Nant aspnet_compiler.exe 发布版本
我有以下 nant 任务:
<!--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>
我的项目中还包含以下代码行:
myVersion = "2.0b";
#if DEBUG
myVersion = Guid.NewId().ToString();
#endif
通过附加为查询字符串参数来加载某些资产(swf 文件)时使用,并确保在调试时不会收到缓存版本但一旦发布就可以管理。
然而,在我认为应该编译发布版本之后,该版本仍然被设置为 Guid,表明我尚未实现发布版本。我检查了 web.config 并将 debug 的值更改为 false,因此我假设我缺少 aspnet_compiler.exe 参数中的某些设置,但我在文档中找不到任何指示此类设置的内容。
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 setting in the aspnet_compiler.exe arguments, but I cant find anything which indicates such in the documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
aspnet_compiler 可以使用 web.config 值区分调试和“零售”编译之间的区别,但条件通常作为参数传递给编译器(请参阅 this)由驱动构建的任何内容(例如 Visual Studio、NAnt 或其他)驱动。 ASP 编译器没有这个功能,因此您需要将它们包含在 web.config 文件的
codedom
部分中:这里,compilerOptions 提供您需要的 #DEBUG 定义。当 aspnet_compiler 调用时,编译器本身会拾取该值,并应反映在代码中的 #conditional 块中。因此,当您在 web.config 中切换其他调试标志时,请记住也要更改它。
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: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.