Skip to content

Commit 2cff475

Browse files
committed
Fix build and address PR comments
- adjust eng/ProjectReferences.props to new project name - simplify `_CreateOpenApiReferenceItemsForOpenApiProjectReferences` target e.g. remove batching - simplify item de-duplication in `_CreateCompileItemsForServiceFileReferences` target i.e. use `Remove` attribute - also handle `.tsx` files in this target - remove malformed `Exists(...)` check in `_GenerateOpenApiReferenceCode` target nits: - remove a useless `StringBuilder.Append(...)` call - remove `%(OpenApiProjectReference.SourceProject)` metadata, duplicated `%(OriginalItemSpec)` - be more consistent about using element syntax for item metadata
1 parent 5b66b60 commit 2cff475

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

eng/ProjectReferences.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Identity.Specification.Tests" ProjectPath="$(RepositoryRoot)src\Identity\Specification.Tests\src\Microsoft.AspNetCore.Identity.Specification.Tests.csproj" />
99
<ProjectReferenceProvider Include="Microsoft.Web.Xdt.Extensions" ProjectPath="$(RepositoryRoot)src\SiteExtensions\Microsoft.Web.Xdt.Extensions\src\Microsoft.Web.Xdt.Extensions.csproj" />
1010
<ProjectReferenceProvider Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" ProjectPath="$(RepositoryRoot)src\Tools\FirstRunCertGenerator\src\Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj" />
11-
<ProjectReferenceProvider Include="Microsoft.Extensions.ApiDescription.Tasks" ProjectPath="$(RepositoryRoot)src\Mvc\Extensions.ApiDescription.Design\src\Microsoft.Extensions.ApiDescription.Design.csproj" />
11+
<ProjectReferenceProvider Include="Microsoft.Extensions.ApiDescription.Tasks" ProjectPath="$(RepositoryRoot)src\Mvc\Extensions.ApiDescription.Client\src\Microsoft.Extensions.ApiDescription.Client.csproj" />
1212
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SignalR.Specification.Tests" ProjectPath="$(RepositoryRoot)src\SignalR\server\Specification.Tests\src\Microsoft.AspNetCore.SignalR.Specification.Tests.csproj" />
1313
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Blazor.Build" ProjectPath="$(RepositoryRoot)src\Components\Blazor\Build\src\Microsoft.AspNetCore.Blazor.Build.csproj" />
1414
<ProjectReferenceProvider Include="Microsoft.AspNetCore" ProjectPath="$(RepositoryRoot)src\DefaultBuilder\src\Microsoft.AspNetCore.csproj" RefProjectPath="$(RepositoryRoot)src\DefaultBuilder\ref\Microsoft.AspNetCore.csproj" />

src/Mvc/Extensions.ApiDescription.Client/src/MetadataSerializer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ private static void EscapeValue(string value, StringBuilder builder)
115115
{
116116
if (string.IsNullOrEmpty(value))
117117
{
118-
builder.Append(value);
119118
return;
120119
}
121120

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
-->
3838
<ItemDefinitionGroup>
3939
<!-- OpenApiProjectReference items may also include OpenApiReference metadata. -->
40-
<OpenApiProjectReference>
41-
<!-- The original identity. Saved when creating OpenApiReference items. -->
42-
<SourceProject>%(Identity)</SourceProject>
43-
</OpenApiProjectReference>
40+
<OpenApiProjectReference />
4441

4542
<OpenApiReference>
4643
<!-- Name of the class to generate. Defaults to match filename in %(OutputPath). -->

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

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,35 @@
2121
Do not change %(ReferenceOutputAssembly) if project contains duplicate @(ProjectReference) and
2222
@(OpenApiProjectReference) items.
2323
-->
24-
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)" ReferenceOutputAssembly="false" />
25-
<ProjectReference Update="@(OpenApiProjectReference)" OpenApiReference="true" />
24+
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)">
25+
<NoWarn>NU1702</NoWarn>
26+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
27+
</ProjectReference>
28+
<ProjectReference Update="@(OpenApiProjectReference)">
29+
<OpenApiReference>true</OpenApiReference>
30+
</ProjectReference>
2631
</ItemGroup>
2732

2833
<Target Name="_CreateOpenApiReferenceItemsForOpenApiProjectReferences"
2934
AfterTargets="ResolveProjectReferences"
30-
Condition="'%(ProjectReferenceWithConfiguration.OpenApiReference)' == 'true' AND '$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true'"
31-
Inputs="%(ProjectReferenceWithConfiguration.Identity)"
32-
Outputs="&lt;not-a-file !&gt;">
33-
<PropertyGroup>
34-
<_Identity>%(ProjectReferenceWithConfiguration.Identity)</_Identity>
35-
<_Temporary />
36-
</PropertyGroup>
37-
38-
<MSBuild Target="OpenApiGetDocuments"
39-
Project="$(_Identity)"
35+
Condition="'$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true'">
36+
<ItemGroup>
37+
<_Temporary Remove="@(_Temporary)" />
38+
</ItemGroup>
39+
40+
<MSBuild Targets="OpenApiGetDocuments"
41+
Projects="@(ProjectReferenceWithConfiguration)"
42+
Condition="'%(ProjectReferenceWithConfiguration.OpenApiReference)' == 'true'"
4043
Properties="%(ProjectReferenceWithConfiguration.SetConfiguration); %(ProjectReferenceWithConfiguration.SetPlatform); %(ProjectReferenceWithConfiguration.SetTargetFramework)"
4144
RebaseOutputs="true"
4245
RemoveProperties="%(ProjectReferenceWithConfiguration.GlobalPropertiesToRemove);TargetFrameworks;RuntimeIdentifier">
43-
<Output TaskParameter="TargetOutputs" PropertyName="_Temporary" />
46+
<Output TaskParameter="TargetOutputs" ItemName="_Temporary" />
4447
</MSBuild>
4548

