[Docs] MSBuild task missing info on workaround regarding duplicate AssemblyVersionAttributes in WPF projects
See original GitHub issueI 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:
- Created 3 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
I will investigate the interaction between the
GenerateAssemblyXAttribute
flags and theIncludePackageReferencesDuringMarkupCompliation
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.
🎉 This issue has been resolved in version 5.8.0 🎉 The release is available on:
Your GitReleaseManager bot 📦🚀