Skip to content

Commit

Permalink
Added support for .NET Core 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoSuter committed Aug 15, 2017
1 parent df4f8a8 commit 1071359
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion build/01_Npm_Build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ dotnet restore "%~dp0/../src/NSwag.ConsoleCore" --no-cache
dotnet build "%~dp0/../src/NSwag.ConsoleCore"
dotnet publish "%~dp0/../src/NSwag.ConsoleCore" -c release -f "netcoreapp1.0"
dotnet publish "%~dp0/../src/NSwag.ConsoleCore" -c release -f "netcoreapp1.1"
dotnet publish "%~dp0/../src/NSwag.ConsoleCore" -c release -f "netcoreapp2.0"

xcopy "%~dp0/../src/NSwag.ConsoleCore/bin/release/netcoreapp1.0/publish" "%~dp0/../src/NSwag.Npm/bin/binaries/netcoreapp1.0" /E /I /y
xcopy "%~dp0/../src/NSwag.ConsoleCore/bin/release/netcoreapp1.1/publish" "%~dp0/../src/NSwag.Npm/bin/binaries/netcoreapp1.1" /E /I /y
xcopy "%~dp0/../src/NSwag.ConsoleCore/bin/release/netcoreapp1.1/publish" "%~dp0/../src/NSwag.Npm/bin/binaries/netcoreapp1.1" /E /I /y
xcopy "%~dp0/../src/NSwag.ConsoleCore/bin/release/netcoreapp2.0/publish" "%~dp0/../src/NSwag.Npm/bin/binaries/netcoreapp2.0" /E /I /y
2 changes: 1 addition & 1 deletion src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;netcoreapp1.1</TargetFrameworks>
<TargetFrameworks>netcoreapp1.0;netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<Description>NSwag: The Swagger API toolchain for .NET and TypeScript</Description>
<Version>11.3.5</Version>
Expand Down
15 changes: 12 additions & 3 deletions src/NSwag.Npm/bin/nswag.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ if (process.env["windir"]) {
}

var c = require('child_process');
if (hasFullDotNet && args.indexOf("--core") == -1 && args.indexOf("--core 1.0") == -1 && args.indexOf("--core 1.1") == -1) {
if (hasFullDotNet &&
args.indexOf("--core") == -1 &&
args.indexOf("--core 1.0") == -1 &&
args.indexOf("--core 1.1") == -1 &&
args.indexOf("--core 2.0") == -1) {
// Run full .NET version
if (args.indexOf("--x86") != -1) {
var cmd = '"' + __dirname + '/binaries/full/nswag.x86.exe" ' + args;
Expand All @@ -34,12 +38,15 @@ if (hasFullDotNet && args.indexOf("--core") == -1 && args.indexOf("--core 1.0")
// Run .NET Core version
var core10cmd = 'dotnet "' + __dirname + '/binaries/netcoreapp1.0/dotnet-nswag.dll" ' + args;
var core11cmd = 'dotnet "' + __dirname + '/binaries/netcoreapp1.1/dotnet-nswag.dll" ' + args;

var core20cmd = 'dotnet "' + __dirname + '/binaries/netcoreapp2.0/dotnet-nswag.dll" ' + args;

var cmd = "dotnet";
if (args.indexOf("--core 1.0") != -1)
c.execSync(core10cmd, { stdio: [0, 1, 2] });
else if (args.indexOf("--core 1.1") != -1)
c.execSync(core11cmd, { stdio: [0, 1, 2] });
else if (args.indexOf("--core 2.0") != -1)
c.execSync(core20cmd, { stdio: [0, 1, 2] });
else {
c.exec(cmd, (error, stdout, stderr) => {
if (!error) {
Expand All @@ -48,7 +55,9 @@ if (hasFullDotNet && args.indexOf("--core") == -1 && args.indexOf("--core 1.0")
c.execSync(core10cmd, { stdio: [0, 1, 2] });
else if (dotnetVersion.indexOf("Version : 1.1.0") !== -1)
c.execSync(core11cmd, { stdio: [0, 1, 2] });
} else
else if (dotnetVersion.indexOf("Version : 2.0.0") !== -1)
c.execSync(core20cmd, { stdio: [0, 1, 2] });
} else // default:
c.execSync(core11cmd, { stdio: [0, 1, 2] });
});
}
Expand Down

5 comments on commit 1071359

@stumpyfr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the release will integrate the support of 2.0? last step to update all my CI to netcore 2.0 :)

Thanks for your work!

@RicoSuter
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment I cannot build for .NET Core 2.0 (and also AppVeyor has problems with it). Can you build the solution with this commit?

@stumpyfr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tried and 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(112,5): error : The current .NET SDK does not support targeting .NET Core 2.0. Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0.

no idea why, I am investigating

@RicoSuter
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - locally. But I have to integrate this in the CI (AppVeyor). Do you know how to install .NET Core 2.0 via command line (powershell) so that we can install it before building on the CI system?

@stumpyfr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.