Konrad Viltersten
Konrad Viltersten

Reputation: 39108

Can't run .Net Core based on project.json after VS 2017 installation

I've been working on a software for a while and always executed it using dotnet run. Today, I decided to install VS 2017 and after that (still not entirely sure if it's the root cause, though), I can't run my software anymore.

The pre-existing project is nowhere near the project I opened with VS 2017 so the only collision I suspect might be due to the Core version being changed. To be sure, I re-ran the installation from the page, the latest version.

dotnet --version
1.0.0-preview4-004233

I notice that when I execute dotnet new, the directory get a xxx.csproj file and not project.json and I've read somewhere that MS is going to drop support for it.

What can I do to get the pre-existing project running again? I'm kind of stuck in the middle of the whole thing and googling gave me precisely nothing. Apparently, I'm the first dude to do this stupid upgrade (if it's because of that to begin with).

Upvotes: 5

Views: 513

Answers (1)

Shaun Luttin
Shaun Luttin

Reputation: 141512

What can I do to get the pre-existing project running again?

Add a global.json to your project or solution's root directory, with an SDK property that points at the previous SDK. For example:

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

View the SDK versions that you have installed like this:

PS> dir 'C:\Program Files\dotnet\sdk\' -name

1.0.0-preview2-003131               
1.0.0-preview2-003133               
1.0.0-preview2-003156               
1.0.0-preview2-1-003177             
1.0.0-preview3-004056               

Anything with preview2 will use project.json, anything with preview3 (or above) will use xxx.csproj.

See also: Announcing .NET Core Tools MSBuild “alpha” > Side by side install.

Upvotes: 5

Related Questions