4649
<ItemGroup>
47-
<OpenApiProjectReference Update="$(_Identity)">
48-
<Documents>$(_Temporary)</Documents>
49-
</OpenApiProjectReference>
50-
<OpenApiReference Include="@(OpenApiProjectReference -> '%(Documents)')" Condition="'%(Identity)' == '$(_Identity)'" />
50+
<OpenApiReference Include="@(_Temporary)" Exclude="@(OpenApiReference)" RemoveMetadata="FullConfiguration" />
51+
<_Temporary Remove="@(_Temporary)" />
5152
</ItemGroup>
52-
<PropertyGroup>
53-
<_Identity />
54-
<_Temporary />
55-
</PropertyGroup>
5653
</Target>
5754

5855
<!-- OpenApiReference support. -->
@@ -84,8 +81,10 @@
8481

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

87-
<Target Name="_GenerateOpenApiReferenceCode" Inputs="@(OpenApiReference)" Outputs="%(OutputPath)"
88-
Condition="$(OpenApiGenerateAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true') OR !Exists('%(OutputPath)')">
84+
<Target Name="_GenerateOpenApiReferenceCode"
85+
Condition="$(OpenApiGenerateAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true')"
86+
Inputs="@(OpenApiReference)"
87+
Outputs="%(OutputPath)">
8988
<MSBuild BuildInParallel="$(BuildInParallel)"
9089
Projects="$(MSBuildProjectFullPath)"
9190
Properties="GeneratorTargetPath=%(OpenApiReference.OutputPath);GeneratorTarget=Generate%(CodeGenerator);GeneratorMetadata=%(SerializedMetadata)"
@@ -105,27 +104,26 @@
105104
Condition="Exists('%(OpenApiReference.OutputPath)') AND ! $([System.IO.File]::Exists('%(OpenApiReference.OutputPath)'))" />
106105

107106
<!-- If OutputPath is a file, add it directly to relevant items. -->
108-
<TypeScriptCompile Remove="@(_Files)" Condition="'%(_Files.OutputPathExtension)' == '.ts'" />
109-
<TypeScriptCompile Include="@(_Files)" Condition="'%(_Files.OutputPathExtension)' == '.ts'">
107+
<TypeScriptCompile Include="@(_Files)"
108+
Exclude="@(TypeScriptCompile)"
109+
Condition="'%(_Files.OutputPathExtension)' == '.ts' OR '%(_Files.OutputPathExtension)' == '.tsx'">
110110
<SourceDocument>%(_Files.FullPath)</SourceDocument>
111111
</TypeScriptCompile>
112112

113-
<Compile Remove="@(_Files)"
114-
Condition="'$(DefaultLanguageSourceExtension)' != '.ts' AND '%(_Files.OutputPathExtension)' == '$(DefaultLanguageSourceExtension)'" />
115113
<Compile Include="@(_Files)"
114+
Exclude="@(Compile)"
116115
Condition="'$(DefaultLanguageSourceExtension)' != '.ts' AND '%(_Files.OutputPathExtension)' == '$(DefaultLanguageSourceExtension)'">
117116
<SourceDocument>%(OpenApiReference.FullPath)</SourceDocument>
118117
</Compile>
119118

120119
<!-- Otherwise, add all descendant files with the expected extension. -->
121-
<TypeScriptCompile Remove="@(_Directories -> '%(Identity)/**/*.ts')" />
122-
<TypeScriptCompile Include="@(_Directories -> '%(Identity)/**/*.ts')">
120+
<TypeScriptCompile Include="@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx')"
121+
Exclude="@(TypeScriptCompile)">
123122
<SourceDocument>%(_Directories.FullPath)</SourceDocument>
124123
</TypeScriptCompile>
125124

126-
<Compile Remove="@(_Directories -> '%(Identity)/**/*.$(DefaultLanguageSourceExtension)')"
127-
Condition="'$(DefaultLanguageSourceExtension)' != '.ts'" />
128125
<Compile Include="@(_Directories -> '%(Identity)/**/*.$(DefaultLanguageSourceExtension)')"
126+
Exclude="@(Compile)"
129127
Condition="'$(DefaultLanguageSourceExtension)' != '.ts'">
130128
<SourceDocument>%(_Directories.FullPath)</SourceDocument>
131129
</Compile>

0 commit comments

Comments
 (0)