RonC
RonC

Reputation: 33897

How to force Visual Studio to compile project against the release version of .Net Core 3.1?

Lately I have noticed in the Output Window of Visual Studio that when I compile my solution I see this message:

You are working with a preview version of the .NET Core SDK

This seems odd to me since I'm not knowingly currently using a preview version of .NET Core SDK. To explore this further, I created a new solution that contains one project based on the default Visual Studio "Class Library (.NET Core) project template. Pretty plain vanilla.

enter image description here.

Here is the total sum of the proj file:

enter image description here

And yet, when I build this project, I see "You are working with a preview version of the .NET Core SDK" in the output window (see first screenshot). What's up with that? I'm using the latest production version of Visual Studio which currently is Version 16.8.5.

I see that this SO question is closely related to my question but unfortunately the poster simply asked how to make the message go away. So the accepted answer is to suppress the message like so:

<PropertyGroup>
   <SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

But I don't want to just suppress the message if under the hood the compiler is really compiling against a preview SDK. I want the compiler to stop using the preview SDK and use the one specified in the proj file. Namely the the production netcoreapp3.1 SDK.

Here are the SDKs I currently have installed:

enter image description here

So how do I make that happen and why is it not already happening?

Upvotes: 1

Views: 1774

Answers (1)

Jonathon Marolf
Jonathon Marolf

Reputation: 2089

There are a few things you can do:

  1. Tell Visual Studio that you do not want to use preview SDKs, this option can be found under Tools -> Options -> Environment -> Preview Features. If this is unchecked Visual Studio will only use released SDKs to build your project

enter image description here

  1. If you only want Visual Studio to use non-preview SDKs for some projects you can add a global.json file to the root folder of those projects. global.json files have many options to configure which SDK should be used to build a given project but for our purposes we just care about allowPrerelease. Setting that to false will ensure your project (or solution) is only built with a released SDK.

NOTE: the defaults are different in different versions of Visual Studio. If you are using a Preview release of Visual Studio it will automatically use preview SDKs. If you are using a released build of Visual Studio it should prefer releases SDKs (unless the option shown in Tools->Options is checked).

Upvotes: 2

Related Questions