Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a project.json to a csproj without using Visual Studio

As of preview3 dotnet new produces a csproj, and both dotnet restore and dotnet build fail against a project.json and/or an xproj.

For instance, running dotnet restore against a directory that has both a project.json and an xproj gives this error.

...xproj(7,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.0-preview3-004056\Extensions\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Further, running it against a directory that has only a project.json gives this error.

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

Without using Visual Studio, how can we convert an existing project.json and/or xproj to a csproj?

like image 761
Shaun Luttin Avatar asked Nov 20 '16 06:11

Shaun Luttin


People also ask

What is a csproj file?

What is a CSProj file? Files with CSPROJ extension represent a C# project file that contains the list of files included in a project along with the references to system assemblies. When a new project is initiated in Microsoft VIiual Studio, you get one . csproj file along with the main solution (. sln) file.

How do I open project json in ASP.NET Core?

Right click your project and select "Edit ProjectName. csproj" to view the file.

What can you do using the project JSON file for an ASP NET application?

json file means to an ASP.NET Core project: Let's explore project. json file's structure and learn how to use it effectively. Apart from the default debug and release build configurations built into the runtime, we can specify new build configurations or override debug and release in the project.

How do I convert Csproj to new format?

The way to do it is as follows (for WebJobs and class library type projects): Right click the packages. config and click the option to migrate to the new PackageReferences style. This will move all the package references in your csproj file and get rid of the packages.


1 Answers

There is a dotnet migrate command.

The dotnet migrate command will migrate a valid Preview 2 project.json based project to a valid Preview 3 csproj project.

We can find detailed help on this command by running dotnet migrate -h (even though dotnet -h does not list the command).

like image 91
Shaun Luttin Avatar answered Sep 20 '22 15:09

Shaun Luttin