Docs: Does not cover Microsoft.AspNet.Core.All

Created on 27 Oct 2018  Â·  33Comments  Â·  Source: dotnet/docs

I'm getting the following error in my VS2017 projects: NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.All' specified a Version of 2.2.0-preview3-35497. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs. However, this document does not cover how Microsoft.AspNetCore.All should actually be referenced in this situation.

Also, the "Implicit References" section does not contain any code samples.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - .NET Core Guide Technology - CLI doc-enhancement

Most helpful comment

It wasn't immediately obvious to me what needed to happen after reading that article, so for the next person coming here with this warning... what I did was:

  1. unload the project
  2. edit the project file
  3. find the reference element
  4. remove the version attribute
  5. save and reload the project.

    Then the warning went away. Not sure if there's an easier way.

All 33 comments

I'm getting the same for Microsoft.AspNetCore.App in a port I'm working on - currently specifying 2.1.5. I'm not sure what the goal of this error is...the result is definitely going to leave users confused in the current state.

cc @DamianEdwards

@Rick-Anderson Is this something you know about?

I'm getting the following error in my VS2017 projects: NETSDK1071: A PackageReference to Microsoft.AspNetCore.All

Use the versionless Microsoft.AspNetCore.App AKA M.A.App

I'm getting the same for Microsoft.AspNetCore.App in a port I'm working on

This document doesn't mention Microsoft.AspNetCore.All or Microsoft.AspNetCore.App

I'm getting the following error in my VS2017 projects: NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.All' specified a Version of 2.2.0-preview3-35497. Specifying the version of this package is not recommended

Correct, you should be using Microsoft.AspNetCore.App ( App, not All). I suspect the fwlink aka.ms/sdkimplicitrefs should be this link

I'm getting the same for Microsoft.AspNetCore.App in a port I'm working on - currently specifying 2.1.5.

M.A.App is versionless, don't specify a version.

@Rick-Anderson Is there a way to not specify a version when using nuget? Nuget forces a version, right? I just upgraded to 2.2 and replaced Microsoft.AspNetCore.All with Microsoft.AspNetCore.App and am receiving this warning:

A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of 2.2.0. Specifying the version of this package is not recommended.

It wasn't immediately obvious to me what needed to happen after reading that article, so for the next person coming here with this warning... what I did was:

  1. unload the project
  2. edit the project file
  3. find the reference element
  4. remove the version attribute
  5. save and reload the project.

    Then the warning went away. Not sure if there's an easier way.

@Rick-Anderson should I just update the link target then? I have permissions to do that.

@mairaw yes

@aeslinger0
No need to unload the project before editing - otherwise your steps are correct.

Not sure what you need, the doc is very clear

Recommendations

Since Microsoft.NETCore.App or NetStandard.Library metapackages are implicitly referenced, the following are our recommended best practices:

  • When targeting .NET Core or .NET Standard, never have an explicit reference to the Microsoft.NETCore.App or NetStandard.Library metapackages via a <PackageReference> item in your project file.

Maybe change that to:

  • When targeting .NET Core or .NET Standard, never have an explicit reference (that is, a version) ...

I just had a quick call with @Rick-Anderson to discuss this. I think there are two issues here:

  • The target of the https://aka.ms/sdkimplicitrefs link doesn't cover the Microsoft.AspNetCore.All and Microsoft.AspNetCore.App scenarios when you get that error message and people don't know what to do
  • However, it seems that not specifying the version for those metapackages shouldn't reuse the link of the implicit reference case (https://aka.ms/sdkimplicitrefs) since those are not implicit package references. I think that error message should change in the product to use a new link.

As a stop gap, we can add some notes about the two packages in that section. And then link to a better place in the ASP.NET docs when that's available.

Thoughts?

/cc @danroth27 @DamianEdwards

@livarcocc any suggestions on where this message is coming from so I can request the error message to be changed in this ASP.NET scenario?

@dsplaisted This comes from the sdk itself.

Opened a new SDK issue then: https://github.com/dotnet/sdk/issues/2879

Moving the stop-gap solution for the current sprint.

@mairaw , @Rick-Anderson How do you go about this in a Windows Console Project targeting .NET Core 2.2 and containing a self hosted web, those also needing to reference the nuget package 'Microsoft.AspNetCore.App'?

