在不使用 Visual Studio 的情况下将 project.json 转换为 csproj

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

从预览版 3 开始,dotnet new 生成一个 csproj,并且 dotnet restoredotnet build 都因 project.json and/or 和 xproj 而失败。

例如,运行 dotnet restore 针对同时具有 project.json 和 xproj 的目录会给出此错误。

...xproj(7,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk.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.

此外,运行 它针对只有 project.json 的目录会给出此错误。

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

不使用 Visual Studio,我们如何将现有的 project.json and/or xproj 转换为 csproj?

有个dotnet migrate command.

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

我们可以通过 运行 dotnet migrate -h 找到有关此命令的详细帮助(即使 dotnet -h 没有列出该命令)。