-
Notifications
You must be signed in to change notification settings - Fork 16
/
Directory.Build.targets
119 lines (107 loc) · 4.91 KB
/
Directory.Build.targets
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup Condition="$(VLPackageBasePath) != ''">
<Content Include="$(VLPackageBasePath)*.vl" PackagePath="%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="$(VLPackageBasePath)Assets\**" PackagePath="Assets\%(RecursiveDir)%(Filename)%(Extension)" LinkBase="Assets" />
<Content Include="$(VLPackageBasePath)help\**" PackagePath="help\%(RecursiveDir)%(Filename)%(Extension)" LinkBase="help" />
<Content Include="$(VLPackageBasePath)vvvv\**" PackagePath="vvvv\%(RecursiveDir)%(Filename)%(Extension)" LinkBase="vvvv" />
<Content Remove="$(VLPackageBasePath)**\*.vl.dll" />
</ItemGroup>
<ItemGroup Condition=" '$(IsPackable)' != 'false' ">
<None Include="$(MsBuildThisFileDirectory)build\nugeticon.png" Pack="true" PackagePath="\"/>
</ItemGroup>
<!-- Workaround to specifiy aliases for PackageReference - taken from https://github.com/NuGet/Home/issues/4989 -->
<Target Name="AddPackageAliases" BeforeTargets="ResolveReferences" Outputs="%(PackageReference.Identity)">
<PropertyGroup>
<AliasPackageReference>@(PackageReference->'%(Identity)')</AliasPackageReference>
<AliasName>@(PackageReference->'%(Alias)')</AliasName>
</PropertyGroup>
<ItemGroup>
<ReferencePath Condition="'%(FileName)'=='$(AliasPackageReference)'">
<Aliases>$(AliasName)</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
<!-- https://github.com/dotnet/sdk/issues/1458#issuecomment-401497095 -->
<Target Name="_ResolveCopyLocalNuGetPackagePdbsAndXml"
AfterTargets="ResolveReferences">
<ItemGroup>
<!-- Only include pdb files when building in Debug -->
<ReferenceCopyLocalPaths
Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')"
Condition="'$(Configuration)' == 'Debug'
and '%(ReferenceCopyLocalPaths.NuGetPackageId)' != ''
and Exists('%(RootDir)%(Directory)%(Filename).pdb')" />
<!-- We always want the documentation files - so help texts on nodes work properly -->
<ReferenceCopyLocalPaths
Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).xml')"
Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != ''
and Exists('%(RootDir)%(Directory)%(Filename).xml')" />
</ItemGroup>
</Target>
<!-- From https://stackoverflow.com/questions/17461175/how-to-get-all-the-metadata-keys-for-any-itemgroup-item -->
<UsingTask
TaskName="GetMetadataTask"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<MyItemGroup ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<MetadataString Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
StringBuilder command = new StringBuilder();
foreach (ITaskItem item in MyItemGroup )
{
command.AppendFormat("ItemName={0}\r\n", item);
foreach (string parameter in item.MetadataNames)
{
command.AppendFormat(" {0}={1}\r\n", parameter, item.GetMetadata(parameter));
}
command.AppendFormat("\r\n");
}
MetadataString = command.ToString();
]]>
</Code>
</Task>
</UsingTask>
<!-- From https://stackoverflow.com/questions/12039434/obtain-file-sizes-in-msbuild-script -->
<UsingTask TaskName="GetFileSize" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<TotalSize ParameterType="System.Int64" Output="true"/>
</ParameterGroup>
<Task>
<Using Namespace="System.IO"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
long l = 0;
foreach (var item in Files) {
var fi = new FileInfo(item.ItemSpec);
l += fi.Length;
}
TotalSize = l;
]]>
</Code>
</Task>
</UsingTask>
<!-- Remove Stride content files from non-entry points -->
<Target Name="_RemoveStrideDependencyContentFiles" AfterTargets="_StrideCopyContent">
<ItemGroup>
<Content Remove="@(_StrideDependencyContent)" Condition=" '$(StrideIsExecutable)' == '' or '$(StrideIsExecutable)' == 'false' " />
</ItemGroup>
</Target>
<!-- Remove glslLangValidator.exe (stemming from Stride.Shaders.Compiler) from our packages -->
<Target Name="_RemoveGlslLangValidatorFromPackage" BeforeTargets="_GetPackageFiles">
<ItemGroup>
<Content Condition="'%(Content.Filename)' == 'glslangValidator'">
<Pack>false</Pack>
</Content>
</ItemGroup>
</Target>
<!-- Causes build error on ARM64 -->
<Target Name="_StrideCheckVisualCRuntime2019">
</Target>
</Project>