Select to view content in your preferred language

Publish single executable not working for .NET 5 or .NET 6

7558
2
Jump to solution
01-24-2022 05:01 AM
mahj
by
Occasional Contributor

Publishing a WPF application as a single executable does not work for .NET 5 (using ArcGIS Runtime 100.12) or .NET 6 (using ArcGIS Runtime 100.13). There are 11 files and a folder in the target folder. The application can be started, but the map will not work. If the exe is moved to another folder it cannot be started.

Publishing the WPF application as a single executable works for .NET Core 3.1 (using ArcGIS Runtime 100.12).

I used Visual Studio 2022 (17.0.5) in all cases and the following publishing settings:

Configuration: Release | Any CPU
Target framework: net6.0-windows10.0.18362 / net5.0-window10.0.18362.0 / netcoreapp3.1
Deployment mode: Self-contained
Target runtime: win-x64
File publish options:
  Produce single file: Checked
  Enable ReadyToRun compilation. Unchecked
  Trim unused code: Unchecked

Have I missed something that needs to be changed for it to work with .NET 5 and .NET 6?

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
NathanCastle1
Esri Contributor

There was a change to the default behavior between .NET Core 3.1 and .NET 5.

Adding the following line to the ClickOnce .pubxml publish profile should solve the problem:

<IncludeAllContentForSelfExtract>True</IncludeAllContentForSelfExtract>

 

Visual Studio/ClickOnce still produces additional files alongside the single-file executable, but they aren't necessary to run the single file app.

Alternatively, if you disable the 'Produce Single File' option, the publish will work without IncludeAllContentForSelfExtract line.

Microsoft has documentation on single file deployments that you might find helpful: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file#including-native-libraries 

View solution in original post

2 Replies
NathanCastle1
Esri Contributor

There was a change to the default behavior between .NET Core 3.1 and .NET 5.

Adding the following line to the ClickOnce .pubxml publish profile should solve the problem:

<IncludeAllContentForSelfExtract>True</IncludeAllContentForSelfExtract>

 

Visual Studio/ClickOnce still produces additional files alongside the single-file executable, but they aren't necessary to run the single file app.

Alternatively, if you disable the 'Produce Single File' option, the publish will work without IncludeAllContentForSelfExtract line.

Microsoft has documentation on single file deployments that you might find helpful: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file#including-native-libraries 

mahj
by
Occasional Contributor

Thanks, now it works in both .NET 5 and .NET 6!

Tried adding IncludeNativeLibrariesForSelfExtract instead, but then the app could not be started.

Awesome that someone at MS realized that just checking the 'Produce single file' option without adding another magic option in the .pubxml file was too hard to use ;-). (*irony very much intended*)