Prevent exeution of GenerateGitVersionInformation in XAML generated intermediate-projects #2280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
During XAML'S build magic a temporary project may get generated and
build (target "GenerateTemporaryTargetAssembly"). The generated project
file already contains compile-items with the generated files from the
original project, this
GitVerstionInformation.g.cs
is listed. When theGitVersion task now runs again, the file is added another time resulting
in an error of CSC.
This patch tries to detect this situation and prevent the execution of
GenerateGitVersionInformation by checking for a special property
injected by GenerateTemporaryTargetAssembly. Unfortunately this is not
documented and thus may change, see https://referencesource.microsoft.com/#PresentationBuildTasks/BuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs,163
Related Issue
This should fix #2228
How Has This Been Tested?
This patch was tested on top of the release v5.3.3 of GitVersionTask and solved the issue on a .NET Framework-4.7.2 solution, compiled with MSBuild 15 as well as VS2019 (aka MSBuild-16).
Checklist: