How to Deploy a single-file .NET 6 WPF app:
Right-click on the WPF application project in the Solution Explorer and select Edit Project File
Add the following line to the <PropertyGroup>
element in the .csproj
file:
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
Right-click on the project in the Solution Explorer and select Publish
Set the Deployment mode to Self-contained under the Target Runtime settings
Select win-* as the Target runtime
Check the Produce single file option under File publish options
Click on Save and then on Publish
Copy the contents of the Target location to the target machine and run the app`
.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<IncludeNativeLibrariesForSelfExtract >true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
</Project>
FolderProfile.pubxml:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>
</Project>