{"id":395,"date":"2026-11-03T09:00:57","date_gmt":"2026-11-03T17:00:57","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/insidemsix\/?p=395"},"modified":"2026-11-03T18:52:21","modified_gmt":"2026-11-04T02:52:21","slug":"sparse-package","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/insidemsix\/sparse-package\/","title":{"rendered":"Sparse Package"},"content":{"rendered":"<p>We recently discussed <a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/msix-external-location\/\">External Location<\/a>\nand how it lets Windows find files referenced in <code>AppxManifest.xml<\/code> but installed by some other\n(not-MSIX) installer.<\/p>\n<p>Many people call this kind of package a &#8220;Sparse package&#8221;. Many even think sparse packages are the\nimportant feature, and External Location is a minor implementation detail.<\/p>\n<p>But&#8230;what is a sparse package?<\/p>\n<p>First, let&#8217;s create one.<\/p>\n<h2>HOWTO create a sparse package<\/h2>\n<p>At its simplest, a sparse package contains <code>AppxManifest.xml<\/code> and other\n<a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/msix-footprint-vs-payload-files\/\">footprint files<\/a>,\nand no payload files.<sup>1<\/sup> For example, here&#8217;s a simple manifest for a HelloWorld application:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;Package\n  xmlns=\"http:\/\/schemas.microsoft.com\/appx\/manifest\/foundation\/windows10\"\n  xmlns:uap=\"http:\/\/schemas.microsoft.com\/appx\/manifest\/uap\/windows10\"\n  xmlns:uap10=\"http:\/\/schemas.microsoft.com\/appx\/manifest\/uap\/windows10\/10\"\n  xmlns:rescap=\"http:\/\/schemas.microsoft.com\/appx\/manifest\/foundation\/windows10\/restrictedcapabilities\"\n  IgnorableNamespaces=\"uap uap10 rescap\"&gt;\n\n  &lt;Identity Name=\"HelloWorld\"\n            Publisher=\"CN=Contoso LLC, O=Contoso LLC, L=Paris, C=France\"\n            Version=\"1.2.3.4\"\n            ProcessorArchitecture=\"x64\" \/&gt;\n\n  &lt;Properties&gt;\n    &lt;uap10:AllowExternalContent&gt;true&lt;\/uap10:AllowExternalContent&gt;\n    &lt;DisplayName&gt;Hello World!&lt;\/DisplayName&gt;\n    &lt;PublisherDisplayName&gt;Contoso&lt;\/PublisherDisplayName&gt;\n    &lt;Logo&gt;logo.png&lt;\/Logo&gt;\n  &lt;\/Properties&gt;\n\n  &lt;Dependencies&gt;\n    &lt;TargetDeviceFamily Name=\"Windows.Universal\" MinVersion=\"10.0.19041.0\" MaxVersionTested=\"10.0.28000.0\" \/&gt;\n  &lt;\/Dependencies&gt;\n\n  &lt;Applications&gt;\n    &lt;Application Id=\"app\" Executable=\"helloworld.exe\" uap10:TrustLevel=\"mediumIL\" uap10:RuntimeBehavior=\"packagedClassicApp\"&gt;\n      &lt;uap:VisualElements DisplayName=\"Hello World!\" Square150x150Logo=\"logo.png\" Square44x44Logo=\"logo.png\" Description=\"Say hello\" BackgroundColor=\"#222222\"&gt;\n      &lt;\/uap:VisualElements&gt;\n    &lt;\/Application&gt;\n  &lt;\/Applications&gt;\n\n  &lt;Capabilities&gt;\n    &lt;rescap:Capability Name=\"runFullTrust\" \/&gt;\n  &lt;\/Capabilities&gt;\n&lt;\/Package&gt;\n<\/code><\/pre>\n<p>The manifest declares <code>&lt;uap10:AllowExternalContent&gt;true&lt;\/uap10:AllowExternalContent&gt;<\/code>, indicating it\nis intended for installation with an External Location.<\/p>\n<p>Let&#8217;s create a PowerShell script to make a signed package with our manifest:<\/p>\n<pre><code class=\"powershell\"># Where to find inputs, a temporary workspace and save output\n$sourcedir = 'C:\\Projects\\HelloWorld'\n$workdir = \"$env:TEMP\\HelloWorldFiles\"\n$msix = 'C:\\Projects\\HelloWorld\\Packages\\HelloWorld.msix'\n$cert = 'C:\\Secrets\\Contoso.pfx'\n\n# Create the temporary workspace containing our input files\nmkdir $workdir\ncopy \"$sourcedir\\AppxManifest.xml\" $workdir\ncopy \"$sourcedir\\logo.png\" $workdir\n\n# Create and sign the package\nmakeappx.exe pack \/o \/h SHA256 \/d $workdir \/p $msix \/nv\nsigntool.exe sign \/fd SHA256 \/f $cert \/p \"CertPasswordShhhDontTell\" $msix\n<\/code><\/pre>\n<p>Notice the <code>makeappx.exe<\/code> command includes the <code>\/nv<\/code> option. This command would normally fail as the\nmanifest references <code>helloworld.exe<\/code> but no such file is provided. The <code>\/nv<\/code> parameter disables that\nfile existence check. This allows us to create a package without those payload files, such as\n<code>helloworld.exe<\/code>.<\/p>\n<p>Looking inside the .msix file via PowerShell&#8230;<\/p>\n<pre><code class=\"powershell\">$zip = [System.IO.Compression.ZipFile]::OpenRead($msix)\ntry {\n    $zip.Entries | Select-Object FullName\n}\nfinally {\n    $zip.Dispose()\n}\n<\/code><\/pre>\n<p>Shows us&#8230;<\/p>\n<pre><code>FullName\n--------\nlogo.png\nAppxManifest.xml\nAppxBlockMap.xml\n[Content_Types].xml\nAppxSignature.p7x\n<\/code><\/pre>\n<p>This is effectively a signed manifest and logo with no <code>helloworld.exe<\/code> (as intended).<\/p>\n<p><a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/appxpkg\/make-appx-package--makeappx-exe-\">MakeAppx.exe<\/a>\nvalidates the contents, including that package-relative files referenced in <code>AppxManifest.xml<\/code> are\nprovided in the content directory (<code>\/d<\/code> parameter). Sparse packages are unusual because they\nintentionally bypass that particular validation using <code>\/nv<\/code>, allowing package-referenced payload to\nexist only in the External Location.<\/p>\n<h2>Do I have to omit payload files?<\/h2>\n<p>No. You can continue including <code>helloworld.exe<\/code> and other payload files in your .msix as usual. But\nWindows won&#8217;t use them.<\/p>\n<p>Since Windows won&#8217;t use those files you can safely omit them and shrink your otherwise much larger\npackage down to a few KB.<\/p>\n<h2>So&#8230;why &#8220;sparse&#8221;?<\/h2>\n<p>When External Location was first described, this &#8220;install payload files via (whatever) installer and\nomit them from the .msix&#8221; behavior was described as similar to\n<a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/fileio\/sparse-files\">NTFS sparse files<\/a>.\nThe file exists, but some of its contents wouldn&#8217;t be used, so that content can safely be omitted.\nThis makes the package rather tiny (usually a few KB) and simple to create.<\/p>\n<p>But never underestimate the power of a catchy name.<\/p>\n<p>People heard &#8220;it&#8217;s like a sparse package&#8221; and thought &#8220;Sparse package&#8221; was the feature.<\/p>\n<p>It wasn&#8217;t.<\/p>\n<p>External Location is the key feature. A sparse package is simply an optimization.<\/p>\n<p>And not always desirable.<\/p>\n<h2>When to be less &#8216;sparse&#8217;<\/h2>\n<p>Earlier I mentioned you <em>can<\/em> include payload files in your .msix, but <strong>Windows<\/strong> won&#8217;t use them.<\/p>\n<p>&#8220;Windows&#8221; being the operative word.<\/p>\n<p>Payload files included in your .msix will be\n<a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/staging-sharing-is-caring\/\">staged in a new package directory<\/a>\nas usual, with the package&#8217;s footprint files &#8211; and with the usual\n<a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/msix-chain-of-trust\/\">integrity protections and options<\/a>.<\/p>\n<p><strong>Windows<\/strong> won&#8217;t look for package referenced files in the package&#8217;s staged directory,\nbut you can &#8211; and for files not referenced in the manifest.<\/p>\n<p>For example, include a\n<a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/dsc\/overview?view=dsc-3.0\">DSCv3<\/a> resource definition\nin your sparse package and enable\n<a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/msix-chain-of-trust\/\">Package Integrity Content Enforcement<\/a>\nto make your DSC resource publisher-controlled and tamper-evident. This provides a higher degree of\nprotection than storing your DSC configuration file in your External Location or elsewhere on the\nsystem.<\/p>\n<p>In the <code>helloworld.exe<\/code> example, let&#8217;s assume you name your DSCv3 resource file <code>helloworld.dsc.resource.json<\/code>.<\/p>\n<p>You could include the file <code>helloworld.dsc.resource.json<\/code> in your .msix, install the rest of your\npayload via your other (not-MSIX) installer, install the package with an External Location pointing\nto that location, and use Windows APIs to locate the DSC file in your package&#8217;s install location.\nFor example:<\/p>\n<pre><code class=\"csharp\">string GetDscConfigFilename(string packageFamilyName)\n{\n    var packageManager = new Windows.Management.Deployment.PackageManager();\n    List&lt;Package&gt; packages =\n        packageManager.FindPackagesForUserWithPackageTypes(\n            \"\",\n            packageFamilyName,\n            PackageTypes.Main)?\n        .ToList()\n        ?? [];\n    if (packages.Count == 1)\n    {\n        return Path.Combine(packages[0].InstalledPath, \"helloworld.dsc.resource.json\");\n    }\n    else\n    {\n        return null;\n    }\n}\n<\/code><\/pre>\n<p>It doesn&#8217;t matter if a malicious actor drops a <code>helloworld.dsc.resource.json<\/code> file into your External Location.\nYou ignore it, as you only look at the file in the package&#8217;s Installed location.<\/p>\n<p>Sparse packages can intentionally contain selected payload that benefits from staging, integrity\nprotection, and publisher control.<\/p>\n<h2>TL;DR<\/h2>\n<p>External Location is the feature; a sparse package is merely one way of packaging for that feature,\nnot the feature itself.<\/p>\n<hr \/>\n<p><sup>1<\/sup> An exception to the rule is a sparse package must contain the payload file referenced by the\n<code>&lt;Package&gt;&lt;Properties&gt;&lt;Logo&gt;<\/code> element in <code>AppxManifest.xml<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently discussed External Location and how it lets Windows find files referenced in AppxManifest.xml but installed by some other (not-MSIX) installer. Many people call this kind of package a &#8220;Sparse package&#8221;. Many even think sparse packages are the important feature, and External Location is a minor implementation detail. But&#8230;what is a sparse package? First, [&hellip;]<\/p>\n","protected":false},"author":911,"featured_media":81,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[8,9,3,2,6,30,33,10,35],"class_list":["post-395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-msix","tag-architecture","tag-code","tag-deployment","tag-msix","tag-packagemanager","tag-packagevolume","tag-packaging","tag-terminology","tag-tools"],"acf":[],"blog_post_summary":"<p>We recently discussed External Location and how it lets Windows find files referenced in AppxManifest.xml but installed by some other (not-MSIX) installer. Many people call this kind of package a &#8220;Sparse package&#8221;. Many even think sparse packages are the important feature, and External Location is a minor implementation detail. But&#8230;what is a sparse package? First, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/users\/911"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":2,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":410,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts\/395\/revisions\/410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/media\/81"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}