WPF apps, published with dotnet publish with arguments -p:PublishTrimmed=true or /p:IncludeAllContentInSingleFile=true fails to run
See original GitHub issue- .NET Core Version: 3.0.103; 3.1.401; 5.0.100-preview.7
- Windows version: Windows 10 Pro x64, 2004 (19041.450)
- Does the bug reproduce also in WPF for .NET Framework 4.8?: No
- Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)?: No
Problem description: WPF apps, published with dotnet publish
with arguments -p:PublishTrimmed=true
or /p:IncludeAllContentInSingleFile=true
(not always, please, read below) fails to run.
Actual behavior: Nothing happens after trying to run the app.
Expected behavior: New window opens.
Minimal repro:
Here’s a simple pwsh
script to create a sample wpf-app and publish it. Some of apps runs (as expected), but some not, they’re noted in sript with comments.
dotnet new wpf -o test
Set-Location test
# Runs correctly
dotnet publish -c Release -r win-x64 -o Publish/5/Simple -f net5.0
dotnet publish -c Release -r win-x64 -o Publish/5/Include -f net5.0 /p:IncludeAllContentInSingleFile=true
dotnet publish -c Release -r win-x64 -o Publish/5/R2R -f net5.0 -p:PublishReadyToRun=true
dotnet publish -c Release -r win-x64 -o Publish/5/R2RSingle -f net5.0 -p:PublishReadyToRun=true -p:PublishSingleFile=true
dotnet publish -c Release -r win-x64 -o Publish/5/R2RSingleSelfC -f net5.0 -p:PublishReadyToRun=true -p:PublishSingleFile=true --self-contained true
# Publishes, but not runs
dotnet publish -c Release -r win-x64 -o Publish/5/Trim -f net5.0 -p:PublishTrimmed=true
dotnet publish -c Release -r win-x64 -o Publish/5/R2RSingleSelfCInclude -f net5.0 -p:PublishReadyToRun=true -p:PublishSingleFile=true --self-contained true /p:IncludeAllContentInSingleFile=true
dotnet publish -c Release -r win-x64 -o Publish/5/R2RSingleSelfCTrim -f net5.0 -p:PublishReadyToRun=true -p:PublishSingleFile=true --self-contained true -p:PublishTrimmed=true
Additional info: I must also say, that I’ve tested this script for netcoreapp3.0
and netcoreapp3.1
(with adding TargetFrameworks
to .csproj
and removing of /p:IncludeAllContentInSingleFile=true
, since it appeared in net5.0
) and the app still fails to run in same cases.
I’ve also tested this for dotnet new console
(Hello world) app and it seems to run correctly for all cases.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (4 by maintainers)
Top GitHub Comments
as base you use System.Runtime usually but it doesnt hurt do add these 2 others.
this will make most normal WPF apps to work
It wasnt merged at the release of RC1. Try https://dotnetcli.blob.core.windows.net/dotnet/Sdk/release/5.0.1xx/dotnet-sdk-latest-win-x64.exe or any other later version than RC1