Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not cover Microsoft.AspNet.Core.All #8691

Closed
robertmclaws opened this issue Oct 27, 2018 — with docs.microsoft.com · 33 comments · Fixed by #11736
Closed

Does not cover Microsoft.AspNet.Core.All #8691

robertmclaws opened this issue Oct 27, 2018 — with docs.microsoft.com · 33 comments · Fixed by #11736
Labels
cli/subsvc doc-enhancement Improve the current content [org][type][category]
Milestone

Comments

Copy link
Contributor

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.

@NickCraver
Copy link
Member

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

@Thraka
Copy link
Contributor

Thraka commented Nov 21, 2018

@Rick-Anderson Is this something you know about?

@Rick-Anderson
Copy link
Contributor

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.

@perezdev
Copy link

perezdev commented Dec 5, 2018

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

@Rick-Anderson
Copy link
Contributor

@perezdev https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app

@aeslinger0
Copy link

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.

@mairaw
Copy link
Contributor

mairaw commented Dec 17, 2018

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

@Rick-Anderson
Copy link
Contributor

@mairaw yes

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

@Rick-Anderson
Copy link
Contributor

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

@mairaw
Copy link
Contributor

mairaw commented Dec 18, 2018

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

@mairaw mairaw self-assigned this Dec 20, 2018
@mairaw mairaw removed the ⌚ Not Triaged Not triaged label Dec 20, 2018
@mairaw
Copy link
Contributor

mairaw commented Dec 20, 2018

@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?

@livarcocc
Copy link

@dsplaisted This comes from the sdk itself.

@dsplaisted
Copy link
Member

Specifically, the error message is defined here: https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/Resources/Strings.resx

@mairaw
Copy link
Contributor

mairaw commented Jan 29, 2019

Opened a new SDK issue then: dotnet/sdk#2879

Moving the stop-gap solution for the current sprint.

@mairaw mairaw removed this from the February 2019 milestone Feb 25, 2019
@guardrex
Copy link
Contributor

guardrex commented Apr 7, 2019

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

@Bartolomeus-649
Copy link

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 of 2.2.3. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs

@guardrex
Copy link
Contributor

guardrex commented Apr 7, 2019

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

@guardrex
Copy link
Contributor

guardrex commented Apr 7, 2019

@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 ==========

@Bartolomeus-649
Copy link

Bartolomeus-649 commented Apr 7, 2019

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 ==========

@guardrex
Copy link
Contributor

guardrex commented Apr 7, 2019

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

In the discussion at dotnet/AspNetCore.Docs#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.

@Bartolomeus-649
Copy link

Bartolomeus-649 commented Apr 7, 2019

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.

@dsplaisted
Copy link
Member

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

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

@guardrex
Copy link
Contributor

guardrex commented Apr 7, 2019

@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/

@dsplaisted
Copy link
Member

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

@Bartolomeus-649
Copy link

Bartolomeus-649 commented Apr 7, 2019

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

@Bartolomeus-649
Copy link

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

@robertmclaws
Copy link
Contributor Author

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.

@mairaw
Copy link
Contributor

mairaw commented Apr 11, 2019

@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

@RandyDaddis
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli/subsvc doc-enhancement Improve the current content [org][type][category]
Projects
None yet
Development

Successfully merging a pull request may close this issue.