user189198
user189198

Reputation:

Support multiple .NET Core versions on Mac OS X

I need to develop both .NET Core project.json-based and .csproj-based applications on my Mac OS system. This is because certain environments only offer a down-level version of the .NET Core runtime, that I don't have direct control over.

However, when I install a new version of the .NET SDK, it overwrites the old one.

Question: How can I install and reference multiple versions of the .NET Core SDK on my Mac?

Upvotes: 2

Views: 4207

Answers (1)

MindingData
MindingData

Reputation: 12470

This article is for windows but it's essentially the same on any platform : http://dotnetcoretutorials.com/2017/02/17/developing-two-versions-net-core-sdk-side-side/

When you install a new version of the SDK, it doesn't overwrite the files, but it does make the command line use the very latest version. By default, all SDK's are installed at

/usr/local/share/dotnet/dotnet

In the root of your solution you add a global.json file with the following contents :

{
  "sdk": {
    "version": "1.0.0-preview2-003131"
  }
}

Where the "version" is the version of the SDK you want to use (It should be the same as the folder name of the SDK in your dotnet folder).

If you are trying to open an existing project, then putting this global.json file will allow you to use the old tooling. And if you are trying to create a new project, but want to use project.json, adding this file in a folder THEN running "dotnet new" will allow you to create a project under the old tooling.

Upvotes: 3

Related Questions