Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent exeution of GenerateGitVersionInformation in XAML generated intermediate-projects #2280

Merged
merged 1 commit into from
May 21, 2020

Conversation

jbaehr
Copy link
Contributor

@jbaehr jbaehr commented May 20, 2020

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 the
GitVersion 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:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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 the
GitVersion 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 also
- https://referencesource.microsoft.com/#PresentationBuildTasks/BuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs,163
- GitTools#2228
Copy link

@prantzos prantzos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can verify that in my case this solution worked and the error on issue #2228 does not occur.

Copy link
Member

@arturcic arturcic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@arturcic
Copy link
Member

@jbaehr Thanks for the investigation. I will merge it

@arturcic arturcic merged commit 6e443ae into GitTools:master May 21, 2020
@arturcic arturcic added this to the 5.3.x milestone May 21, 2020
@arturcic arturcic modified the milestones: 5.3.x, 5.3.4 May 21, 2020
@github-actions
Copy link

🎉 This issue has been resolved in version 5.3.4 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] The item "obj\Debug\GitVersionInformation.g.cs" was specified more than once in the "Sources" parameter
3 participants