Skip to content

Commit 05a44fe

Browse files
committed
Address some rough edges in service reference feature
- #11393 - avoid NU1702 warnings - move defaults for `$(OpenApiGenerateDocuments)` and `$(OpenApiGenerateDocumentsOnBuild)` later, into .targets - do not generate documents for .NET Core 2.0 and earlier TFMs (feature is not supported there) - add `Inputs` and `Outputs` to the `GenerateOpenApiDocuments` target, reducing redundant builds nit: correct Microsoft.Extensions.ApiDescription.Server package version when building locally
1 parent 1defaa5 commit 05a44fe

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

src/Mvc/Extensions.ApiDescription.Client/src/build/Microsoft.Extensions.ApiDescription.Client.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
@(OpenApiProjectReference) items.
2626
-->
2727
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)">
28-
<NoWarn>NU1702</NoWarn>
28+
<GlobalPropertiesToRemove>TargetFramework</GlobalPropertiesToRemove>
2929
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
30+
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
3031
</ProjectReference>
3132
<ProjectReference Update="@(OpenApiProjectReference)">
3233
<OpenApiReference>true</OpenApiReference>

src/Mvc/Extensions.ApiDescription.Server/src/Microsoft.Extensions.ApiDescription.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageId>$(MSBuildProjectName)</PackageId>
1313
<PackageTags>MSBuild;Swagger;Open API;code generation;Web API</PackageTags>
1414
<IsShippingPackage>true</IsShippingPackage>
15-
<PackageVersion>$(ExperimentalPackageVersion)</PackageVersion>
15+
<VersionPrefix>$(ExperimentalVersionPrefix)</VersionPrefix>
1616
<DevelopmentDependency>true</DevelopmentDependency>
1717
</PropertyGroup>
1818

src/Mvc/Extensions.ApiDescription.Server/src/build/Microsoft.Extensions.ApiDescription.Server.props

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
Options added to the Open API document generation tool ('dotnet-getdocument') command line. Available options
99
control console output: 'no-color', 'prefix-output' and 'verbose'. All require a double-dash prefix.
1010
-->
11-
<OpenApiGenerateDocumentsOptions Condition=" '$(OpenApiGenerateDocumentsOptions)' == '' "></OpenApiGenerateDocumentsOptions>
11+
<OpenApiGenerateDocumentsOptions Condition=" '$(OpenApiGenerateDocumentsOptions)' == '' " />
1212

1313
<!--
14-
If 'true' (the default), enable generation of Open API documents. Otherwise, this feature is completely disabled.
15-
This controls whether the 'OpenApiGenerateDocuments' project capability is visible, enables / disables the
16-
'GenerateOpenApiDocuments' target and provides the $(OpenApiGenerateDocumentsOnBuild) default.
14+
If 'true' (the default when targeting .NET Framework or .NET Core 2.1 and later), enable generation of Open API
15+
documents. Otherwise, this feature is completely disabled. This controls whether the 'OpenApiGenerateDocuments'
16+
project capability is visible, enables / disables the 'GenerateOpenApiDocuments' target and provides the
17+
$(OpenApiGenerateDocumentsOnBuild) default.
1718
-->
18-
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' ">true</OpenApiGenerateDocuments>
19+
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' " />
1920

2021
<!--
2122
If 'true' (the default if $(OpenApiGenerateDocuments) is 'true'), will generate Open API documents after every
2223
build. Set to 'false' when targets are invoked from the command line or tied to another target.
2324
-->
24-
<OpenApiGenerateDocumentsOnBuild
25-
Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == '' ">$(OpenApiGenerateDocuments)</OpenApiGenerateDocumentsOnBuild>
25+
<OpenApiGenerateDocumentsOnBuild Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == '' " />
2626

2727
<!--
2828
Where to place Open API documents generated from the application. Value is interpreted relative to the project

