234 строки
10 KiB
XML
234 строки
10 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<PropertyGroup>
|
|
<DefaultTargetPlatformVersion Condition="'$(DefaultTargetPlatformVersion)'==''">18362</DefaultTargetPlatformVersion>
|
|
<AssetTargetFallback Condition="'$(AssetTargetFallback)'==''">uap10.0.$(DefaultTargetPlatformVersion)</AssetTargetFallback>
|
|
|
|
<!-- Up-to-date check fails for Xaml Islands projects: -->
|
|
<!-- https://github.com/dotnet/project-system/issues/5543 -->
|
|
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
|
|
|
<_PlatformShortName_>$(Platform)</_PlatformShortName_>
|
|
<_PlatformShortName_ Condition="'$(_PlatformShortName_)'=='Win32'">x86</_PlatformShortName_>
|
|
<_NetCoreUWP_NuGetPackageId>runtime.win10-$(_PlatformShortName_).Microsoft.NETCore.UniversalWindowsPlatform</_NetCoreUWP_NuGetPackageId>
|
|
<_NetCoreUWP_AOT_NuGetPackageId>runtime.win10-$(_PlatformShortName_)-aot.Microsoft.NETCore.UniversalWindowsPlatform</_NetCoreUWP_AOT_NuGetPackageId>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(DesignTimeBuild)' == 'true'">
|
|
<_DisableAppxCopy>true</_DisableAppxCopy>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<_TargetPlatformVersion Condition="$(_TargetPlatformVersion)==''">10.0.18362.0</_TargetPlatformVersion>
|
|
<ManifestTool Condition="Exists('$(MSBuildThisFileDirectory)\..\tools\mt.exe')">$(MSBuildThisFileDirectory)\..\tools\mt.exe</ManifestTool>
|
|
<ManifestTool Condition="'$(ManifestTool)'==''">$(MSBuildProgramFiles32)\Windows Kits\10\bin\$(_TargetPlatformVersion)\x86\mt.exe</ManifestTool>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IntDir)'==''">
|
|
<IntDir>$(BaseIntermediateOutputPath)\$(Platform)\$(Configuration)\$(TargetFramework)\</IntDir>
|
|
</PropertyGroup>
|
|
<ItemGroup>
|
|
<PackageReference Include="Microsoft.VCRTForwarders.140" Version="1.0.6" />
|
|
</ItemGroup>
|
|
|
|
<Target Name="_GetUWPAppPayload">
|
|
<CreateItem Include="@(ProjectReference)" Condition="Exists('%(RelativeDir)\Package.appxmanifest')">
|
|
<Output ItemName="_AppxProject" TaskParameter="Include"/>
|
|
</CreateItem>
|
|
<MSBuild Projects="@(_AppxProject)"
|
|
Properties="Configuration=$(Configuration);Platform=$(Platform)"
|
|
Targets="Build;GetPackagingOutputs">
|
|
<Output TaskParameter="TargetOutputs" ItemName="_AppxBuildOutputPaths" />
|
|
</MSBuild>
|
|
|
|
<CreateItem Include="%(_AppxBuildOutputPaths.Identity)"
|
|
Condition="'%(_AppxBuildOutputPaths.TargetPath)'!=''"
|
|
AdditionalMetadata="FinalTargetPath=$(OutDir)%(_AppxBuildOutputPaths.TargetPath);TargetPath=%(_AppxBuildOutputPaths.TargetPath)">
|
|
<Output ItemName="_AppxInputs" TaskParameter="Include"/>
|
|
</CreateItem>
|
|
|
|
<CreateItem Include="%(_AppxBuildOutputPaths.RelativeDir)AppxManifest.xml" Condition="Exists('%(_AppxBuildOutputPaths.RelativeDir)AppxManifest.xml')">
|
|
<Output ItemName="AppxManifest" TaskParameter="Include"/>
|
|
</CreateItem>
|
|
|
|
<CreateProperty Value="$(IntDir)Manifests\app.manifest">
|
|
<Output
|
|
TaskParameter="Value"
|
|
PropertyName="GeneratedApplicationManifest" />
|
|
</CreateProperty>
|
|
<CreateProperty Value="$(IntDir)Manifests\mergeapp.manifest">
|
|
<Output
|
|
TaskParameter="Value"
|
|
PropertyName="MergedApplicationManifest" />
|
|
</CreateProperty>
|
|
|
|
</Target>
|
|
|
|
<Target Name="CopyAllProjectReferencesOutputs"
|
|
DependsOnTargets="_GetUWPAppPayload;ResolveReferences"
|
|
Inputs="@(_AppxInputs)"
|
|
Outputs="@(_AppxInputs->'%(FinalTargetPath)')"
|
|
Condition="'$(_DisableAppxCopy)'==''">
|
|
|
|
<CreateItem Include="@(_AppxBuildOutputPaths)"
|
|
Condition="'%(_AppxBuildOutputPaths.TargetPath)'!='' and
|
|
'%(_AppxBuildOutputPaths.NuGetPackageId)'!='$(_NetCoreUWP_AOT_NuGetPackageId)' and
|
|
'%(_AppxBuildOutputPaths.NuGetPackageId)'!='$(_NetCoreUWP_NuGetPackageId)' "
|
|
AdditionalMetadata="Link=%(_AppxBuildOutputPaths.TargetPath)">
|
|
<Output ItemName="_AppxBuildOutputs" TaskParameter="Include"/>
|
|
</CreateItem>
|
|
|
|
<CreateItem Include="@(_AppxBuildOutputs)" >
|
|
<Output ItemName="_AppxAllItems" TaskParameter="Include"/>
|
|
</CreateItem>
|
|
<CreateItem Include="@(_AppxAllItems)" AdditionalMetadata="CopyToOutputDirectory=PreserveNewest">
|
|
<Output ItemName="Content" TaskParameter="Include"/>
|
|
</CreateItem>
|
|
|
|
<WriteLinesToFile
|
|
File="$(IntDir)\AppUWP.payload"
|
|
Lines="@(_AppxBuildOutputPaths)"
|
|
Overwrite="true"
|
|
Encoding="Unicode"/>
|
|
</Target>
|
|
|
|
<UsingTask TaskName="GenerateWinRTManifestFromAppx" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
|
<ParameterGroup>
|
|
<AppxManifest ParameterType="System.String" Required="false" />
|
|
<DestinationFolder ParameterType="System.String" Required="true" />
|
|
</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[
|
|
var headerF = @"<?xml version='1.0' encoding='utf-8' standalone='yes'?>
|
|
<assembly
|
|
manifestVersion='1.0'
|
|
xmlns:asmv3='urn:schemas-microsoft-com:asm.v3'
|
|
xmlns='urn:schemas-microsoft-com:asm.v1'>
|
|
<trustInfo xmlns='urn:schemas-microsoft-com:asm.v2'>
|
|
<security>
|
|
<requestedPrivileges xmlns='urn:schemas-microsoft-com:asm.v3'>
|
|
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
|
</requestedPrivileges>
|
|
</security>
|
|
</trustInfo>
|
|
<compatibility xmlns='urn:schemas-microsoft-com:compatibility.v1'>
|
|
<application>
|
|
<maxversiontested Id='10.0.18362.0'/>
|
|
<supportedOS Id='{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}' />
|
|
</application>
|
|
</compatibility>
|
|
<application xmlns='urn:schemas-microsoft-com:asm.v3'>
|
|
<windowsSettings>
|
|
<dpiAware xmlns='http://schemas.microsoft.com/SMI/2005/WindowsSettings'>true/PM</dpiAware>
|
|
<dpiAwareness xmlns='http://schemas.microsoft.com/SMI/2016/WindowsSettings'>PerMonitorV2, PerMonitor</dpiAwareness>
|
|
</windowsSettings>
|
|
</application>";
|
|
var sb = new StringBuilder();
|
|
sb.Append(headerF);
|
|
|
|
bool foundXamlHost = false;
|
|
if (!string.IsNullOrEmpty(AppxManifest))
|
|
{
|
|
XmlDocument doc = new XmlDocument();
|
|
doc.Load(AppxManifest);
|
|
var nsmgr = new XmlNamespaceManager(doc.NameTable);
|
|
nsmgr.AddNamespace("m", "http://schemas.microsoft.com/appx/manifest/foundation/windows10");
|
|
var xQuery = "./m:Package/m:Extensions/m:Extension/m:InProcessServer";
|
|
|
|
foreach (XmlNode winRTFactory in doc.SelectNodes(xQuery, nsmgr))
|
|
{
|
|
var dllPathNode = winRTFactory.SelectSingleNode("./m:Path", nsmgr);
|
|
var dllPath = dllPathNode.InnerText;
|
|
if (!foundXamlHost)
|
|
{
|
|
foundXamlHost = String.Compare(dllPath, "Microsoft.Toolkit.Win32.UI.XamlHost.dll", true) == 0;
|
|
}
|
|
var typesNames = winRTFactory.SelectNodes("./m:ActivatableClass", nsmgr).OfType<XmlNode>();
|
|
var xmlHeader = String.Format(@" <asmv3:file name='{0}'>", dllPath);
|
|
sb.Append(xmlHeader);
|
|
foreach (var typeNode in typesNames)
|
|
{
|
|
var attribs = typeNode.Attributes.OfType<XmlAttribute>().ToArray();
|
|
var typeName = attribs
|
|
.OfType<XmlAttribute>()
|
|
.SingleOrDefault(x => x.Name == "ActivatableClassId")
|
|
.InnerText;
|
|
var xmlEntry = String.Format(@"
|
|
<activatableClass
|
|
name='{0}'
|
|
threadingModel='both'
|
|
xmlns='urn:schemas-microsoft-com:winrt.v1'/>
|
|
", typeName);
|
|
sb.Append(xmlEntry);
|
|
}
|
|
var xmlFooter = @"
|
|
</asmv3:file>
|
|
";
|
|
sb.Append(xmlFooter);
|
|
}
|
|
}
|
|
if (!foundXamlHost)
|
|
{
|
|
sb.Append(@"
|
|
<asmv3:file name='Microsoft.Toolkit.Win32.UI.XamlHost.dll'>
|
|
<activatableClass
|
|
name='Microsoft.Toolkit.Win32.UI.XamlHost.XamlApplication'
|
|
threadingModel='both'
|
|
xmlns='urn:schemas-microsoft-com:winrt.v1'/>
|
|
</asmv3:file>");
|
|
}
|
|
var xmlFooterF = @"
|
|
</assembly>";
|
|
sb.Append(xmlFooterF);
|
|
var manifestContent = sb.ToString();
|
|
var outFileName = Path.Combine(DestinationFolder, "app.manifest");
|
|
File.WriteAllText(outFileName, manifestContent, Encoding.UTF8);
|
|
]]>
|
|
</Code>
|
|
</Task>
|
|
</UsingTask>
|
|
|
|
<Target Name="CreateWinRTRegistration"
|
|
AfterTargets="ResolveReferences"
|
|
DependsOnTargets="CopyAllProjectReferencesOutputs"
|
|
Inputs="@(AppxManifest);$(ApplicationManifest)"
|
|
Outputs="$(MergedApplicationManifest)"
|
|
Condition="'$(_DisableAppxCopy)'==''">
|
|
<MakeDir Directories="$(IntDir)\Manifests\" />
|
|
<GenerateWinRTManifestFromAppx AppxManifest="@(AppxManifest)" DestinationFolder="$(IntDir)\Manifests\" />
|
|
<CreateItem Include="$(IntDir)Manifests\*.manifest">
|
|
<Output
|
|
TaskParameter="Include"
|
|
ItemName="Manifest"/>
|
|
</CreateItem>
|
|
<Exec
|
|
Condition="Exists('$(ApplicationManifest)')"
|
|
Command=""$(ManifestTool)" -nologo -manifest "$(MSBuildProjectDirectory)\$(GeneratedApplicationManifest)" "$(MSBuildProjectDirectory)\$(ApplicationManifest)" -out:"$(MSBuildProjectDirectory)\$(MergedApplicationManifest)""
|
|
WorkingDirectory="$(MSBuildProjectDirectory)" >
|
|
</Exec>
|
|
<CreateProperty
|
|
Condition="!Exists('$(ApplicationManifest)')"
|
|
Value="$(GeneratedApplicationManifest)">
|
|
<Output
|
|
TaskParameter="Value"
|
|
PropertyName="MergedApplicationManifest" />
|
|
</CreateProperty>
|
|
|
|
<CreateProperty Value="$(MergedApplicationManifest)">
|
|
<Output
|
|
TaskParameter="Value"
|
|
PropertyName="ApplicationManifest" />
|
|
</CreateProperty>
|
|
</Target>
|
|
|
|
</Project>
|