在预构建事件中修改.csproj [英] Modify .csproj in pre-build event
问题描述
tl; dr:如何在执行预构建事件时使用ClickOnce
发布期间修改.csproj
文件?
tl;dr: How to modify the .csproj
file during publishing with ClickOnce
while executing pre-build events?
长: 我正在使用Microsoft托管的TFS对解决方案进行版本控制.
Long: I'm using TFS hosted by Microsoft for version control of my solution.
使用ClickOnce
进行发布时,我获得了最新的修订号+ 1,没有任何问题.我还可以将新版本号成功写入构建过程之外的.csproj
文件中.
When publishing with ClickOnce
, I get the latest revision number + 1 without problems. I also can successfully write the new version number into the .csproj
file outside my build-process.
问题是,.csproj
文件在构建过程中没有得到更新-它可能处于写锁定状态.我在Notepad ++中收到有关该文件修改的通知,但该文件仍包含旧版本,并且VS没有注意到任何更改.
The problem is, that the .csproj
file doesn't get updated during the build process - it might be in a write-lock. I get a notification inside Notepad++ about the modification of the file, but the file still contains the old version and VS didn't notice any changes.
到目前为止,我发现可以解决此问题的唯一解决方案是: 将修订更新移至构建后事件中,然后在实际修订号中添加2而不是1.不幸的是,这将导致每当其他开发人员签入代码时,修订号就会过时.
The only solution by now I found to resolve this issue: Move the revision update into the post-build events and add 2 instead of one to the actual revision number. Unfortunately this would cause that revision number would be out of date whenever other developers check-in code.
推荐答案
好的,点击...:(.
Ok, strike that... :(.
进行更多的区分之后,您将需要覆盖GenerateApplicationManifest目标,以使其正常工作.该目标不使用*DependsUpon
属性组,因此很难覆盖.整个流程在Microsoft.Common.Targets
文件中定义,您可以在%windir%\Microsoft.NET\Framework{cpu}\{version} folder
中找到.
After some more diffing, you'll need to override the GenerateApplicationManifest target to get this to work. That target doesn't use a *DependsUpon
propertygroup, so it's harder to overwrite. The whole flow is defined in the Microsoft.Common.Targets
file which you can find in the %windir%\Microsoft.NET\Framework{cpu}\{version} folder
.
另请参阅: