警告NETSDK1071到'Microsoft.AspNetCore.App'的PackageReference指定的版本为2.1.6. [英] Warning NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.1.6`
问题描述
我有以下警告
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
我尝试通过编辑项目文件然后添加nuget包来删除引用,但是当我这样做时,很多引用不再能正常工作.
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.
我注意到错误是提到最近在计算机上安装的sdk \ 2.2,但在项目文件中没有对其进行引用.
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.
我正在使用VS2017 15.9.5
I am using VS2017 15.9.5
推荐答案
有几种解决方法.
-
如果包括
PackageReference
但删除了Version
属性,则应该使警告消失.这是因为它是一个 metapackage ,(简单地说)是一种包类型,它根据您的框架版本获取版本,更多信息请参见: https://docs.microsoft.com/en-us/dotnet/core/packages#metapackages
If you include the
PackageReference
but remove theVersion
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://docs.microsoft.com/en-us/dotnet/core/packages#metapackages
要禁用警告,请添加AllowExplicitVersion
:
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.11" >
<AllowExplicitVersion>true</AllowExplicitVersion>
</PackageReference>
此处更多: https://github.com/dotnet/sdk/issues/2602
这篇关于警告NETSDK1071到'Microsoft.AspNetCore.App'的PackageReference指定的版本为2.1.6.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!