Recommended way of merging manifests for self-contained apps #4553
-
The documentation for making a self-contained app gives instructions on how to achieve this for a Visual Studio-based build, mainly, setting the following in the project configuration: <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> However, it is unclear what should be done with other build systems. Looking at the built artifacts and the nuget package content, it seems that merging the Windows App SDK manifest with the app manifest is required. However, the nuget package contains 2 sets of manifests:
The files in <file name="" /> However, the Visual Studio build goes a different route, based on the contents of the file at var headerF = @"<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<assembly manifestVersion='1.0'
xmlns:asmv3='urn:schemas-microsoft-com:asm.v3'
xmlns:winrtv1='urn:schemas-microsoft-com:winrt.v1'
xmlns='urn:schemas-microsoft-com:asm.v1'>";
var sb = new StringBuilder();
sb.AppendLine(headerF);
var dllFileFormat = RedirectDlls ?
@" <asmv3:file name='{0}' loadFrom='%MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY%{0}'>" :
@" <asmv3:file name='{0}'>";
if (!string.IsNullOrEmpty(InAppxManifest))
{
XmlDocument doc = new XmlDocument();
doc.Load(InAppxManifest);
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";
var dllFiles = (from di in (new DirectoryInfo(MsixContentDir).EnumerateFiles("*.dll")) select di.Name).ToList();
foreach (XmlNode winRTFactory in doc.SelectNodes(xQuery, nsmgr))
{
var dllFileNode = winRTFactory.SelectSingleNode("./m:Path", nsmgr);
var dllFile = dllFileNode.InnerText;
var typesNames = winRTFactory.SelectNodes("./m:ActivatableClass", nsmgr).OfType<XmlNode>();
sb.AppendFormat(dllFileFormat, dllFile);
sb.AppendLine();
foreach (var typeNode in typesNames)
{
var attribs = typeNode.Attributes.OfType<XmlAttribute>().ToArray();
var typeName = attribs
.OfType<XmlAttribute>()
.SingleOrDefault(x => x.Name == "ActivatableClassId")
.InnerText;
var xmlEntryFormat =
@" <winrtv1:activatableClass name='{0}' threadingModel='both'/>";
sb.AppendFormat(xmlEntryFormat, typeName);
sb.AppendLine();
dllFiles.Remove(dllFile);
}
sb.AppendLine(@" </asmv3:file>");
}
if(RedirectDlls)
{
foreach (var dllFile in dllFiles)
{
sb.AppendFormat(dllFileFormat, dllFile);
sb.AppendLine(@"</asmv3:file>");
}
}
}
sb.AppendLine(@"</assembly>");
var manifestContent = sb.ToString();
File.WriteAllText(OutAppManifest, manifestContent, Encoding.UTF8); This seemingly reads the Questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Since I'm not in a position to answer 1 and 2, I won't even attempt to.
--Edit-- |
Beta Was this translation helpful? Give feedback.
Since I'm not in a position to answer 1 and 2, I won't even attempt to.