question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ruofanwang-ppcommented, Jan 6, 2021

Hi @ruofanwang-pp , sounds more like a GitHub issue than a .NET or WPF issue. Did you look already at the stuff at https://github.com/microsoft/github-actions-for-desktop-apps? Maybe it’s worth to post an issue there.

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

1reaction
davidathompsoncommented, Jan 22, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Console Window shown despite using OutputType WinExe ...
Is there a way to prevent that? Edit: It seems like the console window is only opened if the app is started in...
Read more >
Console output not working when using WinExe with ...
Set the OutputType to Exe. First execution after clean is still the DLL, and later executions use the EXE. Console works in both...
Read more >
OutputType set to WinExe for WPF and WinForms apps - . ...
When OutputType is set to WinExe , a console window doesn't open when the app is executed. Change description. In previous versions of...
Read more >
How to Conditionally Target WinExe
It turns out that when you specify -p:OutputType=WinExe , it happens globally. The property is propagated to all projects being built. So, your ......
Read more >
[DesktopGL + dotnet publish] Console window showing
Here's the setup : Monogame 3.8 DesktopGL .net core 6 self contained ... Check your csproj, you should change the output type to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found