問題描述
我在 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!