Sdk: Warning NETSDK1071 cannot be suppressed

Created on 22 Oct 2018  路  3Comments  路  Source: dotnet/sdk

In ASP.NET, we use DisableImplicitFrameworkReferences and explicit references to Microsoft.NETCore.App because we want to explicitly control what goes into things like the LZMA, shared frameworks, etc. In the 2.2.0-preview3 SDK, this produces an warning in our build that we cannot suppress.

C:\Users\namc.dotnet\x64\sdk\2.2.100-preview3-009430\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.NETCore.App' specified a Version of [2.2.0-preview3-27014-02, 2.3.0). Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs [C:\src\aspnet\AspNetCore22\src\Framework\Microsoft.AspNetCore.App\Microsoft.AspNetCore.App.shfxproj]

Can we suppress this warning when DisableImplicitFrameworkReferences == true? Presumably, anyone setting this opt-out flag knows what they are doing.

@dsplaisted

Most helpful comment

Like this:

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.11" >
  <AllowExplicitVersion>true</AllowExplicitVersion> 
</PackageReference>

All 3 comments

@natemcmaster You should be able to set the AllowExplicitVersion metadata on the PackageReference to true in order to suppress this warning.

This is supposed to happen automatically if you have DisableImplicitFrameworkReferences set to true. Are you adding PackageReference after the evaluation of the SDK targets?

Aha, yes. That was it. We generate our PackageReference items during a target. Adding AllowExplicitVersion=true to the metadata works. Thanks!

Like this:

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.11" >
  <AllowExplicitVersion>true</AllowExplicitVersion> 
</PackageReference>
Was this page helpful?
0 / 5 - 0 ratings