I have the following warning
Severity Code Description Project File Line Suppression State
Warning NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.1.6`. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs MyApi C:\Program Files\dotnet\sdk\2.2.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets 153
I tried removing the reference by editing the project file and then adding the nuget package, however when I did this a lot of references no longer worked correctly.
I note the error is mentioning sdk\2.2 which I did install recently on my computer but there is no reference to it in the project file.
I am using VS2017 15.9.5
There's a few ways around this.
If you include the PackageReference
but remove the Version
attribute, it should make the warning go away. This is because it is a metapackage, which (simply put) is a type of package that gets the version based on your framework version, more here: https://learn.microsoft.com/en-us/dotnet/core/packages#metapackages
To disable the warnings, add AllowExplicitVersion
:
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.11" >
<AllowExplicitVersion>true</AllowExplicitVersion>
</PackageReference>
More here: https://github.com/dotnet/sdk/issues/2602
I ran into a similar situation creating a new xUnit Test Project (.NET Core). When I added a reference to an existing ASP.NET Core Web App project, I got:
Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of:
- Microsoft.AspNetCore.Authorization
- Microsoft.AspNetCore.Cors
- Microsoft.AspNetCore.Diagnostics.Abstractions
- Microsoft.AspNetCore.Mvc
- Microsoft.AspNetCore.Mvc.Abstractions
- Microsoft.AspNetCore.Mvc.Core
- Microsoft.AspNetCore.Mvc.Formatters.Json
- Microsoft.AspNetCore.Mvc.RazorPages
- Microsoft.AspNetCore.Mvc.ViewFeatures
- Microsoft.AspNetCore.Razor.Runtime
- Microsoft.AspNetCore.Routing
I eliminated these version conflicts by adding the Microsoft.AspNetCore.App
to my xUnit Test project.
At this point, I started getting the explicit version reference warning (NETSDK1071).
NuGet Package Manager and Package Manager Console within Visual Studio will both add the version attribute to Microsoft.AspNetCore.App when installing the package. You may remove the version attribute by editing your .csproj file. This should eliminate the NETSDK1071 warning.
Note that if you do remove the version attribute, then NuGet Package Manager will disable the [Uninstall] + [Update] buttons and state: "- implicitly referenced by an SDK...".
At this point, I am not getting any warnings.
There is a lot of chatter and some tldr; documentation related to this issue. FWIW, here are a couple of succinct resources that I think warrant highlighting:
Microsoft.AspNetCore.App metapackage for ASP.NET Core 2.1 or later
@nguerrera summarized the the situation very well:
It is for all tests, or even all non-web projects that have a reference to a web project. It is not really a workaround in that the web reference did not flow transitively in .NET Core 2.x. You need to add it, and you should add it without the version so that the SDK can pick the correct version to avoid conflicts.
Better news: starting with .NET Core 3.0, the web reference will flow transitively and you can reference a web project from a test project without any other steps. So I am closing this. The design of 2.x cannot be changed, but we specifically designed things in 3.0 to have transitive Framework References, and this was a motivating scenario for that.
And here are a couple of tldr; conversations:
Does not cover Microsoft.AspNet.Core.All #8691
Version conflicts in test project depending on a Microsoft.AspNetCore.App project #2253
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With