问题描述
我在 Visual Studio 2008 中使用调用 msbuild 的预构建任务:
I am using a pre-build task in Visual Studio 2008 that invokes msbuild:
C:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.exe $(MSBuildProjectDirectory)version.targets /p:Configuration=$(ConfigurationName)
在 version.targets 中,我正在更新 AssemblyInfo.cs 文件以替换版本信息:
Inside version.targets, I am updating the AssemblyInfo.cs file to replace version information:
<FileUpdate
Encoding="ASCII"
Files="$(MSBuildProjectDirectory)PropertiesAssemblyInfo.cs"
Regex="AssemblyInformationalVersion(".*")]"
ReplacementText="AssemblyInformationalVersion("Product $(ConfigurationString) ($(buildDate))")]"
/>
当我通过 Visual Studio 2008 构建项目时,它构建没有任何问题.
When I build the project through Visual Studio 2008, it builds without any problems.
但是当我查看生成的 exe 的版本信息时,它包含以前的时间戳,即使 AssemblyInfo.cs 已更改为正确"的时间戳.
But when I look at the resulting exe's version information, it contains the previous time stamp even though the AssemblyInfo.cs has been changed with the "correct" one.
主编译任务似乎看不到预构建的更改,并且总是落后.
It seems that the pre-build's changes aren't seen by the main compilation task and it's always one behind.
对我做错了什么有任何想法吗?
Any ideas of what I'm doing wrong?
推荐答案
我不认为你做错了什么 - 这是一个错误.
I don't think you are doing anything wrong - it's a bug.
我已经报告了它这里 - 检查你是否可以重现它并添加验证,也许我们可以通过 MS 修复它.
I have reported it here - check if you can reproduce it and add a validation, maybe we can get it fixed by MS.
我尝试了Si"的建议来更新BeforeBuild"事件中的文件 - 但是我仍然得到与 Visual Studio 2008/SP1 相同的错误结果.
I tried the suggestion by "Si" to update the file in the "BeforeBuild" event - however I still get the same wrong result with Visual Studio 2008/SP1.
更新/解决方法:MS 已回复错误报告.作为一种解决方法,您可以添加
UPDATE/WORKAROUND: MS has responded to the bug report. As a workaround you can add
<UseHostCompilerIfAvailable>FALSE</UseHostCompilerIfAvailable>
到您的 csproj 文件.
to your csproj file.
这篇关于预构建 MSBuild 任务以更新与构建的 exe 不同步的 AssemblyInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!