C
C#16mo ago
Ossie

✅ .EXE works in release but not publish?

Hi, I have a WPF application, and I have made some stuff with the notification area (system tray), I tried yesterday to do it with <UseWinForms>true<UseWinForms>, and everything worked perfectly when building with release. but when I build with publish, it doesn't work. And I know its because of the WinForms thing, since if i removed it, it launched fine. Then I found a nuget package today, which can do the system tray things, but now, again, it doesn't wanna run in publish, but it again runs just fine in release. I use the following settings in my PublishProfile:
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
This is my csproj:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
<ApplicationIcon>henry.ico</ApplicationIcon>
<_SuppressWpfTrimError>true</_SuppressWpfTrimError>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
<ApplicationIcon>henry.ico</ApplicationIcon>
<_SuppressWpfTrimError>true</_SuppressWpfTrimError>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
Is there some way I can debug it to figure out why it doesn't work, it is really pissing me off that it doesn't work when I publish it... but for some reason works when I build it for release
1 Reply
Ossie
OssieOP16mo ago
Turning off PublishSingleFile fixes it, but why...? 😦 I need it as a single file I fixed it with IncludeAllContentForSelfExtract set to true, after finding the remark of it maybe fixing combatability problems https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli
Want results from more Discord servers?
Add your server