Swagger-Codegen:为.NET Core构建Pet Store示例时出错 [英] Swagger-codegen: error building Pet Store example for .NET Core

查看:178
本文介绍了Swagger-Codegen:为.NET Core构建Pet Store示例时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 swagger-codegen 生成的Pet Store示例。 NET核心。当我尝试构建项目时,我看到此错误:

I am trying out swagger-codegen to generate the Pet Store example for .NET Core. When I try to build the project, I see this error:

/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版本不兼容。我怎样才能轻松地更新生成的项目使其起作用?

It looks like the generated .NET core project is not compatible with the version of .NET core I am using. How can I easily update the generated project so it works?

推荐答案

我在阅读以下内容后找到了答案:> https://docs.microsoft.com/zh-CN/dotnet/core/迁移/#dotnet迁移

I found an answer after reading this: https://docs.microsoft.com/en-us/dotnet/core/migration/#dotnet-migrate

答案是在包含以下内容的目录中运行 dotnet migration .xproj 。这样会创建一个 .csproj ,该文件可以无错误构建。

The answer is to run dotnet migrate in the directory containing the .xproj. This creates a .csproj which can be built without errors.

这篇关于Swagger-Codegen:为.NET Core构建Pet Store示例时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