Skip to content

Commit 022f47a

Browse files
committed
Add NSwag.MSBuild.CodeGeneration package
- RicoSuter#1587, RicoSuter#1588
1 parent c397184 commit 022f47a

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

build/01_Build.bat

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ xcopy "%~dp0/../src/NSwag.ConsoleCore/bin/release/netcoreapp2.1/publish" "%~dp0/
2424

2525
REM Package nuspecs
2626
"%~dp0/nuget.exe" pack "%~dp0/../src/NSwag.MSBuild/NSwag.MSBuild.nuspec" || goto :error
27+
"%~dp0/nuget.exe" pack "%~dp0/../src/NSwag.MSBuild/NSwag.MSBuild.CodeGeneration.nuspec" || goto :error
2728
"%~dp0/nuget.exe" pack "%~dp0/../src/NSwagStudio.Chocolatey/NSwagStudio.nuspec" || goto :error
2829

2930
goto :EOF
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
3+
<metadata>
4+
<id>NSwag.MSBuild.CodeGeneration</id>
5+
<version>11.20.1</version>
6+
<authors>Rico Suter</authors>
7+
<owners>Rico Suter</owners>
8+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
9+
<licenseUrl>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</licenseUrl>
10+
<projectUrl>https://github.com/NSwag/NSwag</projectUrl>
11+
<iconUrl>https://raw.githubusercontent.com/NSwag/NSwag/master/assets/NuGetIcon.png</iconUrl>
12+
<description>NSwag: The Swagger API toolchain for .NET and TypeScript</description>
13+
<tags>Swagger Documentation WebApi AspNet TypeScript CodeGen</tags>
14+
<developmentDependency>true</developmentDependency>
15+
<dependencies>
16+
<dependency id="Microsoft.Extensions.ApiDescription.Design" Version="2.2.0-preview3-t007163513" />
17+
<dependency id="NSwag.MSBuild" version="11.20.1" />
18+
</dependencies>
19+
<references />
20+
</metadata>
21+
<files>
22+
<file src="NSwag.MSBuild.CodeGeneration.targets" target="build" />
23+
</files>
24+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project>
3+
<PropertyGroup>
4+
<_NSwagcommand>$(NSwagExe)</_NSwagcommand>
5+
<_NSwagcommand Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NSwagExe_Core20)</_NSwagcommand>
6+
</PropertyGroup>
7+
8+
<ItemDefinitionGroup>
9+
<CurrentServiceProjectReference>
10+
<GenerateNSwagDocumentOptions />
11+
<Configuration />
12+
<Platform />
13+
</CurrentServiceProjectReference>
14+
<CurrentServiceFileReference>
15+
<GenerateNSwagCSharpOptions />
16+
<GenerateNSwagTypeScriptOptions />
17+
</CurrentServiceFileReference>
18+
</ItemDefinitionGroup>
19+
20+
<!-- ServiceProjectReference support -->
21+
22+
<Target Name="GenerateNSwagDocument">
23+
<ItemGroup>
24+
<!-- @(CurrentServiceProjectReference) item group will never contain more than one item. -->
25+
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
26+
<Command>$(NSwagExe)</Command>
27+
<Command Condition="'%(Platform)' == 'x86'">$(NSwagExe_x86)</Command>
28+
<Command Condition="'%(TargetFramework)' == 'netcoreapp1.0'">$(NSwagExe_Core10)</Command>
29+
<Command Condition="'%(TargetFramework)' == 'netcoreapp1.1'">$(NSwagExe_Core11)</Command>
30+
<Command Condition="'%(TargetFramework)' == 'netcoreapp2.0'">$(NSwagExe_Core20)</Command>
31+
<Command Condition="'%(TargetFramework)' == 'netcoreapp2.1'">$(NSwagExe_Core21)</Command>
32+
<Configuration Condition="'%(Configuration)' == ''">$(Configuration)</Configuration>
33+
<GenerateNSwagDocumentOptions
34+
Condition="'%(GenerateNSwagDocumentOptions)' == ''">$(GenerateNSwagDocumentDefaultOptions)</GenerateNSwagDocumentOptions>
35+
</CurrentServiceProjectReference>
36+
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
37+
<Command>%(Command) aspnetcore2swagger /NoBuild:true /output:%(DocumentPath) /Project:%(FullPath)</Command>
38+
</CurrentServiceProjectReference>
39+
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
40+
<Command>%(Command) /Configuration:%(Configuration) /TargetFramework:%(TargetFramework)</Command>
41+
</CurrentServiceProjectReference>
42+
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
43+
<Command>%(Command) %(GenerateNSwagDocumentOptions)</Command>
44+
</CurrentServiceProjectReference>
45+
</ItemGroup>
46+
47+
<Message Importance="high" Text="%0AGenerateNSwagDocument:" />
48+
<Message Importance="high" Text=" %(CurrentServiceProjectReference.Command)" />
49+
<Exec Command="%(CurrentServiceProjectReference.Command)"
50+
IgnoreExitCode="$([System.IO.File]::Exists('%(DocumentPath)'))" />
51+
</Target>
52+
53+
<!-- ServiceFileReference support for C# -->
54+
55+
<Target Name="GenerateNSwagCSharp">
56+
<ItemGroup>
57+
<!-- @(CurrentServiceFileReference) item group will never contain more than one item. -->
58+
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)">
59+
<Command>$(_NSwagcommand) swagger2csclient /className:%(ClassName) /namespace:%(Namespace)</Command>
60+
<GenerateNSwagCSharpOptions
61+
Condition="'%(GenerateNSwagCSharpOptions)' == ''">$(GenerateNSwagCSharpDefaultOptions)</GenerateNSwagCSharpOptions>
62+
</CurrentServiceFileReference>
63+
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)">
64+
<Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(GenerateNSwagCSharpOptions)</Command>
65+
</CurrentServiceFileReference>
66+
</ItemGroup>
67+
68+
<Message Importance="high" Text="%0AGenerateNSwagCSharp:" />
69+
<Message Importance="high" Text=" %(CurrentServiceFileReference.Command)" />
70+
<Exec Command="%(CurrentServiceFileReference.Command)"
71+
IgnoreExitCode="$([System.IO.File]::Exists('%(OutputPath)'))" />
72+
</Target>
73+
74+
<!-- ServiceFileReference support for TypeScript -->
75+
76+
<Target Name="GenerateNSwagTypeScript">
77+
<ItemGroup>
78+
<!-- @(CurrentServiceFileReference) item group will never contain more than one item. -->
79+
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)">
80+
<Command>$(_NSwagcommand) swagger2tsclient /className:%(ClassName) /namespace:%(Namespace)</Command>
81+
<GenerateNSwagTypeScriptOptions
82+
Condition="'%(GenerateNSwagTypeScriptOptions)' == ''">$(GenerateNSwagTypeScriptDefaultOptions)</GenerateNSwagTypeScriptOptions>
83+
</CurrentServiceFileReference>
84+
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)">
85+
<Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(GenerateNSwagTypeScriptOptions)</Command>
86+
</CurrentServiceFileReference>
87+
</ItemGroup>
88+
89+
<Message Importance="high" Text="%0AGenerateNSwagTypeScript:" />
90+
<Message Importance="high" Text=" %(CurrentServiceFileReference.Command)" />
91+
<Exec Command="%(CurrentServiceFileReference.Command)"
92+
IgnoreExitCode="$([System.IO.File]::Exists('%(OutputPath)'))" />
93+
</Target>
94+
</Project>
1.59 MB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rmdir Output /Q /S nonemptydir
2+
mkdir Output
3+
nuget pack NSwag.MSBuild.CodeGeneration.nuspec -OutputDirectory Output

0 commit comments

Comments
 (0)