-
Notifications
You must be signed in to change notification settings - Fork 18
/
Directory.Build.targets
81 lines (66 loc) · 3.3 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
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CustomBuild" AfterTargets="AfterBuild">
<!-- This is used for .NET Core 3 packaged scenarios -->
</Target>
<Target Name="_StompSourceProjectForWapProject" BeforeTargets="_ConvertItems">
<!-- Bug: WinMD Files are not deployed within the exe file. Flatten the package structure fix it -->
<ItemGroup>
<!-- Stomp all "SourceProject" values for all incoming dependencies to flatten the package. -->
<_TemporaryFilteredWapProjOutput Include="@(_FilteredNonWapProjProjectOutput)" />
<_FilteredNonWapProjProjectOutput Remove="@(_TemporaryFilteredWapProjOutput)" />
<_FilteredNonWapProjProjectOutput Include="@(_TemporaryFilteredWapProjOutput)">
<!-- Blank the SourceProject here to vend all files into the root of the package. -->
<SourceProject></SourceProject>
</_FilteredNonWapProjProjectOutput>
</ItemGroup>
</Target>
<Target Name="GeneratePRIFileForUnpackagedApps" AfterTargets="CustomBuild">
<PropertyGroup>
<PRILanguages>x-generate</PRILanguages>
<MakePRIPath>"$(MSBuildProgramFiles32)\Windows Kits"\10\bin\10.0.18362.0\x86\</MakePRIPath>
<ConfigPRIFile>"$(TargetDir)config.xml"</ConfigPRIFile>
<OutputPRIFolder>"$(TargetDir)resources.pri"</OutputPRIFolder>
<ProjectRootPRI>"$(TargetDir)."</ProjectRootPRI>
<PackageManifestPath>$(ProjectDir)Package.appxmanifest</PackageManifestPath>
</PropertyGroup>
<!-- Create the config PRI File -->
<Exec Command="$(MakePRIPath)makepri createconfig /cf $(ConfigPRIFile) /dq $(PRILanguages) /o " />
<!-- Remove the packaging section from the PRI Confif file so there is just PRI for everything -->
<PreparePRIConfigFile ConfigPRIFileName="$(TargetDir)config.xml" />
<!-- Create the resources.PRI file -->
<Exec Command="$(MakePRIPath)makepri new /o /pr $(ProjectRootPRI) /cf $(ConfigPRIFile) /of $(OutputPRIFolder) /mn $(PackageManifestPath)" />
</Target>
<UsingTask TaskName="PreparePRIConfigFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<ConfigPRIFileName ParameterType="System.String" Required="false" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Using Namespace="System.Collections.Generic" />
<Using Namespace="System.IO" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Text" />
<Using Namespace="System.Xml" />
<Code Type="Fragment" Language="cs">
<![CDATA[
string xpath = "resources/packaging";
if (ConfigPRIFileName != null)
{
XmlDocument doc = new XmlDocument();
doc.Load(ConfigPRIFileName);
XmlNodeList nodes = doc.SelectNodes(xpath);
if (nodes.Count > 0)
{
for (int i = nodes.Count - 1; i >= 0; i--)
{
nodes[i].ParentNode.RemoveChild(nodes[i]);
}
doc.Save(ConfigPRIFileName);
}
}]]>
</Code>
</Task>
</UsingTask>
</Project>