question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hymccordcommented, Oct 12, 2021

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.

0reactions
github-actions[bot]commented, Nov 13, 2021

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

Your GitReleaseManager bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Duplicate AssemblyVersion Attribute
To obtain this, one solution is to add conditional defines to the including project (found in project Properties). Then change the assembly ...
Read more >
MSBuild Task Reference
Learn how to use the MSBuild CallTarget task to invoke the specified targets within the project file. Learn about the parameters and settings...
Read more >
MSBuild reference for .NET Desktop SDK projects
Reference for the MSBuild properties and items that are understood by the .NET Desktop SDK, which includes WPF and WinForms.
Read more >
Create packages with OctoPack
OctoPack adds a custom MSBuild target that hooks into the build process of your solution. When enabled, OctoPack will package your console application...
Read more >
Making a WPF app using a SDK-style project with ...
NET Core SDK that adds missing MSBuild targets and properties to enable building project types that are not supported out of the box....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found