-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NSwag.MSBuild.CodeGeneration package (#1659)
* Add NSwag.MSBuild.CodeGeneration package - #1587, #1588 * Correct typo in 01_Build.bat * Use Microsoft.Extensions.ApiDescription.Design version from https://dotnet.myget.org - see https://dotnet.myget.org/feed/aspnetcore-dev/package/nuget/Microsoft.Extensions.ApiDescription.Design - version ranges don't work with preview releases, see NuGet/Home#912 - users need the [aspnetcore-dev](https://dotnet.myget.org/gallery/aspnetcore-dev) feed to get this package * Revert part of "Add NSwag.MSBuild.CodeGeneration package" - remove unnecessary files added in commit cf65d85. * Add `netcoreapp2.2` support in NSwag.MSBuild.CodeGeneration.targets * nit: add NSwag.MSBuild.CodeGeneration files to solution - VS also automatically corrected the NSwag.AssemblyLoader.Tests project type in the solution * Update version * Update Microsoft.Extensions.ApiDescription.Design package version - this preview package is available on NuGet.org
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/NSwag.MSBuild.CodeGeneration/NSwag.MSBuild.CodeGeneration.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata> | ||
<id>NSwag.MSBuild.CodeGeneration</id> | ||
<version>12.0.0</version> | ||
<authors>Rico Suter</authors> | ||
<owners>Rico Suter</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<licenseUrl>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</licenseUrl> | ||
<projectUrl>https://github.com/NSwag/NSwag</projectUrl> | ||
<iconUrl>https://raw.githubusercontent.com/NSwag/NSwag/master/assets/NuGetIcon.png</iconUrl> | ||
<description>NSwag: The Swagger API toolchain for .NET and TypeScript</description> | ||
<tags>Swagger Documentation WebApi AspNet TypeScript CodeGen</tags> | ||
<developmentDependency>true</developmentDependency> | ||
<dependencies> | ||
<dependency id="Microsoft.Extensions.ApiDescription.Design" version="0.1.0-preview1-10773" /> | ||
<dependency id="NSwag.MSBuild" version="12.0.0" /> | ||
</dependencies> | ||
<references /> | ||
</metadata> | ||
<files> | ||
<file src="NSwag.MSBuild.CodeGeneration.targets" target="build" /> | ||
</files> | ||
</package> |
95 changes: 95 additions & 0 deletions
95
src/NSwag.MSBuild.CodeGeneration/NSwag.MSBuild.CodeGeneration.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project> | ||
<PropertyGroup> | ||
<_NSwagcommand>$(NSwagExe)</_NSwagcommand> | ||
<_NSwagcommand Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NSwagExe_Core20)</_NSwagcommand> | ||
</PropertyGroup> | ||
|
||
<ItemDefinitionGroup> | ||
<CurrentServiceProjectReference> | ||
<GenerateNSwagDocumentOptions /> | ||
<Configuration /> | ||
<Platform /> | ||
</CurrentServiceProjectReference> | ||
<CurrentServiceFileReference> | ||
<GenerateNSwagCSharpOptions /> | ||
<GenerateNSwagTypeScriptOptions /> | ||
</CurrentServiceFileReference> | ||
</ItemDefinitionGroup> | ||
|
||
<!-- ServiceProjectReference support --> | ||
|
||
<Target Name="GenerateNSwagDocument"> | ||
<ItemGroup> | ||
<!-- @(CurrentServiceProjectReference) item group will never contain more than one item. --> | ||
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)"> | ||
<Command>$(NSwagExe)</Command> | ||
<Command Condition="'%(Platform)' == 'x86'">$(NSwagExe_x86)</Command> | ||
<Command Condition="'%(TargetFramework)' == 'netcoreapp1.0'">$(NSwagExe_Core10)</Command> | ||
<Command Condition="'%(TargetFramework)' == 'netcoreapp1.1'">$(NSwagExe_Core11)</Command> | ||
<Command Condition="'%(TargetFramework)' == 'netcoreapp2.0'">$(NSwagExe_Core20)</Command> | ||
<Command Condition="'%(TargetFramework)' == 'netcoreapp2.1'">$(NSwagExe_Core21)</Command> | ||
<Command Condition="'%(TargetFramework)' == 'netcoreapp2.2'">$(NSwagExe_Core21)</Command> | ||
<Configuration Condition="'%(Configuration)' == ''">$(Configuration)</Configuration> | ||
<GenerateNSwagDocumentOptions | ||
Condition="'%(GenerateNSwagDocumentOptions)' == ''">$(GenerateNSwagDocumentDefaultOptions)</GenerateNSwagDocumentOptions> | ||
</CurrentServiceProjectReference> | ||
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)"> | ||
<Command>%(Command) aspnetcore2swagger /NoBuild:true /output:%(DocumentPath) /Project:%(FullPath)</Command> | ||
</CurrentServiceProjectReference> | ||
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)"> | ||
<Command>%(Command) /Configuration:%(Configuration) /TargetFramework:%(TargetFramework)</Command> | ||
</CurrentServiceProjectReference> | ||
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)"> | ||
<Command>%(Command) %(GenerateNSwagDocumentOptions)</Command> | ||
</CurrentServiceProjectReference> | ||
</ItemGroup> | ||
|
||
<Message Importance="high" Text="%0AGenerateNSwagDocument:" /> | ||
<Message Importance="high" Text=" %(CurrentServiceProjectReference.Command)" /> | ||
<Exec Command="%(CurrentServiceProjectReference.Command)" | ||
IgnoreExitCode="$([System.IO.File]::Exists('%(DocumentPath)'))" /> | ||
</Target> | ||
|
||
<!-- ServiceFileReference support for C# --> | ||
|
||
<Target Name="GenerateNSwagCSharp"> | ||
<ItemGroup> | ||
<!-- @(CurrentServiceFileReference) item group will never contain more than one item. --> | ||
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)"> | ||
<Command>$(_NSwagcommand) swagger2csclient /className:%(ClassName) /namespace:%(Namespace)</Command> | ||
<GenerateNSwagCSharpOptions | ||
Condition="'%(GenerateNSwagCSharpOptions)' == ''">$(GenerateNSwagCSharpDefaultOptions)</GenerateNSwagCSharpOptions> | ||
</CurrentServiceFileReference> | ||
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)"> | ||
<Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(GenerateNSwagCSharpOptions)</Command> | ||
</CurrentServiceFileReference> | ||
</ItemGroup> | ||
|
||
<Message Importance="high" Text="%0AGenerateNSwagCSharp:" /> | ||
<Message Importance="high" Text=" %(CurrentServiceFileReference.Command)" /> | ||
<Exec Command="%(CurrentServiceFileReference.Command)" | ||
IgnoreExitCode="$([System.IO.File]::Exists('%(OutputPath)'))" /> | ||
</Target> | ||
|
||
<!-- ServiceFileReference support for TypeScript --> | ||
|
||
<Target Name="GenerateNSwagTypeScript"> | ||
<ItemGroup> | ||
<!-- @(CurrentServiceFileReference) item group will never contain more than one item. --> | ||
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)"> | ||
<Command>$(_NSwagcommand) swagger2tsclient /className:%(ClassName) /namespace:%(Namespace)</Command> | ||
<GenerateNSwagTypeScriptOptions | ||
Condition="'%(GenerateNSwagTypeScriptOptions)' == ''">$(GenerateNSwagTypeScriptDefaultOptions)</GenerateNSwagTypeScriptOptions> | ||
</CurrentServiceFileReference> | ||
<CurrentServiceFileReference Update="@(CurrentServiceFileReference)"> | ||
<Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(GenerateNSwagTypeScriptOptions)</Command> | ||
</CurrentServiceFileReference> | ||
</ItemGroup> | ||
|
||
<Message Importance="high" Text="%0AGenerateNSwagTypeScript:" /> | ||
<Message Importance="high" Text=" %(CurrentServiceFileReference.Command)" /> | ||
<Exec Command="%(CurrentServiceFileReference.Command)" | ||
IgnoreExitCode="$([System.IO.File]::Exists('%(OutputPath)'))" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters