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

[Docs] MSBuild task missing info on workaround regarding duplicate AssemblyVersionAttributes in WPF projects #2614

Closed
hymccord opened this issue Mar 4, 2021 · 7 comments · Fixed by #2882
Milestone

Comments

@hymccord
Copy link
Contributor

hymccord commented Mar 4, 2021

I ran into this problem today but there is already a workaround in place with the .NET Core 5.0.200 SDK.
Prereqs:

  • SDK styled project using WPF
  • Targeting net5.0-windows (I didn't test others)
  • .NET Core 5.0.200 SDK (or lower to produce the error)

Minimal repro:
net5wpf_gitversionbug.zip
or make the repro yourself

dotnet new wpflib -f net5.0 -o wpfbug
cd wpfbug
dotnet new gitignore
dotnet new globaljson --sdk-version 5.0.200
dotnet add wpfbug.csproj package gitversion.msbuild
git init && git add -A && git commit -m Init
# You'll need to add a usercontrol to the project (via visual studio) so it'll do a two-compile pass
dotnet build

You should get a few errors regarding duplicate attributes. WPF temporary projects don't properly import package reference props and targets. This leads to the temporary project making it's own AssemblyInfo.cs file it thinks it hasn't been generated yet.
In actuality, a second one is then generated and CSC picks up both during the CoreCompile target of the temp assembly... leading to this!

 C:\Users\Hank\source\repos\wpfbug\obj\Debug\net5.0-windows\wpfbug_r4a111wm_wpftmp.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [C:\Users\Hank\source\repos\wpfbug\wpfbug_r4a111wm_wpftmp.csproj]
C:\Users\Hank\source\repos\wpfbug\obj\Debug\net5.0-windows\wpfbug_r4a111wm_wpftmp.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [C:\Users\Hank\source\repos\wpfbug\wpfbug_r4a111wm_wpftmp.csproj]
C:\Users\Hank\source\repos\wpfbug\obj\Debug\net5.0-windows\wpfbug_r4a111wm_wpftmp.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [C:\Users\Hank\source\repos\wpfbug\wpfbug_r4a111wm_wpftmp.csproj]

If you specify a new property (IncludePackageReferencesDuringMarkupCompliation) that was put in in the 5.0.200 release, you can build successfully.
dotnet build -p:IncludePackageReferencesDuringMarkupCompilation=true

I hope this seems appropriate to file an issue here.

Is the best place to put this info in ~docs/input/docs/usage/msbuild.md? If so, I can contribute and submit a PR to help guide people if they run into this error as that flag is not well documented.
If it's of no concern to gitversion, I can close the issue 😄

It should go away with .NET6 as the flag will be enabled by default.

Thanks!

@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 2, 2021
@stale stale bot closed this as completed Jul 9, 2021
@MindaugasLaganeckas
Copy link

@inkahootz : the issue is relevant. It is a bit disappointing, that no one from the project would look into it.

@asbjornu
Copy link
Member

Sorry for not responding until now. I think @inkahootz' proposal of adding information to the documentation is a good one and would accept a PR for that.

@asbjornu asbjornu reopened this Oct 12, 2021
@asbjornu
Copy link
Member

asbjornu commented Oct 12, 2021

However, please see #2841 that already added some related information. A PR expanding on that should take the existing information into account.

@hymccord
Copy link
Contributor Author

I will investigate the interaction between the GenerateAssemblyXAttribute flags and the IncludePackageReferencesDuringMarkupCompliation flag and submit a PR if appropriate.

I do feel there is some room for documentation since net5.0 is still the current release, so there will probably be a PR.

@hymccord
Copy link
Contributor Author

@asbjornu LMK if I need to trim off the last commit and open a separate issue for that.

I did my best to verify that the change works back to .NET Core 3.1 with resource URI's showing the correct version.

Thanks for reopening the issue by the way! Just glad we can get it fixed 👍

@stale stale bot removed the stale label Oct 18, 2021
@asbjornu asbjornu added this to the 5.x milestone Oct 22, 2021
@arturcic arturcic modified the milestones: 5.x, 5.8.0 Nov 8, 2021
@github-actions
Copy link

🎉 This issue has been resolved in version 5.8.0 🎉
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 a pull request may close this issue.

4 participants