|
84 | 84 |
|
85 | 85 | <Target Name="_InnerGenerateOpenApiCode" DependsOnTargets="_GetCurrentOpenApiReference;$(GeneratorTarget)" />
|
86 | 86 |
|
| 87 | + <!-- Note target will **always** execute when generator uses the OutputPath as a directory. --> |
87 | 88 | <Target Name="_GenerateOpenApiCode"
|
88 | 89 | Condition="$(OpenApiGenerateCodeAtDesignTime) OR ('$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true')"
|
89 | 90 | Inputs="@(OpenApiReference)"
|
|
100 | 101 | <ItemGroup>
|
101 | 102 | <_Files Remove="@(_Files)" />
|
102 | 103 | <_Files Include="@(OpenApiReference -> '%(OutputPath)')"
|
103 |
| - Condition="$([System.IO.File]::Exists('%(OpenApiReference.OutputPath)'))"> |
104 |
| - <OutputPathExtension>$([System.IO.Path]::GetExtension('%(OpenApiReference.OutputPath)'))</OutputPathExtension> |
105 |
| - </_Files> |
| 104 | + Condition="$([System.IO.File]::Exists('%(OpenApiReference.OutputPath)'))" /> |
106 | 105 | <_Directories Remove="@(_Directories)" />
|
107 | 106 | <_Directories Include="@(OpenApiReference -> '%(OutputPath)')"
|
108 | 107 | Condition="Exists('%(OpenApiReference.OutputPath)') AND ! $([System.IO.File]::Exists('%(OpenApiReference.OutputPath)'))" />
|
| 108 | + </ItemGroup> |
| 109 | + |
| 110 | + <ItemGroup> |
| 111 | + <_Files SourceDocument="%(OriginalItemSpec)" RemoveMetadata="OriginalItemSpec" /> |
| 112 | + <_Directories SourceDocument="%(OriginalItemSpec)" RemoveMetadata="OriginalItemSpec" /> |
| 113 | + </ItemGroup> |
109 | 114 |
|
| 115 | + <ItemGroup> |
110 | 116 | <!-- If OutputPath is a file, add it directly to relevant items. -->
|
111 | 117 | <TypeScriptCompile Include="@(_Files)"
|
112 | 118 | Exclude="@(TypeScriptCompile)"
|
113 |
| - Condition="'%(_Files.OutputPathExtension)' == '.ts' OR '%(_Files.OutputPathExtension)' == '.tsx'"> |
114 |
| - <SourceDocument>%(_Files.FullPath)</SourceDocument> |
115 |
| - </TypeScriptCompile> |
| 119 | + Condition="'%(_Files.Extension)' == '.ts' OR '%(_Files.Extension)' == '.tsx'" /> |
116 | 120 |
|
117 | 121 | <Compile Include="@(_Files)"
|
118 | 122 | Exclude="@(Compile)"
|
119 |
| - Condition="'$(DefaultLanguageSourceExtension)' != '.ts' AND '%(_Files.OutputPathExtension)' == '$(DefaultLanguageSourceExtension)'"> |
120 |
| - <SourceDocument>%(OpenApiReference.FullPath)</SourceDocument> |
121 |
| - </Compile> |
| 123 | + Condition="'$(DefaultLanguageSourceExtension)' != '.ts' AND '%(_Files.Extension)' == '$(DefaultLanguageSourceExtension)'" /> |
| 124 | + </ItemGroup> |
122 | 125 |
|
123 |
| - <!-- Otherwise, add all descendant files with the expected extension. --> |
124 |
| - <TypeScriptCompile Include="@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx')" |
125 |
| - Exclude="@(TypeScriptCompile)"> |
126 |
| - <SourceDocument>%(_Directories.FullPath)</SourceDocument> |
127 |
| - </TypeScriptCompile> |
| 126 | + <!-- |
| 127 | + Otherwise, add all descendant files with the expected extension. Glob into _Directories before updating |
| 128 | + TypeScriptCompile or Compile items. See <https://github.com/dotnet/msbuild/issues/3274> and workaround in |
| 129 | + <https://stackoverflow.com/questions/48868060/can-a-task-itemgroup-glob-files>. Unfortunately, this workaround |
| 130 | + loses SourceDocument and other metadata. |
| 131 | + --> |
| 132 | + <PropertyGroup> |
| 133 | + <_TypeScriptCompileItemsFromDirectories>@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx')</_TypeScriptCompileItemsFromDirectories> |
| 134 | + <_CompileItemsFromDirectories>@(_Directories -> '%(Identity)/**/*$(DefaultLanguageSourceExtension)')</_CompileItemsFromDirectories> |
| 135 | + </PropertyGroup> |
128 | 136 |
|
129 |
| - <Compile Include="@(_Directories -> '%(Identity)/**/*.$(DefaultLanguageSourceExtension)')" |
| 137 | + <ItemGroup> |
| 138 | + <TypeScriptCompile Include="$(_TypeScriptCompileItemsFromDirectories)" Exclude="@(TypeScriptCompile)" /> |
| 139 | + |
| 140 | + <Compile Include="$(_CompileItemsFromDirectories)" |
130 | 141 | Exclude="@(Compile)"
|
131 |
| - Condition="'$(DefaultLanguageSourceExtension)' != '.ts'"> |
132 |
| - <SourceDocument>%(_Directories.FullPath)</SourceDocument> |
133 |
| - </Compile> |
| 142 | + Condition="'$(DefaultLanguageSourceExtension)' != '.ts'" /> |
134 | 143 |
|
135 |
| - <FileWrites Exclude="@(FileWrites)" |
136 |
| - Include="@(_Files);@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx;%(Identity)/**/*.$(DefaultLanguageSourceExtension)')" /> |
| 144 | + <FileWrites Include="@(_Files);$(_TypeScriptCompileItemsFromDirectories);$(_CompileItemsFromDirectories)" |
| 145 | + Exclude="@(FileWrites)" /> |
137 | 146 |
|
138 | 147 | <_Files Remove="@(_Files)" />
|
139 | 148 | <_Directories Remove="@(_Directories)" />
|
140 | 149 | </ItemGroup>
|
| 150 | + |
| 151 | + <PropertyGroup> |
| 152 | + <_TypeScriptCompileItemsFromDirectories /> |
| 153 | + <_CompileItemsFromDirectories /> |
| 154 | + </PropertyGroup> |
141 | 155 | </Target>
|
142 | 156 |
|
143 | 157 | <!-- Inform users of breaking changes in this file and Microsoft.Extensions.ApiDescription.Client.props. -->
|
|
0 commit comments