.NET 5 RC2 WPF self-contained, single exe publish fails if its using assets from another .net 5 wpf project
See original GitHub issueWhen referring to a UserControl from another .net core 3.1 wpf project, the main project publish is successful.
When referring to a UserControl from another .net 5 wpf project, the main project publish fails, and outputs:
Could not copy the file “…\singlefilehost.exe” because it was not found.
Main project csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
Main project publish settings:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net5.0-windows\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net5.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
</Project>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7
Top Results From Across the Web
Single File publish doesn't work with a WPF app
There's no error, it just doesn't start. When I deploy the app without the "single file" option, the app works fine. I'm using...
Read more >Self-Contained Single-File does not produce a single file
Net 5 console application with no dependencies on third party components. I have set it up to publish as a self-contained single-file.
Read more >Publish single executable not working for .NET 5 or .NET 6
If the exe is moved to another folder it cannot be started. Publishing the WPF application as a single executable works for .NET...
Read more >Should I use self-contained or framework-dependent ...
In this post I compare the impact of the framework-dependent vs self-contained mode on Docker image size, taking layer caching into account.
Read more >Breaking change in publish for .net 5 - Developer Community
NET 5, it is no longer possible to generate single file executable in dotnet publish using default configuration.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good answer!!
Ok this is not enough, it was a coincidence I guess.
The workaround was :