Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more properties controlling service reference code generation #10641

Merged
merged 4 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/ProjectReferences.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Identity.Specification.Tests" ProjectPath="$(RepoRoot)src\Identity\Specification.Tests\src\Microsoft.AspNetCore.Identity.Specification.Tests.csproj" />
<ProjectReferenceProvider Include="Microsoft.Web.Xdt.Extensions" ProjectPath="$(RepoRoot)src\SiteExtensions\Microsoft.Web.Xdt.Extensions\src\Microsoft.Web.Xdt.Extensions.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" ProjectPath="$(RepoRoot)src\Tools\FirstRunCertGenerator\src\Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.ApiDescription.Tasks" ProjectPath="$(RepoRoot)src\Mvc\Extensions.ApiDescription.Client\src\Microsoft.Extensions.ApiDescription.Client.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.ApiDescription.Client" ProjectPath="$(RepoRoot)src\Mvc\Extensions.ApiDescription.Client\src\Microsoft.Extensions.ApiDescription.Client.csproj" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing some necessary context here, but I don't really get the point of renaming an assembly containing tasks to not be suffixed with .Tasks.

Is the metapoint here that we want to separate the tasks used for client-gen from the tasks used inside server-projects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original point but I ended up not needing tasks in the server project and decided I preferred using the same name everywhere.

<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR.Specification.Tests" ProjectPath="$(RepoRoot)src\SignalR\server\Specification.Tests\src\Microsoft.AspNetCore.SignalR.Specification.Tests.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Blazor.Build" ProjectPath="$(RepoRoot)src\Components\Blazor\Build\src\Microsoft.AspNetCore.Blazor.Build.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore" ProjectPath="$(RepoRoot)src\DefaultBuilder\src\Microsoft.AspNetCore.csproj" RefProjectPath="$(RepoRoot)src\DefaultBuilder\ref\Microsoft.AspNetCore.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Copied from
// https://github.com/aspnet/AspNetCore-Tooling/blob/master/src/Razor/src/Microsoft.AspNetCore.Razor.Language/CSharpIdentifier.cs
namespace Microsoft.Extensions.ApiDescription.Tasks
namespace Microsoft.Extensions.ApiDescription.Client
{
internal static class CSharpIdentifier
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.Extensions.ApiDescription.Tasks
namespace Microsoft.Extensions.ApiDescription.Client
{
/// <summary>
/// Restore <see cref="ITaskItem"/>s from given property value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.Extensions.ApiDescription.Tasks
namespace Microsoft.Extensions.ApiDescription.Client
{
/// <summary>
/// Adds or corrects ClassName, FirstForGenerator, Namespace, and OutputPath metadata in OpenApiReference items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.Extensions.ApiDescription.Tasks
namespace Microsoft.Extensions.ApiDescription.Client
{
/// <summary>
/// Utility methods to serialize and deserialize <see cref="ITaskItem"/> metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
<!-- Do not complain about lack of lib folder. -->
<NoPackageAnalysis>true</NoPackageAnalysis>

<AssemblyName>Microsoft.Extensions.ApiDescription.Tasks</AssemblyName>
<Description>MSBuild tasks and targets for code generation</Description>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSource>false</IncludeSource>
<IncludeSymbols>false</IncludeSymbols>
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
<PackageId>$(MSBuildProjectName)</PackageId>
<PackageTags>Build Tasks;MSBuild;Swagger;Open API;code generation; Web API client</PackageTags>
<IsShippingPackage>true</IsShippingPackage>
<PackageVersion>$(ExperimentalPackageVersion)</PackageVersion>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<VerifyVersion>false</VerifyVersion>
<VersionPrefix>$(ExperimentalVersionPrefix)</VersionPrefix>
<VersionSuffix>$(ExperimentalVersionSuffix)</VersionSuffix>

<HasReferenceAssembly>false</HasReferenceAssembly>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<files>
<file src="build\*" target="build" />
<file src="buildMultiTargeting\*" target="buildMultiTargeting" />
<file src="$baseOutputPath$\$configuration$\net461\Microsoft.Extensions.ApiDescription.Tasks.*" target="tasks\net461" />
<file src="$baseOutputPath$\$configuration$\netstandard2.0\Microsoft.Extensions.ApiDescription.Tasks.*" target="tasks\netstandard2.0" />
<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" />
</files>
</package>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,35 +1,60 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<PropertyGroup>
<_ApiDescriptionTasksAssemblyTarget
Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_ApiDescriptionTasksAssemblyTarget>
<_ApiDescriptionTasksAssemblyTarget
Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_ApiDescriptionTasksAssemblyTarget>
<_ApiDescriptionTasksAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_ApiDescriptionTasksAssemblyTarget)/Microsoft.Extensions.ApiDescription.Tasks.dll</_ApiDescriptionTasksAssemblyPath>
<_ApiDescriptionTasksAssemblyTarget />
<_ApiDescriptionClientAssemblyTarget
Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_ApiDescriptionClientAssemblyTarget>
<_ApiDescriptionClientAssemblyTarget
Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_ApiDescriptionClientAssemblyTarget>
<_ApiDescriptionClientAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_ApiDescriptionClientAssemblyTarget)/Microsoft.Extensions.ApiDescription.Client.dll</_ApiDescriptionClientAssemblyPath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really relevant anymore? MSBuild supports netstandard2.0 everywhere .NET Core runs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the assembly has any dependencies that aren't in netstandard as implemented in .NET 4.7.2, I'd leave this in. Netstandard task assemblies are probably much more viable now that VS is on 4.7.2, but they've historically been a problem and splitting into core and full implementations has been required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm mentioning it because we've been doing ns2.0 in Razor for a while now with no problems.

Since this is new code it should be fine as long as we test it in VS right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as long as it works in VS, command line msbuild.exe, and command line msbuild.exe from a Build Tools install of VS, you should be good to go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this to #4923 since the extra bits do no harm. This is all an implementation detail and it'll take time to do the necessary testing…

<_ApiDescriptionClientAssemblyTarget />
</PropertyGroup>
<UsingTask TaskName="GetCurrentItems" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="GetFileReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="GetCurrentItems" AssemblyFile="$(_ApiDescriptionClientAssemblyPath)" />
<UsingTask TaskName="GetFileReferenceMetadata" AssemblyFile="$(_ApiDescriptionClientAssemblyPath)" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random observation: GetCurrentItems is a pretty generic name given that item is a common term in MSBuild. We might want to choose more specific names. I don't think GetFileReferenceMetadata is bad.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the suggestion to #4923


<!--
Settings users may update as they see fit.
-->
<PropertyGroup>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennc do you have any input on the names of these user-visible properties?

<OpenApiDefaultGeneratorOptions Condition="'$(OpenApiDefaultGeneratorOptions)' == ''"></OpenApiDefaultGeneratorOptions>
<!--
Options added to the code generator command line by default. Provides the default %(Options) metadata of
@(OpenApiReference) and @(OpenApiProjectReference) items.
-->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always really happy to see quality docs in MSBuild 👍

<OpenApiGenerateCodeOptions Condition="'$(OpenApiGenerateCodeOptions)' == ''"></OpenApiGenerateCodeOptions>

<!--
If 'true' (the default), generate code for @(OpenApiReference) and @(OpenApiProjectReference) items before the
BeforeCompile target.

If 'false', the 'GenerateOpenApiCode' target is not part of the build (by default) but can run when explicitly
referenced. That is, the target may be invoked from the command line or tied in through another target.
-->
<OpenApiGenerateCodeOnBuild Condition="'$(OpenApiGenerateCodeOnBuild)' == ''">true</OpenApiGenerateCodeOnBuild>

<!--
If 'true' (the default), generate code for @(OpenApiReference) and @(OpenApiProjectReference) items during
design-time builds. Otherwise, generate code only during a full build.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going with the name OpenApiGenerateCodeOnBuild would this become OpenApiGenerateCodeOnDesignTimeBuild?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about it but the sense is a bit different. @glennc and I decided this one was fine as-is. Could of course change it if users disagree.

-->
<OpenApiGenerateCodeAtDesignTime
Condition="'$(OpenApiGenerateCodeAtDesignTime)' == ''">true</OpenApiGenerateCodeAtDesignTime>

<!--
If 'true', will generate code for OpenApiReference items during design-time builds. Otherwise, generate code only
for output files that do not yet exist during design-time builds.
If 'true' (the default), build projects referenced in @(OpenApiProjectReference) items before retrieving that
project's Open API documents list (or generating code). Recommend setting this to 'false' when the referenced
projects do not share target framework values (avoiding build errors and / or warnings).

If 'false', ensure the referenced projects build before this one in the solution or through other means. IDEs may
be confused about the project dependency graph in this case.
-->
<OpenApiGenerateAtDesignTime Condition="'$(OpenApiGenerateAtDesignTime)' == ''">true</OpenApiGenerateAtDesignTime>
<OpenApiBuildReferencedProjects
Condition="'$(OpenApiBuildReferencedProjects)' == ''">true</OpenApiBuildReferencedProjects>

<!--
$(OpenApiDefaultOutputDirectory) value is interpreted relative to the project folder, unless already an
absolute path.
Default folder to place code generated from Open API documents. Value is interpreted relative to the project
folder, unless already an absolute path. Part of the default %(OutputPath) metadata of @(OpenApiReference) and
@(OpenApiProjectReference) items.
-->
<OpenApiDefaultOutputDirectory
Condition="'$(OpenApiDefaultOutputDirectory)' == ''">$(BaseIntermediateOutputPath)</OpenApiDefaultOutputDirectory>
<OpenApiDefaultOutputDirectory>$([MSBuild]::EnsureTrailingSlash('$(OpenApiDefaultOutputDirectory)'))</OpenApiDefaultOutputDirectory>
<OpenApiCodeDirectory
Condition="'$(OpenApiCodeDirectory)' == ''">$(BaseIntermediateOutputPath)</OpenApiCodeDirectory>
</PropertyGroup>

<!--
Expand All @@ -42,24 +67,28 @@
<OpenApiReference>
<!-- Name of the class to generate. Defaults to match filename in %(OutputPath). -->
<ClassName />

<!--
Code generator to use. Required and must end with "CSharp" or "TypeScript" (the currently-supported target
languages) unless %(OutputPath) is set. Builds will invoke a target named "Generate%(CodeGenerator)" to do
actual code generation.
-->
<CodeGenerator>NSwagCSharp</CodeGenerator>

<!-- Namespace to contain generated class. Default is $(RootNamespace). -->
<Namespace />

<!--
Options to pass to the code generator target then (likely) added to a tool's command line. Value is passed
along to the code generator but otherwise unused in this package.
-->
<Options>$(OpenApiDefaultGeneratorOptions)</Options>
<Options>$(OpenApiGenerateCodeOptions)</Options>

<!--
Path to place generated code. Code generator may interpret path as a filename or directory. Default filename or
folder name is %(Filename)Client.[cs|ts]. Filenames and relative paths (if explicitly set) are combined with
$(OpenApiDefaultOutputDirectory). Final value (depending on $(OpenApiDefaultOutputDirectory)) is likely to be
a path relative to the client project.
$(OpenApiCodeDirectory). Final value (depending on $(OpenApiCodeDirectory)) is likely to be a path relative to
the client project.
-->
<OutputPath />
</OpenApiReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
<Project>
<!-- Internal settings. Not intended for customization. -->
<PropertyGroup>
<GenerateOpenApiReferenceCodeDependsOn>
_GetMetadataForOpenApiReferences;
_GenerateOpenApiReferenceCode;
_CreateCompileItemsForOpenApiReferences
</GenerateOpenApiReferenceCodeDependsOn>
<GenerateServiceFileReferenceCodeDependsOn>
<GenerateOpenApiCodeDependsOn>
_GenerateErrorsForOldItems;
_CreateOpenApiReferenceItemsForOpenApiProjectReferences;
GenerateOpenApiReferenceCode
</GenerateServiceFileReferenceCodeDependsOn>
_GetMetadataForOpenApiReferences;
_GenerateOpenApiCode;
_CreateCompileItemsForOpenApiReferences
</GenerateOpenApiCodeDependsOn>
</PropertyGroup>

<!-- OpenApiProjectReference support. -->

<ItemGroup>
<ItemGroup Condition=" '$(OpenApiBuildReferencedProjects)' == 'true' ">
<!--
Do not change %(ReferenceOutputAssembly) if project contains duplicate @(ProjectReference) and
@(OpenApiProjectReference) items.
Expand All @@ -30,19 +27,16 @@
</ProjectReference>
</ItemGroup>

<Target Name="_CreateOpenApiReferenceItemsForOpenApiProjectReferences"
AfterTargets="ResolveProjectReferences"
Condition="'$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true'">
<Target Name="_CreateOpenApiReferenceItemsForOpenApiProjectReferences" DependsOnTargets="ResolveProjectReferences">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have Condition="@(OpenApiProjectReference->Count()) != 0"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really doesn't matter because everything in this target no-ops when there's nothing worth doing. Let me know if you feel differently

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple is better, I agree with Doug.

<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>

<MSBuild Targets="OpenApiGetDocuments"
Projects="@(ProjectReferenceWithConfiguration)"
Condition="'%(ProjectReferenceWithConfiguration.OpenApiReference)' == 'true'"
Properties="%(ProjectReferenceWithConfiguration.SetConfiguration); %(ProjectReferenceWithConfiguration.SetPlatform); %(ProjectReferenceWithConfiguration.SetTargetFramework)"
BuildInParallel="$(BuildInParallel)"
Projects="@(OpenApiProjectReference)"
RebaseOutputs="true"
RemoveProperties="%(ProjectReferenceWithConfiguration.GlobalPropertiesToRemove);TargetFrameworks;RuntimeIdentifier">
RemoveProperties="Configuration;Platform;RuntimeIdentifier;TargetFramework;TargetFrameworks">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rainersigwald is removing these properties sufficient?

And, am I missing something important in the shift from @(ProjectReferenceWithConfiguration) to using @(OpenApiProjectReference) items directly? (Without this, design-time builds would still have been broken and '$(OpenApiBuildReferencedProjects)' == 'false' would not work.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd definitely want to keep something like %(OpenApiProjectReference.GlobalPropertiesToRemove) in there as an escape hatch. This list looks ok to me, but there's always a risk of things changing (like when multitargeting was added) or user projects having their own custom dimensions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion! I added this to #4923 because I have other bits to do short-term.

<Output TaskParameter="TargetOutputs" ItemName="_Temporary" />
</MSBuild>

Expand All @@ -62,7 +56,7 @@
<GetFileReferenceMetadata Inputs="@(OpenApiReference)"
Extension="$(DefaultLanguageSourceExtension)"
Namespace="$(RootNamespace)"
OutputDirectory="$(OpenApiDefaultOutputDirectory)">
OutputDirectory="$(OpenApiCodeDirectory)">
<Output TaskParameter="Outputs" ItemName="_Temporary" />
</GetFileReferenceMetadata>

Expand All @@ -79,17 +73,16 @@
</GetCurrentItems>
</Target>

<Target Name="_InnerGenerateOpenApiReferenceCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" />
<Target Name="_InnerGenerateOpenApiCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" />

<Target Name="_GenerateOpenApiReferenceCode"
Condition="$(OpenApiGenerateAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true')"
<Target Name="_GenerateOpenApiCode"
Condition="$(OpenApiGenerateCodeAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true')"
Inputs="@(OpenApiReference)"
Outputs="%(OutputPath)">
<MSBuild BuildInParallel="$(BuildInParallel)"
Projects="$(MSBuildProjectFullPath)"
<MSBuild Projects="$(MSBuildProjectFullPath)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this idea with this call that we only want to call this once even with multi-targeting? If that's the case should we have a comment?

Basically I'm not sure why this is a separate invocation of MSBuild, a comment would help.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is about running things once. And, sure, I'll add a comment

BuildInParallel="$(BuildInParallel)"
Properties="GeneratorTargetPath=%(OpenApiReference.OutputPath);GeneratorTarget=Generate%(CodeGenerator);GeneratorMetadata=%(SerializedMetadata)"
RemoveProperties="TargetFrameworks"
Targets="_InnerGenerateOpenApiReferenceCode" />
Targets="_InnerGenerateOpenApiCode" />
</Target>

<Target Name="_CreateCompileItemsForOpenApiReferences" Condition="'@(OpenApiReference)' != ''">
Expand Down Expand Up @@ -133,17 +126,26 @@
</ItemGroup>
</Target>

<Target Name="GenerateOpenApiReferenceCode" DependsOnTargets="$(GenerateOpenApiReferenceCodeDependsOn)" />

<!-- Tie above code generation steps into the build. -->
<!-- Inform users of breaking changes in this file and Microsoft.Extensions.ApiDescription.Client.props. -->

<Target Name="_GenerateErrorsForOldItems">
<Error Condition="'@(ServiceProjectReference)' != ''" Text="ServiceProjectReference items are no longer supported." />
<Error Condition="'@(ServiceUriReference)' != ''" Text="ServiceUriReference items are no longer supported." />
<Error Condition="'@(ServiceFileReference)' != ''" Text="ServiceFileReference items are no longer supported." />
</Target>

<Target Name="GenerateServiceFileReferenceCode"
<!-- Main code generation entry point. -->

<Target Name="GenerateOpenApiCode" DependsOnTargets="$(GenerateOpenApiCodeDependsOn)" />

<!--
Unless this is an inner build or default timing is disabled, tie code generation into the build. Separate from
GenerateOpenApiCode and not invoked from the ../buildMultiTargeting targets to prevent repeated code generation
when multi-targeting.
-->

<Target Name="_TieInGenerateOpenApiCode"
BeforeTargets="BeforeCompile"
DependsOnTargets="$(GenerateServiceFileReferenceCodeDependsOn)" />
Condition=" '$(OpenApiGenerateCodeOnBuild)' == 'true' AND ('$(TargetFramework)' == '' OR '$(TargetFrameworks)' == '') "
DependsOnTargets="GenerateOpenApiCode" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<Import Project="../build/Microsoft.Extensions.ApiDescription.Client.props" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<Target Name="GenerateServiceFileReferenceCode" BeforeTargets="BeforeCompile">
<MsBuild Projects="$(MSBuildProjectFile)"
Targets="GenerateServiceFileReferenceCode"
<Target Name="GenerateOpenApiCode">
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="GenerateOpenApiCode"
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0])"
RemoveProperties="TargetFrameworks;RuntimeIdentifier" />
RemoveProperties="RuntimeIdentifier" />
</Target>

<Target Name="_GenerateOpenApiCode"
BeforeTargets="BeforeCompile"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CoreCompile. Would that allow users to do user things ™️ in BeforeCompile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoreCompile is late because it comes after the MSBuild targets cache the list of references and source files involved in the compilation

Condition=" ''$(OpenApiGenerateCodeOnBuild)' == 'true' "
DependsOnTargets="GenerateOpenApiCode" />
</Project>