Skip to content

Instantly share code, notes, and snippets.

@cnbluefire
Last active April 20, 2026 15:33
Show Gist options
  • Select an option

  • Save cnbluefire/bd08d855d8ca5b396cbb32c0e4af4ecd to your computer and use it in GitHub Desktop.

Select an option

Save cnbluefire/bd08d855d8ca5b396cbb32c0e4af4ecd to your computer and use it in GitHub Desktop.
Enable the "MSIX packaging" context menu in Visual Studio.
<Project>
<PropertyGroup>
<EnableMsixTooling>true</EnableMsixTooling>
<LogSDKReferenceResolutionErrorsAsWarnings>true</LogSDKReferenceResolutionErrorsAsWarnings>
<RuntimeIdentifier Condition="'$(Platform)' == 'x86'">win-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(Platform)' == 'win32'">win-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(Platform)' == 'x64'">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(Platform)' == 'arm64'">win-arm64</RuntimeIdentifier>
<_PublishProfileFileName>win-$(Platform).pubxml</_PublishProfileFileName>
<PublishProfile Condition="'$(_PublishProfileFileName)' != '' and Exists('$(MSBuildProjectDirectory)\Properties\PublishProfiles\$(_PublishProfileFileName)')">$(_PublishProfileFileName)</PublishProfile>
<MicrosoftWindowsSdkBuildToolsMSIXPackageVersion>*</MicrosoftWindowsSdkBuildToolsMSIXPackageVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
</PropertyGroup>
<ItemGroup Condition="'$(EnableMsixTooling)' == 'true'">
<ProjectCapability Include="WindowsXaml" />
<AvailableItemName Include="AppxManifest" />
</ItemGroup>
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PackageReference Include="Microsoft.Windows.SDK.BuildTools.MSIX" Version="$(MicrosoftWindowsSdkBuildToolsMSIXPackageVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PackageReference Include="Microsoft.Windows.SDK.BuildTools.MSIX">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<Target Name="_PackMsixCheckTargetFramework" Condition="'$([MSBuild]::IsTargetFrameworkCompatible(&apos;$(TargetFramework)&apos;, &apos;net8.0-windows10.0.22000.0&apos;)) != 'true'">
<Error Text="MSIX packaging requires a Windows-specific target framework. The current TargetFramework '$(TargetFramework)' is not compatible. Please set TargetFramework to 'net8.0-windows10.0.22000.0' or a later Windows TFM (e.g., net8.0-windows10.0.22621.0) in your project file." />
</Target>
<Target Name="_PackMsixRemoveRuntimeJsonFilesWhenPublishAot" BeforeTargets="_ComputeAppxPackagePayload" AfterTargets="PackagingOutputs" Condition="'$(_IsPublishAotTrueInsideTarget)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">
<ItemGroup>
<_RemoveRuntimeJsonFiles Include="@(PackagingOutputs)" Condition="'%(Filename)%(Extension)' == '$(AssemblyName).runtimeconfig.json'"/>
<_RemoveRuntimeJsonFiles Include="@(PackagingOutputs)" Condition="'%(Filename)%(Extension)' == '$(AssemblyName).deps.json'"/>
<PackagingOutputs Remove="@(_RemoveRuntimeJsonFiles)" />
</ItemGroup>
</Target>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity
Name="[YOUR PACKAGE NAME]"
Publisher="CN=[YOUR PUBLISHER NAME]"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="[NEW GUID]" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>[YOUR PACKAGE DISPLAY NAME]</DisplayName>
<PublisherDisplayName>[YOUR PUBLISHER DISPLAY NAME]</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="[YOUR APPLICATION DISPLAY NAME]"
Description="[YOUR APPLICATION DESCRIPTION]"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>arm64</Platform>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<SelfContained>true</SelfContained>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<SelfContained>true</SelfContained>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<SelfContained>true</SelfContained>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Content Include="Assets\**\*" />
</ItemGroup>
<PropertyGroup>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
<UapAppxPackageBuildMode>StoreAndSideload</UapAppxPackageBuildMode>
</PropertyGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment