警告NETSDK1071到'Microsoft.AspNetCore.App'的PackageReference指定的版本为2.1.6. [英] Warning NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.1.6`

查看:441
本文介绍了警告NETSDK1071到'Microsoft.AspNetCore.App'的PackageReference指定的版本为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

推荐答案

有几种解决方法.

  • 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://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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