dotnet / dotnet/wpf

"Trim unused assemblies (in preview)" Publish option causes simple WPF app to crash immediately upon launching

Open
#2,416 24 comments 1 reaction 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.1.100 Commit: cd82f021f4
* Windows version: Windows 10 v1909 OS Build 18363.476)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Unknown
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? Probably not, but I am Publishing using Visual Studio.

**Problem description:**
A minimal .NET Core 3.1 WPF app with publish options "Produce Single File" and "Trim unused assemblies (in preview)" checked -> crashes immediately upon launching.

If I republish **without** checking "Trim unused assemblies (in preview)", it launches just fine.

**Actual behavior:**
Nothing appears to happen when executing the WpfCoreApp.exe file.

EventViewer says:
Description: A .NET Core application failed.
Application: WpfCoreApp.exe
Path: C:\code\WpfCoreApp\bin\Release\netcoreapp3.1\publish\WpfCoreApp.exe
Message: The application to execute does not exist: 'C:\Users\bignis\AppData\Local\Temp\.net\WpfCoreApp\gusxieru.uvn\WpfCoreApp.dll'.

**Expected behavior:**
A simple app with a few buttons appears

**Minimal repro:**
In Visual Studio 2019 v16.4.2, load the source code of this simple WPF app =
[WpfAppSourceCode.zip](https://github.com/dotnet/wpf/files/4048255/WpfAppSourceCode.zip)

Use these publish settings
![image](https://user-images.githubusercontent.com/1821535/72189975-e6ada380-33c3-11ea-9806-0439a40eb7f2.png)

and run the file \bin\Release\netcoreapp3.1\publish\WpfCoreApp.exe

nothing will happen and the error appears in the EventViewer.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.