Compiling C # projects with resource files (*.resx,*.bmp,*.gif, etc.) with Nant

Source: Internet
Author: User
Tags echo message resource

Scenario One: How to compile an item that supports multiple language switching

The 
 <!--transform the format of the resource file (the necessary steps to compile the resource file)--> <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/> <!--compiling a string resource file (Simplified Chinese)--> <al o utput= "${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> <!--compiling string resource file (US English)--> <al output= "${build.dir}\bin\en-us\${nant.project.name}.resources.dll" target= "Lib" culture= "en-US" > <sou RCEs basedir= "${build.dir}\bin\En-US "> <includes name=" ${nant.project.name}. Resourcetext.en-us.resources "/> </sources> </al> <!--compiling ${nant.project.name} main project-
    -> <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 failonemp Ty= "true" > <includes name= "**\*.cs/> <includes name=". \commonassemblyinfo.cs "/> </sources> <resources basedir=" ${build.dir}\bin "> <includes nam E= "${nant.project.name}. Resourcetext.resources "/> </resources> </csc> 

Scenario two: How to compile a project with a picture resource

You do not need to use (and should not use) <resgen> tags when the name of the resource filename is exactly the same as those vs.net automatically generated resource file names.

You should use the <resources> tag, compiled by the compile task to execute the compilation of the resource file at compile time.

Here is an example:

<target name= "Build" >
    <echo message= "compiling ${nant.project.name} project/> <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>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.