Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't run asp.net core project generated using yeoman generator

I've created a Asp.Net Core project using Yeoman Generator using yo aspnet but the project can't be run.

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

enter image description here

like image 616
20B2 Avatar asked Dec 05 '16 10:12

20B2


3 Answers

Please do the following thing:

npm uninstall -g generator-aspnet
npm install -g yo bower # (optional)
npm install -g [email protected]

check whether you have installed the latest version of SDK, not the LTS one.

Thanks, Steve Smith, Scott Addie, Rick Anderson, Noel Rice, and Shayne Boyer for the kind tutorial.

The tutorial link: https://learn.microsoft.com/en-us/aspnet/core/client-side/yeoman

like image 170
Ahsan Ahmad Avatar answered Oct 30 '22 03:10

Ahsan Ahmad


I've had the same issue. Turned out that Yeoman generator did produce project.json as build config file which was replaced by .csproj file with the release of 1.0.0-preview3-004056.

Obviously, your version of dotnet is preview3 or higher, that's why MSBUILD looks for .csproj file and fails to find it.

In order to migrate from project.json to .csproj you can run:
dotnet migrate

And then you can run:
dotnet restore
dotnet build
dotnet run

Worked out for me just fine.

like image 26
Prostakov Avatar answered Oct 30 '22 03:10

Prostakov


I just had the same problem, after following the links posted by Sender and reading around it is indeed because of the move from project.json back to the XML project file introduced in Preview3, so if you have Preview 3 or later installed you may see this error. dotnet restore will take the latest version by default.

To see which versions of dotnet core you have installed just look in \Program Files\dotnet\sdk

There is actually a very simple work-around (see bottom of page here) which allows you to run multiple versions of core side by side. So in the parent folder above the generated project include a file called global.json with the following contents:

{
  "projects": [ "your-project-name" ],
  "sdk": {
    "version": "1.0.0-preview2-003131"
  }
}

Notes:

  • check your version exists in the sdk folder and adjust as necessary (there is also preview 2 version 3121)
  • Change the projects section to the name of your project generated with yoeman.
like image 24
Rob Bird Avatar answered Oct 30 '22 02:10

Rob Bird