Swagger-codegen:为 .NET Core 构建 Pet Store 示例时出错

Swagger-codegen: error building Pet Store example for .NET Core

我正在尝试 swagger-codegen 为 .NET Core 生成 Pet Store 示例。当我尝试构建项目时,我看到了这个错误:

/home/username/test/src/IO.Swagger/IO.Swagger.xproj(7,5): error MSB4019:
The imported project "/usr/share/dotnet/sdk/1.0.4/Microsoft/VisualStudio/v14.0/
DotNet/Microsoft.DotNet.Props"
was not found. Confirm that the path in the <Import> declaration is correct,
and that the file exists on disk.

我 运行 的确切步骤是:

$ java -jar swagger-codegen-cli.jar generate -i 
     http://petstore.swagger.io/v2/swagger.json -l aspnetcore -o test/
$ cd test/
$ chmod +x build.sh
$ ./build.sh

版本:

$ dotnet --version
1.0.4
$ java -jar swagger-codegen-cli.jar version
2.2.3

生成的.NET core项目好像和我使用的.NET core版本不兼容。我怎样才能轻松更新生成的项目以使其正常工作?

看完这篇我找到了答案:https://docs.microsoft.com/en-us/dotnet/core/migration/#dotnet-migrate

答案是 运行 dotnet migrate 在包含 .xproj 的目录中。这将创建一个 .csproj,可以在没有错误的情况下构建它。