Migrating a .NET Core project to the .csproj format
The dotnet 1.0.1
tooling includes a tool called dotnet-migrate
.
Just run:
$ dotnet migrate
More info here at the Microsoft Docs here.
But it dint work for me. This is what I got:
$ dotnet migrate
No executable found matching command "dotnet-migrate"
I tried re-updating dotnet by downloading the latest setup (v1.0.1
) from here, but it din't help either.
That's when I happened to run dotnet --info
from the project directory:
$ dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)
Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64
Notice the version? It's still using the old tooling.
However running it from ~
showed this as I'd expect:
$ dotnet --info
.NET Command Line Tools (1.0.1)
Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64
Base Path: /usr/local/share/dotnet/sdk/1.0.1
That's when I realized the culprit. The project had a global.json
file with the old SDK version in it.
All I had to do was update the SDK version in it to 1.0.1
:
{
"projects": [ "." ],
"sdk": {
"version": "1.0.1"
}
}
And everything worked as expected.
The global.json
file is used to select an SDK version and is useful because:
- You can be sure that everyone in your team uses the same SDK version
- You can have multiple SDK versions installed and use different SDKs for different projects if need be.