-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
63 lines (52 loc) · 2.97 KB
/
Directory.Build.targets
File metadata and controls
63 lines (52 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<Project>
<ItemGroup>
<!-- Usually, GenerateSource="true" is enough for Arcade to do the generation. -->
<!-- However, MSBuild.Sdk.Extras can break us by explicitly setting Generator metadata -->
<!-- https://github.com/novotnyllc/MSBuildSdkExtras/blob/b58e1d25b530e02ce4d1b937ccf99082019cdc47/Source/MSBuild.Sdk.Extras/DefaultItems/Platforms/Common.props#L13-L21 -->
<EmbeddedResource Update="**\*.resx" GenerateSource="true" Generator="MSBuild:_GenerateResxSource" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<!-- Pack config -->
<PropertyGroup>
<PackageTags Condition=" '$(PackageTags)' == '' ">$(CommonPackageTags)</PackageTags>
<PackageReadmeFile Condition=" '$(PackageReadmeFile)' == '' and Exists('PACKAGE.md') ">PACKAGE.md</PackageReadmeFile>
</PropertyGroup>
<!-- Add a package README file from. -->
<ItemGroup Condition=" '$(PackageReadmeFile)' != '' ">
<None Include="$(PackageReadmeFile)" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Condition=" '$(GenerateBuildInfo)' == 'true' ">
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Templating" Version="$(MicrosoftDotNetBuildTasksTemplatingPackageVersion)" AllowExplicitReference="true" PrivateAssets="All" IsImplicitlyDefined="true" />
</ItemGroup>
<Target Name="_GenerateVersionSourceFileCache">
<PropertyGroup>
<_TemplateProperties>Version=$(Version)</_TemplateProperties>
<_TemplatePropertiesCacheFile>$(IntermediateOutputPath)$(MSBuildProjectFile).GenerateVersionSourceFile.cache</_TemplatePropertiesCacheFile>
</PropertyGroup>
<Hash ItemsToHash="@(_TemplateProperties)">
<Output TaskParameter="HashResult" PropertyName="_TemplatePropertiesHash" />
</Hash>
<WriteLinesToFile Lines="$(_TemplatePropertiesHash)" File="$(_TemplatePropertiesCacheFile)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_TemplatePropertiesCacheFile)" />
</ItemGroup>
</Target>
<!-- See https://github.com/dotnet/arcade/issues/16019 -->
<!-- This can be simplified if Arcade implemented WriteOnlyWhenDifferent -->
<Target Name="GenerateVersionSourceFile"
AfterTargets="PrepareForBuild"
DependsOnTargets="_GenerateVersionSourceFileCache"
Inputs="$(_TemplatePropertiesCacheFile)"
Outputs="$(IntermediateOutputPath)BuildInfo.cs"
Condition=" '$(GenerateBuildInfo)' == 'true' ">
<ItemGroup>
<_TemplateCsproj Include="$(MSBuildProjectDirectory)/BuildInfo.cs.template" Destination="$(IntermediateOutputPath)BuildInfo.cs" />
</ItemGroup>
<GenerateFileFromTemplate TemplateFile="%(_TemplateCsproj.Identity)" OutputPath="%(_TemplateCsproj.Destination)" Properties="$(_TemplateProperties)">
<Output TaskParameter="ResolvedOutputPath" ItemName="FileWrites" />
</GenerateFileFromTemplate>
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)BuildInfo.cs" />
</ItemGroup>
</Target>
</Project>