Fix a typo and address remaining service reference TODO items (#13364)

- #4923
- typo caused problems when cleaning files
- add `%(OpenApiProjectReference.GlobalPropertiesToRemove)` metadata
  - stop removing `$(Configuration)` or `$(Platform)` global properties
- address timing issues cropping up occasionally in builds using service ref features
  - avoid `AfterTargets="Build"`; referencing projects sometimes continue while post-build work is done
    - instead use `BeforeTargets="Build"` since that's a no-op target wrapping up a build
- set only properties in buildMultiTargeting\Microsoft.Extensions.ApiDescription.Server.targets
  - items not evaluated early enough to reference in all cases
- rename Microsoft.Extensions.ApiDescription.Client tasks
- remove net461 task assembly
This commit is contained in:
Doug Bunting 2019-08-23 15:59:58 -07:00 committed by GitHub
parent e89a0519b9
commit 8417429b9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 34 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Build.Framework; using Microsoft.Build.Framework;
@ -9,7 +9,7 @@ namespace Microsoft.Extensions.ApiDescription.Client
/// <summary> /// <summary>
/// Restore <see cref="ITaskItem"/>s from given property value. /// Restore <see cref="ITaskItem"/>s from given property value.
/// </summary> /// </summary>
public class GetCurrentItems : Task public class GetCurrentOpenApiReference : Task
{ {
/// <summary> /// <summary>
/// The property value to deserialize. /// The property value to deserialize.

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -13,7 +13,7 @@ namespace Microsoft.Extensions.ApiDescription.Client
/// Adds or corrects ClassName, FirstForGenerator, Namespace, and OutputPath metadata in OpenApiReference items. /// Adds or corrects ClassName, FirstForGenerator, Namespace, and OutputPath metadata in OpenApiReference items.
/// Also stores final metadata as SerializedMetadata. /// Also stores final metadata as SerializedMetadata.
/// </summary> /// </summary>
public class GetFileReferenceMetadata : Task public class GetOpenApiReferenceMetadata : Task
{ {
private const string TypeScriptLanguageName = "TypeScript"; private const string TypeScriptLanguageName = "TypeScript";

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<!-- Do not complain about lack of lib folder. --> <!-- Do not complain about lack of lib folder. -->
<NoPackageAnalysis>true</NoPackageAnalysis> <NoPackageAnalysis>true</NoPackageAnalysis>
@ -9,7 +9,7 @@
<PackageId>$(MSBuildProjectName)</PackageId> <PackageId>$(MSBuildProjectName)</PackageId>
<PackageTags>Build Tasks;MSBuild;Swagger;OpenAPI;code generation;Web API client;service reference</PackageTags> <PackageTags>Build Tasks;MSBuild;Swagger;OpenAPI;code generation;Web API client;service reference</PackageTags>
<IsShippingPackage>true</IsShippingPackage> <IsShippingPackage>true</IsShippingPackage>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<DevelopmentDependency>true</DevelopmentDependency> <DevelopmentDependency>true</DevelopmentDependency>
<HasReferenceAssembly>false</HasReferenceAssembly> <HasReferenceAssembly>false</HasReferenceAssembly>
</PropertyGroup> </PropertyGroup>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.8"> <metadata minClientVersion="2.8">
$CommonMetadataElements$ $CommonMetadataElements$
@ -7,7 +7,6 @@
<files> <files>
<file src="build\*" target="build" /> <file src="build\*" target="build" />
<file src="buildMultiTargeting\*" target="buildMultiTargeting" /> <file src="buildMultiTargeting\*" target="buildMultiTargeting" />
<file src="$baseOutputPath$\$configuration$\net461\Microsoft.Extensions.ApiDescription.Client.*" target="tasks\net461" />
<file src="$baseOutputPath$\$configuration$\netstandard2.0\Microsoft.Extensions.ApiDescription.Client.*" target="tasks\netstandard2.0" /> <file src="$baseOutputPath$\$configuration$\netstandard2.0\Microsoft.Extensions.ApiDescription.Client.*" target="tasks\netstandard2.0" />
</files> </files>
</package> </package>

View File

@ -1,15 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_ApiDescriptionClientAssemblyTarget <_ApiDescriptionClientAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/netstandard2.0/Microsoft.Extensions.ApiDescription.Client.dll</_ApiDescriptionClientAssemblyPath>
Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_ApiDescriptionClientAssemblyTarget>
<_ApiDescriptionClientAssemblyTarget
Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_ApiDescriptionClientAssemblyTarget>
<_ApiDescriptionClientAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_ApiDescriptionClientAssemblyTarget)/Microsoft.Extensions.ApiDescription.Client.dll</_ApiDescriptionClientAssemblyPath>
<_ApiDescriptionClientAssemblyTarget />
</PropertyGroup> </PropertyGroup>
<UsingTask TaskName="GetCurrentItems" AssemblyFile="$(_ApiDescriptionClientAssemblyPath)" /> <UsingTask TaskName="GetCurrentOpenApiReference" AssemblyFile="$(_ApiDescriptionClientAssemblyPath)" />
<UsingTask TaskName="GetFileReferenceMetadata" AssemblyFile="$(_ApiDescriptionClientAssemblyPath)" /> <UsingTask TaskName="GetOpenApiReferenceMetadata" AssemblyFile="$(_ApiDescriptionClientAssemblyPath)" />
<!-- <!--
Settings users may update as they see fit. Settings users may update as they see fit.
@ -98,6 +93,13 @@
<!-- OpenApiProjectReference items may include all OpenApiReference metadata. --> <!-- OpenApiProjectReference items may include all OpenApiReference metadata. -->
<OpenApiProjectReference> <OpenApiProjectReference>
<!--
Semicolon-separated list of global properties to remove in a @(ProjectReference) item created for this
@(OpenApiProjectReference). These properties, along with Configuration, Platform, RuntimeIdentifier and
TargetFrameworks, are also removed when invoking the 'OpenApiGetDocuments' target in the referenced project.
-->
<GlobalPropertiesToRemove>TargetFramework</GlobalPropertiesToRemove>
<!-- <!--
Name of the class to generate. Defaults to match filename in %(OutputPath). To avoid compilation errors, Name of the class to generate. Defaults to match filename in %(OutputPath). To avoid compilation errors,
override only if the referenced project has a single registered document. override only if the referenced project has a single registered document.

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project> <Project>
<!-- Internal settings. Not intended for customization. --> <!-- Internal settings. Not intended for customization. -->
<PropertyGroup> <PropertyGroup>
@ -25,7 +25,6 @@
@(OpenApiProjectReference) items. @(OpenApiProjectReference) items.
--> -->
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)"> <ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)">
<GlobalPropertiesToRemove>TargetFramework</GlobalPropertiesToRemove>
<Private>false</Private> <Private>false</Private>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
@ -44,7 +43,7 @@
BuildInParallel="$(BuildInParallel)" BuildInParallel="$(BuildInParallel)"
Projects="@(OpenApiProjectReference)" Projects="@(OpenApiProjectReference)"
RebaseOutputs="true" RebaseOutputs="true"
RemoveProperties="Configuration;Platform;RuntimeIdentifier;TargetFramework;TargetFrameworks"> RemoveProperties="RuntimeIdentifier;TargetFrameworks;%(OpenApiProjectReference.GlobalPropertiesToRemove)">
<Output TaskParameter="TargetOutputs" ItemName="_Temporary" /> <Output TaskParameter="TargetOutputs" ItemName="_Temporary" />
</MSBuild> </MSBuild>
@ -61,12 +60,12 @@
<_Temporary Remove="@(_Temporary)" /> <_Temporary Remove="@(_Temporary)" />
</ItemGroup> </ItemGroup>
<GetFileReferenceMetadata Inputs="@(OpenApiReference)" <GetOpenApiReferenceMetadata Inputs="@(OpenApiReference)"
Extension="$(DefaultLanguageSourceExtension)" Extension="$(DefaultLanguageSourceExtension)"
Namespace="$(RootNamespace)" Namespace="$(RootNamespace)"
OutputDirectory="$(OpenApiCodeDirectory)"> OutputDirectory="$(OpenApiCodeDirectory)">
<Output TaskParameter="Outputs" ItemName="_Temporary" /> <Output TaskParameter="Outputs" ItemName="_Temporary" />
</GetFileReferenceMetadata> </GetOpenApiReferenceMetadata>
<ItemGroup> <ItemGroup>
<OpenApiReference Remove="@(OpenApiReference)" /> <OpenApiReference Remove="@(OpenApiReference)" />
@ -76,9 +75,9 @@
</Target> </Target>
<Target Name="_GetCurrentOpenApiReference"> <Target Name="_GetCurrentOpenApiReference">
<GetCurrentItems Input="$(GeneratorMetadata)"> <GetCurrentOpenApiReference Input="$(GeneratorMetadata)">
<Output TaskParameter="Outputs" ItemName="CurrentOpenApiReference" /> <Output TaskParameter="Outputs" ItemName="CurrentOpenApiReference" />
</GetCurrentItems> </GetCurrentOpenApiReference>
</Target> </Target>
<Target Name="_InnerGenerateOpenApiCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" /> <Target Name="_InnerGenerateOpenApiCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" />
@ -132,7 +131,7 @@
</Compile> </Compile>
<FileWrites Exclude="@(FileWrites)" <FileWrites Exclude="@(FileWrites)"
Include="@(_Files);@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx;%(Identity)/**/*.$(DefaultLanguageSourceExtension)'" /> Include="@(_Files);@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx;%(Identity)/**/*.$(DefaultLanguageSourceExtension)')" />
<_Files Remove="@(_Files)" /> <_Files Remove="@(_Files)" />
<_Directories Remove="@(_Directories)" /> <_Directories Remove="@(_Directories)" />

View File

@ -65,7 +65,7 @@
<!-- Unless this is an inner build or default timing is disabled, tie document retrieval into the build. --> <!-- Unless this is an inner build or default timing is disabled, tie document retrieval into the build. -->
<Target Name="_GenerateOpenApiDocuments" <Target Name="_GenerateOpenApiDocuments"
AfterTargets="Build" BeforeTargets="Build"
Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == 'true' AND ('$(TargetFramework)' == '' OR '$(TargetFrameworks)' == '') " Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == 'true' AND ('$(TargetFramework)' == '' OR '$(TargetFrameworks)' == '') "
DependsOnTargets="GenerateOpenApiDocuments" /> DependsOnTargets="GenerateOpenApiDocuments" />
</Project> </Project>

View File

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project> <Project>
<ItemGroup>
<_OpenApiGenerateDocumentsTFMs Remove="@(_OpenApiGenerateDocumentsTFMs)" />
<_OpenApiGenerateDocumentsTFMs Include="$(TargetFrameworks)" Exclude="netcoreapp1.0;netcoreapp1.1;netcoreapp2.0" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<!-- Default value may lead to an inner build error if $(OpenApiGenerateDocuments) is explicitly set to 'true'. --> <!-- Default value may lead to an inner build error if $(OpenApiGenerateDocuments) is explicitly set to 'true'. -->
<_OpenApiGenerateDocumentsTFM>$(TargetFrameworks.Trim(';').Split(';')[0])</_OpenApiGenerateDocumentsTFM> <_OpenApiGenerateDocumentsTFM>$(TargetFrameworks.Trim(';').Split(';')[0])</_OpenApiGenerateDocumentsTFM>
<!-- Prefer first TFM of those the tool supports. --> <!-- Prefer first TFM of those the tool supports. -->
<_Temporary>$(@(_OpenApiGenerateDocumentsTFMs).Trim(';'))</_Temporary> <_Temporary>$(TargetFrameworks
.Replace('netcoreapp1.0', '')
.Replace('netcoreapp1.1', '')
.Replace('netcoreapp2.0', '')
.Trim(';'))</_Temporary>
<_OpenApiGenerateDocumentsTFM <_OpenApiGenerateDocumentsTFM
Condition=" '$(_Temporary)' != '' ">$(_Temporary.Split(';')[0])</_OpenApiGenerateDocumentsTFM> Condition=" '$(_Temporary)' != '' ">$(_Temporary.Split(';')[0])</_OpenApiGenerateDocumentsTFM>
@ -34,7 +33,7 @@
</Target> </Target>
<Target Name="_GenerateOpenApiDocuments" <Target Name="_GenerateOpenApiDocuments"
AfterTargets="Build" BeforeTargets="Build"
Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == 'true' " Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == 'true' "
DependsOnTargets="GenerateOpenApiDocuments" /> DependsOnTargets="GenerateOpenApiDocuments" />

View File

@ -21,7 +21,7 @@
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" /> <Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" />
</ItemGroup> </ItemGroup>
<Target Name="BuildX86" AfterTargets="Build" Condition=" '$(TargetFramework)' == 'net461' And '$(Platform)' != 'x86' "> <Target Name="BuildX86" BeforeTargets="Build" Condition=" '$(TargetFramework)' == 'net461' And '$(Platform)' != 'x86' ">
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="TargetFramework=$(TargetFramework);Platform=x86" Targets="Build" /> <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="TargetFramework=$(TargetFramework);Platform=x86" Targets="Build" />
</Target> </Target>
</Project> </Project>