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.

Error NU1605 trying to build Winforms.sln

See original GitHub issue
  • .NET Core Version: 3.0.100-preview3-010283 [C:\Program Files\dotnet\sdk] 3.0.100-preview4-010480 [C:\Program Files\dotnet\sdk]

  • Have you experienced this same bug with .NET Framework?: No

Problem description:

After forking dotnet/winforms master Winforms.sln does not build - there are 64 cases of errors like this:

Severity	Code	Description	Project	File	Line	Suppression State
Error	NU1605	Detected package downgrade: Microsoft.NETCore.Platforms from 3.0.0-preview4.19118.6 to 3.0.0-preview3.19115.9. Reference the package directly from the project to select a different version. 
 System.Windows.Forms -> System.Drawing.Common 4.6.0-preview4.19118.6 -> Microsoft.NETCore.Platforms (>= 3.0.0-preview4.19118.6) 
 System.Windows.Forms -> Microsoft.NETCore.Platforms (>= 3.0.0-preview3.19115.9)	System.Windows.Forms.Ref	C:\Users\JoeErickson\source\repos\winforms\src\System.Windows.Forms\ref\System.Windows.Forms.Ref.csproj	1	

This has been an ongoing problem for a while. The workaround has been to change the ~15 C# projects to not treat NU1605 as an error.

NU1605 is explicitly set to be treated as an error in all C# projects in Winforms.sln and this makes good sense but I cannot figure out how to get the correct build of .NET Core 3. Neither the daily build nor the current Preview 3 release works. This problem has persisted for at least several weeks.

Minimal repro:

  1. Install latest Visual Studio 2019 Preview 3 and .NET Core 3 (Preview 3 or daily build).
  2. Fork and clone dotnet/winforms master.
  3. Load Winforms.sln into VS 2019.
  4. Try to build.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ericstjcommented, Feb 22, 2019

Don’t suppress nu1605: package downgrades are bad.

Looks to be a side-effect of https://github.com/dotnet/sdk/blob/0690b28e426f5b7e6dfe7ab4200b83ce3c96bc95/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props#L81-L87. /cc @dsplaisted

The SDK you’re building with is adding a reference to it’s version of MS.NC.Platforms which is lagging behind the version that WinForms gets from the CoreFx packages.

You should be able to workaround it by updating the reference added by the SDK (looks like they don’t have a great hook for defining it).

So add Microsoft.NETCore.Platforms to the list of packages you get from darc (versions.props), then put something like the following in your root Directory.Build.targets:

  <ItemGroup>
    <PackageReference Update="Microsoft.NETCore.Platforms" Version="$(MicrosoftNETCorePlatformsPackageVersion)" />
  </ItemGroup>
0reactions
RussKiecommented, Feb 26, 2019

I have checked out the latest master and now I can’t compile…

Attempting to compile I get a bunch of errors:

Build with surface heuristics started at 17:49:41
Use build tool: C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\MSBuild.exe
0>------- Project started: InternalUtilitiesForTests
1>------- Project started: System.Windows.Forms
2>------- Project started: System.Windows.Forms.Ref
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(14,12): Error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(15,12): Error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(18,12): Error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(19,12): Error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(20,12): Error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(21,12): Error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
0>C:\Development\winforms\artifacts\obj\InternalUtilitiesForTests\Debug\netcoreapp3.0\InternalUtilitiesForTests.AssemblyInfo.cs(22,12): Error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute
0>------- Project finished: InternalUtilitiesForTests. Succeeded: False. Errors: 7. Warnings: 0
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(14,12): Error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(15,12): Error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(18,12): Error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(19,12): Error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(20,12): Error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(21,12): Error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
2>C:\Development\winforms\artifacts\obj\System.Windows.Forms.Ref\Debug\netcoreapp3.0\System.Windows.Forms.Ref.AssemblyInfo.cs(22,12): Error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute
2>------- Project finished: System.Windows.Forms.Ref. Succeeded: False. Errors: 7. Warnings: 0
1>------- Project finished: System.Windows.Forms. Succeeded: True. Errors: 0. Warnings: 0
3>------- Project started: WinformsControlsTest
4>------- Project started: System.Windows.Forms.IntegrationTests
5>------- Project started: System.Windows.Forms.Design.Editors
6>------- Project started: System.Windows.Forms.Design
4>------- Project finished: System.Windows.Forms.IntegrationTests. Succeeded: True. Errors: 0. Warnings: 0
5>------- Project finished: System.Windows.Forms.Design.Editors. Succeeded: True. Errors: 0. Warnings: 0
7>------- Project started: System.Windows.Forms.Design.Editors.Tests
7>------- Project finished: System.Windows.Forms.Design.Editors.Tests. Succeeded: True. Errors: 0. Warnings: 0
3>------- Project finished: WinformsControlsTest. Succeeded: True. Errors: 0. Warnings: 0
6>------- Project finished: System.Windows.Forms.Design. Succeeded: True. Errors: 0. Warnings: 0
Build completed in 00:00:27.495

I also get the following warning: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

NuGet Warning NU1605
While NU1605 is considered a warning by the NuGet tooling, the .NET SDK opts into treating this warning as an error through WarningsAsErrors...
Read more >
Error NU1605 Detected package downgrade
Something that I've run into that causes this error is having multiple references to the same package in one or more .csproj files....
Read more >
Blazor - Error NU1605 is thrown when publishing a self ...
Publishing fails with the NU1605 error. See the Publish output for details. Workaround: Use the solution from the following help topic: NuGet ...
Read more >
Error NU1605 - Detected package downgrade. Reference ...
This error occurs when a dependency package has a version higher than an existing package version in the project solution. ... Another way...
Read more >
VS 2019 RC -- Can't create Winforms (.Net Core)
I installed VS2019 Community Edition RC and tried to create a new project. The template I chose was Windows Forms App (.NET core)....
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