DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Zero to AI Hero, Part 2: Understanding Plugins in Semantic Kernel, A Deep Dive With Examples
  • Publishing Flutter Packages to JFrog Artifactory
  • Feature Flags in .NET 8 and Azure
  • Implementing CRUD Operations With NLP Using Microsoft.Extensions.AI

Trending

  • Event-Driven Microservices: How Kafka and RabbitMQ Power Scalable Systems
  • Caching 101: Theory, Algorithms, Tools, and Best Practices
  • AI Agents: A New Era for Integration Professionals
  • Traditional Testing and RAGAS: A Hybrid Strategy for Evaluating AI Chatbots
  1. DZone
  2. Coding
  3. Languages
  4. Switching Between .NET Core SDK Versions

Switching Between .NET Core SDK Versions

If you're working with two different versions of .NET Core, you'll need two different SDKs. But this isn't as easy as it sounds.

By 
Faisal Pathan user avatar
Faisal Pathan
·
Feb. 22, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
112.6K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we’ll learn how we can switch between the versions of the .NET Core SDK as per our needs.

If you have worked on one project that used .NET Core version 2.1 and then you installed .NET Core 3.0 Preview, you will get an SDK error while trying to run your .NET Core 2.1 project. This is because your current SDK version has changed to 3.0

A big advantage of .NET Core is that it installs .NET Core SDKs separately, so the new SDK does not affect the previously installed SDK. You can see all the installed SDKs under "C:\Program Files\dotnet\sdk".

Switching Between .NET Core SDK Versions

First, we are going to see how we can view our current SDK version on the machine. By default, it will be the latest installed version (the SDK you installed at last).

To view your current SDK version, follow the below steps.

Open the command prompt and type the below command.

dotnet --version 

Switching Between .NET Core SDK Versions

To view all installed SDKs, follow the below steps.

Open the command prompt and execute the following command: dotnet --info. This will show the list of all available SDKs on your system.    

Switching Between .NET Core SDK Versions

Checking the Version of Your .NET Core Project

Open your project's source folder and, in the address bar, type "cmd" and press Enter. It will open the command prompt with the project path. Switching Between .NET Core SDK Versions

Execute the following command:  dotnet --version.Switching Between .NET Core SDK VersionsIt will display your project's current SDK version,i.e., 2.1.503 in our case. 

Now, we are going to change this version to Core 3.0. For that, type the below command and press Enter.

dotnet new globaljson --sdk-version 3.0.100-preview-010184 --force 

Switching Between .NET Core SDK Versions 

Switching Between .NET Core SDK Versions

It will create a "global.json" file which is stored in the folder of the current version of your project's SDK. 

{  
  "sdk": {  
    "version": "3.0.100-preview-010184"  
  }  
}

To create the "global.json" file in the current directory folder, you need to fire this command:  

dotnet new globaljson 

This will create a "global.json" file and, by default, it is set to the latest version.

Summary

Here, we have changed the current SDK version of our project and learned how we can view, upgrade, or downgrade the SDK. It's very easy to control the SDK version in .NET Core. Feel free to leave feedback/comment/questions related to this article in the comments section. 

Software development kit .NET

Opinions expressed by DZone contributors are their own.

Related

  • Zero to AI Hero, Part 2: Understanding Plugins in Semantic Kernel, A Deep Dive With Examples
  • Publishing Flutter Packages to JFrog Artifactory
  • Feature Flags in .NET 8 and Azure
  • Implementing CRUD Operations With NLP Using Microsoft.Extensions.AI

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!