开发者

Nant aspnet_compiler.exe release build

开发者 https://www.devze.com 2023-02-16 07:28 出处:网络
I have the following nant task: <!--Compiles the possible release candidate to be used for further testing and possible release -->

I have the following nant task:

<!--Compiles the possible release candidate to be used for further testing and possible release -->
<target name="createReleaseCandidateJob">
  <xmlpoke file="${nant.project.basedir}/${webApplicationProjectName}/Web.config"
   xpath="/configuration/system.web/compilation/@debug"
   value="false" />
  <exec basedir="." program="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe"
        commandline="-p ${webApplicationProjectName} -v / ${releaseCandidateOutputDir}"
        workingdir="."
        failonerror="true"
      />
  <echo>Completed Compile RC Job</echo>
</target>

I also have the following line of code included in my project:

myVersion = "2.0b";
#if DEBUG
     myVersion = Guid.NewId().ToString();
#endif

this is used when loading certain assets (swf files) by being appended as a querystring parameter and ensures that when debugging a cached version isn't received but is manageable once released.

However, after what I believed should be compiling a relase build, the version is still being set as a Guid indicating I'm not achieving a release build yet. I've checked the web.config and the value of debug is changed to false so I'm assuming I'm missing some s开发者_StackOverflow中文版etting in the aspnet_compiler.exe arguments, but I cant find anything which indicates such in the documentation.


The aspnet_compiler can tell the difference between a debug and 'retail' compile using the web.config value, but the conditionals are usually passed as an argument to the compiler (see this) by whatever is driving the build (e.g. Visual Studio, NAnt or whatever). The ASP compiler doesn't have that, so you need to include them in the codedom section of the web.config file:

<system.codedom>
  <compilers>
    <compiler
      language="c#;cs;csharp" 
      extension=".cs"
      warningLevel="4"
      compilerOptions="/d:DEBUG"
      type="Microsoft.CSharp.CSharpCodeProvider, 
        System, Version=2.0.0.0, Culture=neutral, 
        PublicKeyToken=b77a5c561934e089" />
    </compilers>
</system.codedom>

Here, compilerOptions provides the #DEBUG definition you need. That will be picked up by the compiler itself when invoked by aspnet_compiler and should be reflected in the #conditional blocks in your code. So remember to change that as well when you switch the other debug flag in your web.config.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号