pre-建立MSBuild任务,更新程序集信息不带内置exe文件同步 [英] Pre-build MSBuild task to update AssemblyInfo not in sync with built exe

查看:153
本文介绍了pre-建立MSBuild任务,更新程序集信息不带内置exe文件同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2008的一个pre-生成任务调用的MSBuild:

I am using a pre-build task in Visual Studio 2008 that invokes msbuild:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.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)\Properties\AssemblyInfo.cs"
    	Regex="AssemblyInformationalVersion\(&quot;.*&quot;\)\]" 
    	ReplacementText="AssemblyInformationalVersion(&quot;Product $(ConfigurationString) ($(buildDate))&quot;)]"
    />

当我建立通过Visual Studio 2008的项目,它建立没有任何问题。

When I build the project through Visual Studio 2008, it builds without any problems.

但是,当我看到由此产生的EXE的版本信息,它包含即使AssemblyInfo.cs中已经改变的正确的一个previous时间戳。

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.

看来,pre-构建的变化不是由主编译任务看到和它总是一个在后面。

It seems that the pre-build's changes aren't seen by the main compilation task and it's always one behind.

我做错了任何想法?

推荐答案

我不知道你在做什么错 - 这是一个错误

I don't think you are doing anything wrong - it's a bug.

我已经报告说,它<一个href=\"https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=423670\">here - 检查是否可以重现它并添加一个验证,也许我们可以得到固定的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.

UPDATE /替代方法:MS已经回应了错误报告。作为一种变通方法,您可以添加

UPDATE/WORKAROUND: MS has responded to the bug report. As a workaround you can add

<UseHostCompilerIfAvailable>FALSE</UseHostCompilerIfAvailable>

您的csproj文件。

to your csproj file.

这篇关于pre-建立MSBuild任务,更新程序集信息不带内置exe文件同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