sdk: Debugging for .NET Core does not calculate the output path correctly with TargetName
I’ve been using <TargetName>ActualOutputFileNameWithoutExtension</TargetName> as a good way to control the output filename independently from the assembly’s actual name. Once in a while, for style reasons, this is handy. Sometimes I’ll need a long namespace and matching assembly name containing the namespace, but the output file name looks kinda silly.
As @boriscallens discovered, when you try to debug, the executable path is not properly calculated and debugging does not start. I don’t know if he’s using the old or new csproj SDK, but I did discover an issue with the new project system:
I’ve always happened to use this in the new csproj and targeting .NET Framework, where the debug executable path is properly calculated. It’s when you target .NET Core that it stops working.
Runs and debugs as expected:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net47</TargetFramework>
<OutputType>exe</OutputType>
<TargetName>TestFilename</TargetName>
</PropertyGroup>
</Project>
Does not run or debug, unless you remove the <TargetName>:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp11</TargetFramework>
<OutputType>exe</OutputType>
<TargetName>TestFilename</TargetName>
</PropertyGroup>
</Project>
Specifically, my expectation would be that debugging would honor <TargetFileName> calculated in Microsoft.Common.CurrentVersion.targets.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 12
- Comments: 18 (7 by maintainers)
Commits related to this issue
- dotnet/sdk 2.1.700-preview-64015-02 (#11173) — committed to wli3/sdk by nguerrera 5 years ago
I looked into this, there’s SDK bugs here:
TargetNameTargetNameMoving over to the SDK.
Here is a simpler set of steps to reproduce the issue, but for running instead of debugging - hopefully the same fix for both.
Edit TargetNameIssue.csproj and add
<TargetName>CustomName</TargetName>within theProperyGroupsection.It would be great to see a fix released for this issue 🙂
Any chance of getting some love on this issue? Repro steps are well documented, and it’s been a few months. The StackOverflow link in the original report has some more info on motivation.
Repro Steps:
Expected:
Visual Studio will attach debugger to Debug_newname.exe and debugging session will start
Actual:
Visual Studio is unable to attach debugger to Debugnewname.exe because it is looking for DebugEXEIssue.exe.
The value in the ‘AssemblyName’ on the project properties is not updated based on the active configuration set in the Configuration manager.
It’s not exactly clear what fails; to route this to the correct component - can you fill out the following:
Repro Steps:
Expected:
Actual: