Skip to content

PackAsTool true breaks debugging in Visual Studio when project is WPF #3023

@fernacolo

Description

@fernacolo

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions