error NU1605 : Detected package downgrade: Microsoft.NETCore.App from 2.1.2 to 2.1.0After I migrated from .netcoreapp2.0 to .netcoreapp2.1, I am getting a error NU1605: Detected package downgrade: Microsoft.NETCore.App from 2.1.2 to 2.1.0 when running dotnet publish with the -r option.
snapshot

one of my class libs csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
<PackageReference Include="xunit" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rubicon.ReverseProxy\Rubicon.ReverseProxy.csproj" />
</ItemGroup>
</Project>
main project csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.2" />
<PackageReference Include="Polly" Version="6.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Steeltoe.CloudFoundry.ConnectorCore" Version="2.0.0" />
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="deploy.*.bat">
<DependentUpon>deploy.bat</DependentUpon>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="manifest.*.yml">
<DependentUpon>manifest.yml</DependentUpon>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="manifest.yml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
@weshaggard
One of the packages you are referencing is likely pulling in a lower version of a package. @DamianEdwards have you seen this?
Based on the error screenshot it looks like a couple of your test projects are directly referencing 2.1.0 of the runtime either via a direct PackageReference or via overriding the RuntimeFrameworkVersion. Can you provide a pointer to your Rubicon.ReversProxy.Tests.Common.csproj?
The weird part is that running dotnet publish without -r (i.e., to output a dll) doesn't cause any issues.
Here's the Rubicon.ReverseProxy.Tests.Common.csproj.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.2" />
<PackageReference Include="xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rubicon.ReverseProxy\Rubicon.ReverseProxy.csproj" />
</ItemGroup>
</Project>
By the way, I added the <NoWarn>$(NoWarn);NU1605</NoWarn> as a workaround for this issue. If I remove if, I get the error messages. But it doesn't look like a good idea to simply suppress these errors.
Have you tried updating your reference to Microsoft.AspNetCore.TestHost to the latest version?
I have. Doesn't make a difference with regards to the NU1605 : Detected package downgrade error.
I left it as 2.0.2 in the end because the latest version of Microsoft.AspNetCore.TestHost changed its behavior somehow and it broke our tests.
In your test project, try setting
<PropertyGroup>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
in the test project.
This is likely caused by NuGet using different properties to restore than the actual build will use - the RuntimeIdentifier will not be forward across P2P references during the build but NuGet will evaluate all projects using the global property and thus the runtime roll-forward kicks in.
And btw roll-forward doesn't kick in for test projects since they are libraries by default and the test SDK changes them to <OutputType>Exe</OutputType> too late for the self-contained roll-forward IIRC.
In theory, you can also work around this by setting <OutputType>Exe</OutputType> in the test project instead of the TargetLatestRuntimePatch mentioned above.
I have the same issue. Builds locally fine, but throws same error as above for my test project on the build server.
Adding <OutputType>Exe</OutputType> worked for me.
Adding just <OutputType>Exe</OutputType> got over the downgrade error but publish then failed on:
NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.2, but with current settings, version 2.1.0 would be used instead
Adding <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> fixes it fully.
My unit test project showed up as running 2.1.0 where all the other projects in my solution were running 2.1.2 and I got the same error.
Adding <PropertyGroup><TargetLatestRuntimePatch>true</TargetLatestRuntimePatch></PropertyGroup> solved the issue for me as well.
Change .csproj doesn't work.
Nuget problems are persistent with any .net core 2.1 project I start.
When I use "Nuget Console" with "Update-Package -reinstall", then Project name is cleared and it displays "'default' project not found" error. :-(
My visual studio has several Nuget related errors and repair/reinstall doesn't fix anything.
Issue moved to dotnet/core-sdk #81 via ZenHub
Most helpful comment
In your test project, try setting
in the test project.
This is likely caused by NuGet using different properties to restore than the actual build will use - the RuntimeIdentifier will not be forward across P2P references during the build but NuGet will evaluate all projects using the global property and thus the runtime roll-forward kicks in.
Also see https://github.com/dotnet/sdk/issues/1834