Debugging for .NET Core does not calculate the output path correctly with TargetName
See original GitHub issueI’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.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:16 (6 by maintainers)
Top GitHub Comments
I looked into this, there’s SDK bugs here:
TargetName
TargetName
Moving 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 theProperyGroup
section.It would be great to see a fix released for this issue 🙂