src/Mvc/Extensions.ApiDescription.Server/src/build/Microsoft.Extensions.ApiDescription.Server.targets

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no"?>
22
<Project>
3+
<PropertyGroup Condition=" '$(OpenApiGenerateDocuments)' == '' ">
4+
<OpenApiGenerateDocuments
5+
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' &lt; '2.1' ">false</OpenApiGenerateDocuments>
6+
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' ">true</OpenApiGenerateDocuments>
7+
</PropertyGroup>
38
<PropertyGroup>
49
<_OpenApiDocumentsCache>$(BaseIntermediateOutputPath)$(MSBuildProjectName).OpenApiFiles.cache</_OpenApiDocumentsCache>
10+
<OpenApiGenerateDocumentsOnBuild
11+
Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == '' ">$(OpenApiGenerateDocuments)</OpenApiGenerateDocumentsOnBuild>
512
</PropertyGroup>
13+
614
<ItemGroup Condition=" '$(OpenApiGenerateDocuments)' == 'true' ">
715
<ProjectCapability Include="OpenApiGenerateDocuments" />
816
</ItemGroup>
@@ -13,7 +21,10 @@
1321
</ReadLinesFromFile>
1422
</Target>
1523

16-
<Target Name="GenerateOpenApiDocuments" Condition=" '$(OpenApiGenerateDocuments)' == 'true' ">
24+
<Target Name="GenerateOpenApiDocuments"
25+
Condition=" '$(OpenApiGenerateDocuments)' == 'true' "
26+
Inputs="$(TargetPath)"
27+
Outputs="$(_OpenApiDocumentsCache)">
1728
<PropertyGroup>
1829
<_Command>dotnet "$(MSBuildThisFileDirectory)/../tools/dotnet-getdocument.dll" --assembly "$(TargetPath)"</_Command>
1930
<_Command>$(_Command) --file-list "$(_OpenApiDocumentsCache)" --framework "$(TargetFrameworkMoniker)"</_Command>

src/Mvc/Extensions.ApiDescription.Server/src/buildMultiTargeting/Microsoft.Extensions.ApiDescription.Server.targets

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no"?>
22
<Project>
3+
<PropertyGroup>
4+
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' ">true</OpenApiGenerateDocuments>
5+
<OpenApiGenerateDocumentsOnBuild
6+
Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == '' ">$(OpenApiGenerateDocuments)</OpenApiGenerateDocumentsOnBuild>
7+
</PropertyGroup>
8+
39
<ItemGroup Condition=" '$(OpenApiGenerateDocuments)' == 'true' ">
410
<ProjectCapability Include="OpenApiGenerateDocuments" />
511
</ItemGroup>
@@ -17,11 +23,27 @@
1723
DependsOnTargets="GenerateOpenApiDocuments" />
1824

1925
<Target Name="OpenApiGetDocuments" Returns="@(_OpenApiProjectDocuments)">
26+
<ItemGroup>
27+
<_Temporary Remove="@(_Temporary)" />
28+
<_Temporary Include="$(TargetFrameworks)" Exclude="netcoreapp1.0;netcoreapp1.1;netcoreapp2.0" />
29+
</ItemGroup>
30+
<PropertyGroup>
31+
<_Temporary>@(_Temporary)</_Temporary>
32+
</PropertyGroup>
33+
2034
<MSBuild Projects="$(MSBuildProjectFile)"
2135
Targets="OpenApiGetDocuments"
22-
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0])"
36+
Condition=" '$(_Temporary)' != '' "
37+
Properties="TargetFramework=$(_Temporary.Split(';')[0])"
2338
RemoveProperties="RuntimeIdentifier">
2439
<Output TaskParameter="TargetOutputs" ItemName="_OpenApiProjectDocuments" />
2540
</MSBuild>
41+
42+
<ItemGroup>
43+
<_Temporary Remove="@(_Temporary)" />
44+
</ItemGroup>
45+
<PropertyGroup>
46+
<_Temporary />
47+
</PropertyGroup>
2648
</Target>
2749
</Project>

0 commit comments

Comments
 (0)