zoukankan      html  css  js  c++  java
  • 用NAnt编译带有资源文件(*.resx,*.bmp,*.gif等)的C#项目


    情况一:如何编译支持多语言切换的项目

        <!--
        转换资源文件的格式(编译资源文件的必要步骤)
        -->
        <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>

  • 相关阅读:
    MSP430程序库<二>UART异步串口
    MSP430程序库<五>SPI同步串行通信
    MSP430程序库<四>printf和scanf函数移植
    短信猫的实现(C#)类库开源啦
    短信猫软件的实现(C#)<十三>超长短信
    Linq to SQlite的使用
    MSP430程序库<三>12864液晶程序库
    查看Linux中自带的jdk ,设置JAVA_HOME
    [linux] vimrc
    [C#] socket demo
  • 原文地址:https://www.cnblogs.com/rrooyy/p/74905.html
Copyright © 2011-2022 走看看