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.

[Bug] Duplicate attributes with MSBuild task in WPF net5.0-windows project

See original GitHub issue

Describe the bug After installing the MSBuild GitVersion task and removing all version information the project fails to compile due to duplicate version attribute errors.

Build output:

Build started...
1>------ Build started: Project: WpfApp1, Configuration: Debug Any CPU ------
1>C:\Users\mbender\Desktop\WpfApp1\WpfApp1\obj\Debug\net5.0-windows\WpfApp1_0fxhewp2_wpftmp.AssemblyInfo.cs(16,12,16,58): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
1>C:\Users\mbender\Desktop\WpfApp1\WpfApp1\obj\Debug\net5.0-windows\WpfApp1_0fxhewp2_wpftmp.AssemblyInfo.cs(17,12,17,67): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
1>C:\Users\mbender\Desktop\WpfApp1\WpfApp1\obj\Debug\net5.0-windows\WpfApp1_0fxhewp2_wpftmp.AssemblyInfo.cs(20,12,20,54): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute
1>Done building project "WpfApp1_0fxhewp2_wpftmp.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Expected Behavior

Following the basic tutorial I’d expect the project to compile and have GitVersion-calculated version information applied.

Actual Behavior

Project fails to compile.

Possible Fix

No clue.

Steps to Reproduce

  1. Create a new .NET 5 WPF project (net5.0-windows)
  2. Ensure that the new project is using GIT, i.e. create at least a local GIT repo
  3. Install GitVersion.MsBuild Nuget
  4. Ensure no version information is provided inside the project (a new project shouldn’t have any information)
  5. Attempt to compile the project

Context

Cannot use GitVersion in my project.

Your Environment

Windows Server 2019 Standard GIT 2.32.0.windows.2 VS 2019 GitVersion.MsBuild 5.6.11

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Crown0815commented, Aug 26, 2021

@arp-mbender maybe try this

1reaction
asbjornucommented, Aug 16, 2021

Seems like a duplicate of #2512, #2278, #2226, #2163 and #1802.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF application build fails with "Program does not contain ...
WPF application build fails with "Program does not contain a static 'Main' method" using MSBuild from SDK 6.0 instead of bundled MSBuild in ......
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 >
CS0579 Duplicate Attribute Error with .NET Core
The error is a result of the build process generating AssemblyInfo.cs files in each project obj directory. This file exists to provide MSBuild...
Read more >
Net 5 library projects have incorrect configuration
When create a Windows Forms Class Library or WPF Class library, the target framework displays: net5.0-windows. Which project template did ...
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