|
19 | 19 | </PropertyGroup> |
20 | 20 |
|
21 | 21 | <ItemGroup> |
| 22 | + <!-- see https://github.com/dotnet/aspire/pull/1225 --> |
22 | 23 | <None Include="templates\**\*" /> |
23 | 24 | </ItemGroup> |
24 | 25 |
|
| 26 | + <ItemGroup> |
| 27 | + <TemplateProjectFiles Include="$(MSBuildThisFileDirectory)templates\**\*.csproj"> |
| 28 | + <PackagePath>content/templates/%(RecursiveDir)</PackagePath> |
| 29 | + <DestinationFile>$(IntermediateOutputPath)content\templates\%(RecursiveDir)%(Filename)%(Extension)</DestinationFile> |
| 30 | + </TemplateProjectFiles> |
| 31 | + <TemplateProjectFilesObj Include="@(TemplateProjectFiles->'%(DestinationFile)')" /> |
| 32 | + |
| 33 | + <TemplateFiles Include="$(MSBuildThisFileDirectory)templates\**\*" |
| 34 | + Exclude="$(MSBuildThisFileDirectory)templates\**\bin\**;$(MSBuildThisFileDirectory)templates\**\obj\**;$(MSBuildThisFileDirectory)templates\**\*.csproj"> |
| 35 | + <PackagePath>content/templates/%(RecursiveDir)</PackagePath> |
| 36 | + </TemplateFiles> |
| 37 | + <TemplateFilesObj Include="@(TemplateFiles->'$(IntermediateOutputPath)content\templates\%(RecursiveDir)%(Filename)%(Extension)')" /> |
| 38 | + </ItemGroup> |
| 39 | + |
25 | 40 | <!-- When building a package, this target will run to copy all the templates into the intermediate directory, |
26 | 41 | replaces the package versions, and adds them to the package.--> |
27 | 42 | <Target Name="AddTemplatesToPackageAsContent" |
28 | 43 | DependsOnTargets="ReplacePackageVersionOnTemplates"> |
29 | | - |
30 | | - <!-- Creating a temporary item instead of defining content items directly in order to avoid MSBuild MSB4120 |
31 | | - message shown when an item within a target references itself which may cuase unintended expansion. --> |
32 | | - <ItemGroup> |
33 | | - <_TemplatesForPackage Include="$(IntermediateOutputPath)\content\templates\**\*" /> |
34 | | - </ItemGroup> |
35 | 44 | <ItemGroup> |
36 | | - <Content Include="%(_TemplatesForPackage.Identity)" |
37 | | - PackagePath="content/templates/%(_TemplatesForPackage.RecursiveDir)" /> |
| 45 | + <Content Include="@(TemplateFilesObj);@(TemplateProjectFilesObj)" /> |
38 | 46 | </ItemGroup> |
39 | 47 | </Target> |
40 | 48 |
|
41 | 49 | <!-- Replaces the versions referenced by the templates projects to use the version of the packages being live-built --> |
42 | 50 | <Target Name="ReplacePackageVersionOnTemplates" |
43 | | - DependsOnTargets="CopyTemplatesToIntermediateOutputPath"> |
44 | | - |
45 | | - <ItemGroup> |
46 | | - <TemplateProjectFiles Include="templates\**\*.csproj" /> |
47 | | - <TemplateProjectFiles> |
48 | | - <DestinationFile>$(IntermediateOutputPath)\content\templates\%(RecursiveDir)%(Filename)%(Extension)</DestinationFile> |
49 | | - </TemplateProjectFiles> |
50 | | - </ItemGroup> |
| 51 | + DependsOnTargets="CopyTemplatesToIntermediateOutputPath" |
| 52 | + Inputs="@(TemplateProjectFiles)" |
| 53 | + Outputs="@(TemplateProjectFilesObj)"> |
51 | 54 |
|
52 | 55 | <WriteLinesToFile File="%(TemplateProjectFiles.DestinationFile)" |
53 | 56 | Lines="$([System.IO.File]::ReadAllText('%(TemplateProjectFiles.FullPath)') |
|
61 | 64 | .Replace('!!REPLACE_WITH_OTEL_ASPNETCORE_VERSION!!', '$(OpenTelemetryInstrumentationAspNetCoreVersion)') |
62 | 65 | .Replace('!!REPLACE_WITH_OTEL_HTTP_VERSION!!', '$(OpenTelemetryInstrumentationHttpVersion)') |
63 | 66 | .Replace('!!REPLACE_WITH_OTEL_RUNTIME_VERSION!!', '$(OpenTelemetryInstrumentationRuntimeVersion)') )" |
| 67 | + WriteOnlyWhenDifferent="True" |
64 | 68 | Overwrite="true" /> |
65 | 69 | </Target> |
66 | 70 |
|
67 | 71 | <!-- Grabs the contents of the templates folder and copies them to IntermediateOutputPath directory --> |
68 | | - <Target Name="CopyTemplatesToIntermediateOutputPath"> |
69 | | - |
70 | | - <ItemGroup> |
71 | | - <_ContentFilesToPackage Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**;templates\**\*.csproj" /> |
72 | | - </ItemGroup> |
| 72 | + <Target Name="CopyTemplatesToIntermediateOutputPath" |
| 73 | + Inputs="@(TemplateFiles)" |
| 74 | + Outputs="@(TemplateFilesObj)"> |
73 | 75 |
|
74 | | - <Copy SourceFiles="@(_ContentFilesToPackage)" |
75 | | - SkipUnchangedFiles="true" |
76 | | - DestinationFolder="$(IntermediateOutputPath)\content\templates\%(RecursiveDir)" /> |
| 76 | + <Copy SourceFiles="@(TemplateFiles)" |
| 77 | + DestinationFiles="@(TemplateFilesObj)" |
| 78 | + SkipUnchangedFiles="true" /> |
77 | 79 | </Target> |
78 | 80 |
|
79 | 81 | </Project> |
0 commit comments