|
| 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> |
0 commit comments