Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run .exe file in publish folder after publish wpf app using cmd "dotnet publish -r win-x64 -c Release --self-contained true /p:PublishTrimmed=true " #9274

Closed
MelonWang1 opened this issue Jun 21, 2024 · 2 comments

Comments

@MelonWang1
Copy link

MelonWang1 commented Jun 21, 2024

Description

The wpfapp1.exe file cannot be run using cmd or by double clicking in File Explorer after publish wpf app using cmd "dotnet publish -r win-x64 -c Release --self-contained true /p:PublishTrimmed=true ".

Reproduction Steps

  1. Installer latest .NET 9.0 SDK
  2. dotnet new wpf
  3. Add below code to.csproj file

<_SuppressWpfTrimError>true</_SuppressWpfTrimError>

  1. Add nuget.config file to wpf application
<configuration>
  <packageSources>
    <add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
  </packageSources>
</configuration>
  1. dotnet publish -r win-x64 -c Release --self-contained true /p:PublishTrimmed=true
  2. cd C:\wpfapp\bin\Release\net9.0-windows\win-x64\publish
  3. .\wpfapp1.exe or double click wpfapp1.exe

Expected behavior

Run wpfapp1.exe succssfully.

Actual behavior

The wpfapp1.exe file cannot be run using cmd or by double clicking in File Explorer. Event Viewer has the application error.
Screenshot 2024-06-21 085606

If using cmd "dotnet publish -r win-x64 -c Release --self-contained true" to publish, the .exe file can run successfully.
wpf- no trim

Regression?

This issue cannot repro in .NET 3.1.

Configuration

.NET SDK 9.0.100-preview.6.24320.9

OS: Win11 23H2 X64

@lindexi
Copy link
Contributor

lindexi commented Jun 21, 2024

Thank you for you feedback @MelonWang1

But duplicate of #3811

As I said in #3811 (comment) , you can use https://github.com/yangzhongke/Zack.DotNetTrimmer to trim your wpf project.

@pchaurasia14
Copy link
Member

Thanks @lindexi.
Closing this as duplicate of #3811

@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants