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.
The exact steps I ran were:
$ 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
Versions:
$ dotnet --version
1.0.4
$ java -jar swagger-codegen-cli.jar version
2.2.3
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?
I found an answer after reading this: https://docs.microsoft.com/en-us/dotnet/core/migration/#dotnet-migrate
The answer is to run
dotnet migrate
in the directory containing the.xproj
. This creates a.csproj
which can be built without errors.