Setting OutputType WinExe is not preventing a console host
See original GitHub issue.NET Core Version: (e.g. 3.0 Preview1, or daily build number, use dotnet --info
)
Docker image mcr.microsoft.com/dotnet/sdk:3.1)
Windows version: (winver
)
Github Hosted Environment
Winders Server 2019 - OS Version: 10.0.17763 Build 1637
Does the bug reproduce also in WPF for .NET Framework 4.8?: ~Yes/No~ Did not test
Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)? If yes, please file the issue via the instructions here. No, but it is working as intended when manually publishing on on my local machine (Windows 10 202h).
Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.
Problem description:
The project is using Microsoft.NET.Sdk.WindowsDesktop
with the OutputType
set to WinExe
. The produced executable from Github Workflow with Docker is opening the application with a console host.
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationIcon>Common\Images\favicon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
...
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.9" />
<PackageReference Include="ReactiveUI.Events.WPF" Version="11.5.35" />
<PackageReference Include="ReactiveUI.WPF" Version="11.5.35" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
<PackageReference Include="Splat.Microsoft.Extensions.DependencyInjection" Version="9.6.1" />
<PackageReference Include="Splat.Microsoft.Extensions.Logging" Version="9.6.1" />
<PackageReference Include="System.Linq.Async" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<Resource Include="Common\Fonts\39784E_0_0.ttf" />
<Resource Include="Common\Fonts\39784E_1_0.ttf" />
</ItemGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
... </ItemGroup>
</Project>
Actual behavior: The produced executable from our Github workflow is opening the application with a console host.
Expected behavior: The produced executable should not open a console host.
Minimal repro: 100% on 20+ runs.
- Same actual outputs with publishing profile
- Old docker image
mcr.microsoft.com/windows/servercore:ltsc2019
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks for your reply, @thomasclaudiushuber. I’ll also try to reproduce this issue without docker and straight with Github Actions. ~I’ll post an issue there, if the same actual behavior is reproduced.~
Building the application straight within the Github workflow is not reproducing this issue. It looks more like an issue with the docker image (mcr.microsoft.com/dotnet/sdk:3.1) and the application
@lindexi Thanks for the idea. Tried this as well. The same dotnet publish command will work fine on a regular machine but the same command, run inside the sdk container, will always show the console window.