In the reply to @perezdev, @Rick-Anderson refers to https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app , but it's not really obvious what you are actually supposed to do.

In a completely new .Net core Console project (template: Visual C# ==> .NET Core ==> Console App (.NET Core) ), are you supposed to use the "Manage NuGet Packages..." feature you can access by right clicking the dependencies node in the Console project?
And in the NuGet Package Manager add the 'Microsoft.AspNetCore.App' package?
Should this get me a project that builds without warnings, or is this the wrong process to get a .NET Core Console project that can self-host the web server and which build without warnings?

@Bartolomeus-649 per the article I reference:

The Microsoft.AspNetCore.App metapackage isn't a traditional package that's updated from NuGet. Similar to Microsoft.NETCore.App, Microsoft.AspNetCore.App represents a shared runtime, which has special versioning semantics handled outside of NuGet. For more information, see Packages, metapackages and frameworks.

To update ASP.NET Core:

On development machines and build servers: Download and install the .NET Core SDK.
On deployment servers: Download and install the .NET Core runtime.


You don't manage it from NuGet, you get it from the SDK.

@Bartolomeus-649 ... and although we have similar coverage in the official docs, which no doubt you've seen, also check out @RickStrahl's blog post ... written in the 2.1-era, but I think all good. Where he says ".NET Core Windows Hosting Pack," we call that the "ASP.NET Core Hosting Bundle." Met Rick in person for the first time recently! It was a _genuine honor_ to shake his hand and thank him in person for saving my keester a few times! :beers:

Keep in mind that what you need on the host also depends on the type of app you deploy:

If you end up hosting with IIS, install the "ASP.NET Core Hosting Bundle," a separate installer listed in the https://dot.net downloads for each release. Use the latest, but note that they had to pull the Preview 3 installer for 3.0 preview (use the Preview 2 installer if you're going to use 3.0 preview bits). There will be a Preview 4 Hosting Bundle when Preview 4 releases.

We have coverage on web hosting in:

@Rick-Anderson Still don't get what I need to to do in Visual Studio to get a brand new .NET Core Console Application, created from the .NET Core Console template shipped with Visual Studio by Microsoft to build without warnings when you need to reference ASP.NET (libraries, namespaces, classes...).

@Bartolomeus-649 Did you confirm that your VS has the ASP.NET and web development workload installed. To confirm, run the VS installer, select Modify, and check the workloads that are checked off.

If you have that, could you put up a repro project on GH that I can pull down here and take a look at? ... something that you're getting errors with. I'll take a look and let you know if it repros here.

Just create a new .NET Core Console project in Visual Studio by using the built-in/included template for -NET Core Console Applications, and then add the NuGet package Microsoft.AspNetCore.App and you'll get this warning when building:
C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of2.2.3. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs

... ok ... I'll give that a shot.

I assume it breaks, too, if you don't supply the version ...

<PackageReference Include="Microsoft.AspNetCore.App" />

Need a few minutes ... I have a PR about to go out. I'll get back to u shortly.

@Bartolomeus-649 Seems ok here ...

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>

1>------ Rebuild All started: Project: ConsoleApp1DotnetDocsIssue8691, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
1>ConsoleApp1DotnetDocsIssue8691 -> C:\Users\XXXXXXXX\Source\repos\ConsoleApp1DotnetDocsIssue8691\bin\Debug\netcoreapp2.2\ConsoleApp1DotnetDocsIssue8691.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Mine look like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.3" />
  </ItemGroup>
</Project>

and ther build output:

1>------ Rebuild All started: Project: Test, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.2.3`. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs
1>Test -> C:\Users\xxx\source\repos\Test\bin\Debug\netcoreapp2.2\Test.dll
1>Done building project "Test.csproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

What's the problem again? ... not sure what you're asking.

In the discussion at https://github.com/aspnet/AspNetCore.Docs/issues/6430, they say that the implicit versioning only works with the Microsoft.NET.Sdk.Web SDK (set in the <Project> element of the project file). However, they also say that they planned (at the time) to make improvements in the way that implicit versioning works for 3.0. I'm using the 3.0 preview SDK here. It didn't complain about my use of the package ref without a version. I'm a bit in the dark at the moment on what they changed for 3.0 in these regards ... I'll have to go on an issue/blog post hunt and see what I can find out.

I get the warning in Visual Studio with the current release of VS and .NET Core.

My question is very simple:
How do get rid of the warning and do things the proper way, which this apparently is not, since it clearly say in the warning message: "not recommended"?

I just want to know "the recommended way" of doing this so everything work as it should.

@Bartolomeus-649 The recommended way is to edit the .csproj file, and remove the Version attribute from the PackageReference:

 <PackageReference Include="Microsoft.AspNetCore.App" />

@dsplaisted What about the current guidance to use the Web SDK so that implicit versioning will work ... still correct for 2.2? ... any changes to that guidance for 3.0 SDK?

@Bartolomeus-649 You might like this one ... I just added it to my reading list. https://natemcmaster.com/blog/2018/08/29/netcore-primitives-2/

@guardrex In the 2.2 SDKs the implicit versioning for the ASP.NET packages was moved down into the vanilla Microsoft.NET.Sdk, so you don't need to use the Web SDK.

In 3.0 it all changes again, instead of a PackageReference, there is now a FrameworkReference item. However, if you are using the Web SDK then the FrameworkReference will be included implicitly and doesn't need to be in your project file. If you wanted a console app to use the ASP.NET shared framework it would look something like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App"  />
  </ItemGroup>
</Project>

Is it a supported action to manually modify the config made by Visual Studio, it won't be overwritten or make the NuGet tool act up now or in the future?
What happens when there's an upgrade, an VS finds a reference with a "missing" verson, will that lead to problem for VS to convert/upgrade the config file to the next version?
Will it work with the cli tools and the package management console? What about the completely new way to do thing in 3.0, where the entire reference should be in a tag with another name, and perhaps in a new ItemGroup?
What about build servers, will they recognize and understand how to work with a PackageReference without a version?

In "Additions to the csproj format for .NET Core" it say that version is required, how does that relate to this?

Version

The __required Version attribute__ specifies the version of the package to restore. The attribute respects the rules of the NuGet versioning scheme. The default behavior is an exact version match. For example, specifying Version="1.2.3" is equivalent to NuGet notation [1.2.3] for the exact 1.2.3 version of the package.

What about interference and working together with other NuGet packages that might be referring to a specific version?

Wise from 20+ years of experience, It feels a bit risky changing the project file by hand, and especially removing a property that is there for every package referenced >99.9% of the time....very likely someone somewhere assumes the version to be there and stuff breaks down and you end up spending days trying to figure out why stuff all of a sudden stop working...

@dsplaisted Why not just include and reference "everything", and the just remove what's not used when building.
You guys know of all your namespaces and classes, right? So just put that in a XML file somewhere, with info on where/how to get it, and point Roslyn to that file and lets stop worrying about references to anything from Microsoft. The references are in the code, why specify them one more time?
Have the developer answer some basic questions like: run on client, run on server, business use, home use, MS toolset for build, 3ed party build chain, run in Azure, run in other cloud, has GUI and so on, that will probably make it easy to choose between stuff if there's more than one source available for a class or a namespace.

The length of the discussion in this thread and the extent of the confusion makes it pretty clear that the documentation needs to be updated to cover this scenario. Not everyone is going to be updating to VS2019 or .NET Core 3, and those that are need guidance on what to do. The original issue was that the documentation does not cover the specific metapackage in question, leaving users in a lurch as to how to resolve the issue.

To me, the solution is simple: Either update the tooling in VS2017 / .NET Core 2.X to ignore the version information in the metapackage and just do the right thing internally (seems like a no-brainer, honestly) or update the docs so that, when the user hits Ctrl+F to look for "Microsoft.AspNetCore.App" they get an actual result with clear instructions.

@natemcmaster created a PR to add that info to our docs: #11736
Please take a look!

With that, I'm considering this docs issue resolved. Once we get the experience and behavior fixed in the product, we can then make additional changes.

/cc @KathleenDollard

@Bartolomeus-649 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 did not understand how there could be conflicts when I did not find any references to Microsoft.AspNetCore.App NuGet package in my xUnit project.

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).

@perezdev 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, am not getting any warnings.

@mairaw 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LJ9999 picture LJ9999  Â·  3Comments

mekomlusa picture mekomlusa  Â·  3Comments

gmatv picture gmatv  Â·  3Comments

skylerberg picture skylerberg  Â·  3Comments

stjepan picture stjepan  Â·  3Comments