Stefan Over
Stefan Over

Reputation: 6046

Modify .csproj in pre-build event

tl;dr: How to modify the .csproj file during publishing with ClickOnce while executing pre-build events?

Long: I'm using TFS hosted by Microsoft for version control of my solution.

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.

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.

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.

Upvotes: 4

Views: 2710

Answers (1)

jessehouwing
jessehouwing

Reputation: 114461

Ok, strike that... :(.

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.

See also:

Upvotes: 1

Related Questions