简体   繁体   中英

How to restore an ASP.NET Core project with Ubuntu

Recently, I created an asp.net core project using Visual Studio Code on Windows and pushed it to GitHub. When I cloned the repo from GitHub and attempted to do a dotnet restore on the project on Ubuntu, an error message stating there was no project.json file was returned. Can anyone point me to a resource that will show me how to properly restore a .net core project from a Linux machine? Thanks!

So it seems like on each of your machines you are running different versions of the .net core SDK.

A big caveat with what you are trying to do. Are you trying to use Project Rider from Jetbrains on Linux? This only works with project.json (As of the time of this post) so be wary of that.

Now there are two ways to do this. If you are wanting the very latest on Linux and don't care about using Rider, then you can go here : https://github.com/dotnet/core/blob/master/release-notes/download-archive.md and download the latest release for both Linux and Windows, install on both and you should be good to go.

If you do care about using Rider or you aren't ready to be strapped in for the wild ride of the latest release. Then you can do the following.

Find what version of the SDK you have on linux by typing into a terminal the following :

dotnet --version

This will spit out what version you have on linux. Go here and download the same version for windows and install it on your windows machine ( https://github.com/dotnet/core/blob/master/release-notes/download-archive.md ).

Now BEFORE you create a project, create a solution folder and create a file in it called global.json. Inside that put the following :

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

Where the SDK version matches what you got from your linux terminal. Now create a folder for your project inside the solution folder. Run "dotnet new -t web" or a similar command to create your project. It will inspect the SDK version of the global.json and create a project with the tooling that matches. You should then be able to shift this project around any machine that has the same SDK installed, even if it also has the latest SDK's also.

If you do not create the global.json, it defaults to the latest version (Atleast on Windows).

Read a bit more about it here : http://dotnetcoretutorials.com/2017/02/17/developing-two-versions-net-core-sdk-side-side/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM