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

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

问题描述

我正在尝试使用 swagger-codegen 为 .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/en-us/dotnet/core/migration/#dotnet-migrate

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

答案是在包含 .xproj 的目录中运行 dotnet migrate.这将创建一个 .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天全站免登陆