如何删除消息“您正在使用.NET Core SDK的预览版”

Ale*_*der 7 asp.net-core

重建解决方案时,出现消息

    You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project
Run Code Online (Sandbox Code Playgroud)

我创建了一个包含的global.json

    {
        "sdk": {
            "version": "2.1.4"
        }
    }
Run Code Online (Sandbox Code Playgroud)

然后在cli中

    dotnet --version
Run Code Online (Sandbox Code Playgroud)

输出

    2.1.4
Run Code Online (Sandbox Code Playgroud)

然后在cli中

    dotnet --list-sdks
Run Code Online (Sandbox Code Playgroud)

输出

    2.1.4 [C:\Program Files\dotnet\sdk]
    2.1.100 [C:\Program Files\dotnet\sdk]
    2.1.101 [C:\Program Files\dotnet\sdk]
    2.1.102 [C:\Program Files\dotnet\sdk]
    2.1.103 [C:\Program Files\dotnet\sdk]
    2.1.104 [C:\Program Files\dotnet\sdk]
    2.1.200-preview-007474 [C:\Program Files\dotnet\sdk]
    2.1.200-preview-007576 [C:\Program Files\dotnet\sdk]
    2.1.200 [C:\Program Files\dotnet\sdk]
    2.1.300-preview2-008533 [C:\Program Files\dotnet\sdk]
Run Code Online (Sandbox Code Playgroud)

在我的.csproj中

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
    <Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
    <PackageReference Include="NLog.Web.AspNetCore" Version="4.5.4" />
</ItemGroup>

<ItemGroup>
    <Content Update="nlog.config">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

通过执行上述操作更改dotnet版本后,在重新生成解决方案时仍会收到消息。如何更改我正在使用的.net core sdk的当前版本并删除该烦人的消息?

And*_*rew 7

在github上查看此PR:https : //github.com/dotnet/sdk/pull/2042

基本上,您可以在.csproj文件中执行以下操作:

<PropertyGroup>
   <SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

  • 如果我使用 Visual Studio 构建而不是从命令行构建,我会看到警告。那么 Visual Studio 不尊重 `global.json` 中的设置? (2认同)