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.

PackAsTool true breaks debugging in Visual Studio when project is WPF

See original GitHub issue

I’m writing a tool application that uses WPF. It is intended to be called from console, but it shows graphics that cannot be represented by text, therefore I need WPF. It works fine in .NET Framework, but when migrating to .NET Core, when I add <PackAsTool>true</PackAsTool>, VS2019 cannot debug it anymore, saying:

The debug executable ‘c:\path\to\mytool.exe’ specified in ‘mytool’ debug profile does not exist.

This might be a VS2019 issue (as you are probably thinking right now 😉), however it seems that when <PackAsTool>true</PackAsTool> is added to the .csproj, it changes the output type to dll, even though the project says it’s WinExe:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWPF>true</UseWPF>
    <PackageType>DotnetTool</PackageType>
    <PackAsTool>true</PackAsTool>
  </PropertyGroup>

</Project>

This is bad because I cannot use the simplicity of <PackAsTool>true</PackAsTool> for publishing and installation (i.e. have an automatic shim installed to path).

Even if I ignore the VS limitation, I’m also not sure if a DLL would work as expected for a WPF project. My understanding is that WPF requires WinExe for certain features.

Here’s my dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview3-010431
 Commit:    d72abce213

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\

Host (useful for support):
  Version: 3.0.0-preview3-27503-5
  Commit:  3844df9537

.NET Core SDKs installed:
  2.1.601 [C:\Program Files\dotnet\sdk]
  2.2.103 [C:\Program Files\dotnet\sdk]
  3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview3-27504-2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

And this is my VS version:

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wli3commented, Jul 29, 2019

RunCommand is fixed by https://github.com/dotnet/sdk/pull/3212

But there is still a bug on due to lack of an apphost during build, PE bits do not takes effect during debug(works after install and run the app).

Talked to @nguerrera, we think a better solution is to generate apphost during build, but does not pack it

1reaction
fernacolocommented, Mar 19, 2019

Just FYI, I was able to mitigate by doing this:

<PackAsTool Condition="'$(BuildingInsideVisualStudio)'!='true'">true</PackAsTool>

Yet I think the issue is prevalent. Just not sure if this is dotnet/sdk or VS2019 issue. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging WPF - Visual Studio (Windows)
Visual Studio can receive debug trace information from WPF applications and display that information in the Output window. This topic describes ...
Read more >
WPF main window not showing for Debug build
I'm working on a C# project with WPF in Visual Studio. My application was building and running perfectly yesterday. As far as I...
Read more >
WPF - Debugging
It is a systematic mechanism of identifying and fixing the bugs or defects in a piece of code which are not behaving the...
Read more >
Changes in the foreach package - Category Name
Debugging without a symbol file would make it difficult to set breakpoints on a specific line of code or even step through code....
Read more >
Journal – .NET Development Addict
I decided to follow the pattern of UWP and WPF and place our “generic” control template in the “Themes\Generic.xaml” file. Because there is...
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