用NAnt編譯帶有資源檔(*.resx,*.bmp,*.gif等)的C#項目

來源:互聯網
上載者:User

情況一:如何編譯支援多語言切換的項目

    <!--
    轉換資源檔的格式(編譯資源檔的必要步驟)
    -->
    <resgen input="ResourceText.resx" output="${nant.project.name}.ResourceText.resources" todir="${build.dir}\bin" />
    <resgen input="ResourceText.zh-CHS.resx" output="${nant.project.name}.ResourceText.zh-CHS.resources" todir="${build.dir}\bin\zh-CHS" />
    <resgen input="ResourceText.en-US.resx" output="${nant.project.name}.ResourceText.en-US.resources" todir="${build.dir}\bin\en-US" />
    <!--
    編譯字串資源檔(簡體中文)
    -->
    <al output="${build.dir}\bin\zh-CHS\${nant.project.name}.resources.dll" target="lib" culture="zh-CHS">
      <sources basedir="${build.dir}\bin\zh-CHS">
        <includes name="${nant.project.name}.ResourceText.zh-CHS.resources" />
      </sources>
    </al>
    <!--
    編譯字串資源檔(美國英語)
    -->
    <al output="${build.dir}\bin\en-US\${nant.project.name}.resources.dll" target="lib" culture="en-US">
      <sources basedir="${build.dir}\bin\en-US">
        <includes name="${nant.project.name}.ResourceText.en-US.resources" />
      </sources>
    </al>

    <!--
    編譯${nant.project.name}主專案
    -->
    <csc
    warnaserror="true"
    debug="${build.debug}"
    doc="${build.dir}\bin\${nant.project.name}.xml"
    output="${build.dir}\bin\${nant.project.name}.exe"
    target="winexe" win32icon="App.ico">
    <sources failonempty="true">
      <includes name="**\*.cs" />
      <includes name="..\CommonAssemblyInfo.cs" />
    </sources>
    <resources basedir="${build.dir}\bin">
      <includes name="${nant.project.name}.ResourceText.resources" />
    </resources>
    </csc>

情況二:如何編譯帶有圖片資源的項目

當資源檔名的命名方式剛好與那些VS.NET自動產生的資源檔名相同時,你不需要使用(也不應該使用) <resgen>標籤。

你應該使用<resources>標籤,由編譯任務在編譯時間執行對資源檔的編譯。
下面是一個範例:

  <target name="build">
    <echo message="編譯${nant.project.name}項目" />
    <csc
    warnaserror="true"
    debug="${build.debug}"
    doc="${build.dir}\bin\${nant.project.name}.xml"
    output="${build.dir}\bin\${nant.project.name}.dll"
    target="library">
    <sources failonempty="true">
      <includes name="**\*.cs" />
      <includes name="..\CommonAssemblyInfo.cs" />
    </sources>
    <resources basedir="." prefix="${nant.project.name}" dynamicprefix="true">
      <includes name="Arrows\*.gif" />
      <includes name="CheckBoxes\*.bmp" />
      <includes name="RadioButtons\*.gif" />
    </resources>
    </csc>
  </target>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.