Reputation: 12441
I have downloaded and installed the latest .Net Core from https://www.microsoft.com/net/download/core, but after the installation I opened up a cmd prompt and > dotnet --version
still shows 1.0.0-preview2-003131
Could someone explain what I'm missing here please?
Upvotes: 0
Views: 1584
Reputation: 1593
The original answer was highly targeted at the understanding that the OP had with context at the time (2016). Core has come a long way in the last few years so if you are coming at this now, you might not even know what a global.json and SDK pinning is because it is no longer part of the default template when creating a new project.
Essentially, the CLI will use the highest installed version of .Net Core by default. However, should you choose to, you can dictate a specific version of .Net Core to be used by all apps in nested folders by creating a global.json and setting a specific SDK version. If you do this, you'll get errors when the incorrect version is installed.
The Core team is pretty good about not causing any breaking changes and as described above have opted to remove pinning by default. This actually recently caused some issues for some people because they had not pinned to the version they had built their app against. I personally prefer to pin to the version I'm building against and update it explicitly.
To add extra confusion, the SDK versions don't line up with the version numbers of the .Net Core releases so you really have to "just know" which version to use for what.
For anyone coming to this answer now, the problem that the OP had here was that he didn't realize the global.json was pinning his version nor why the version was so different than the .Net Core version.
The command line is context specific. My guess is you are running from a project that has a global.json in a parent folder that references an older version.
Old Global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
Change your global.json to:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-1-003177"
}
}
This change will make the dotnet cli respect the new version in your projects so you can choose when to upgrade your projects. This is how you can have multiple versions of dotnet on your machine and not have to update every one of your projects at once.
[Edit - SDK version confusion]
Just to note, the SDK version you have installed is indeed the 1.1 version of the SDK. The installer indicates the new version of the SDK for 1.1. I've captured a screenshot below.
Upvotes: 2