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:
```c#
Does not run or debug, unless you remove the `<TargetName>`:
```c#
<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.
Can someone point me to where I should ask the same for old csproj? It also calculates <TargetFileName> based on <TargetName>, and the debugger for that project system has the same problem as the .NET Core debugger in the new csproj.
@jnm2 We track both in this repo.
Also, every time you start debugging a new csproj .NET Framework console app, it creates .runtimeconfig.json and .runtimeconfig.dev.json files which do not match the target name.
Just had another case today where I'm creating a tool with projects ToolName, ToolName.Console, ToolName.MSBuild, etc, and I want the ToolName.Console project's assembly name to be ToolName.Console while the output name is ToolName.exe.
@srivatsn and @basoundr so is no one tracking or assigned to this issue?
@bruceburge we're tracking all of these issues, but focused more on performance and significant blocking issues at the moment. @nguerrera - if the .runtimeconfig.json is generated with the wrong name, that sounds like an SDK issue, right? It's possible that fixing that will fix the debugging too...
@Pilchie I appreciate that, just saw that someone had been assigned and unassigned with no one attached to it. Thanks for that clarification, and hopefully this will spark a solution to this issue.
@nguerrera - if the .runtimeconfig.json is generated with the wrong name, that sounds like an SDK issue, right? It's possible that fixing that will fix the debugging too...
Yes. That would be an SDK issue.
Filed https://github.com/dotnet/sdk/issues/2252 for the incorrect runtimeconfig files.
Any update on this? I'm having the same issue with a c# Winforms app. I change the AssemblyName based on a configuration condition, and it fails when I change AssemblyName to something other than that specified in the csproj file. I have tried removing
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug NotMyAssemblyName|AnyCPU' ">
<AssemblyName>NotMyAssemblyName</AssemblyName>
..
</PropertyGroup>
It's not exactly clear what fails; to route this to the correct component - can you fill out the following:
Repro Steps:
Expected:
Actual:
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.
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.
Have to change AssemblyName. Waiting for solution. Thank you!
I looked into this, there's SDK bugs here:
1) The generated host exe does not respect TargetName
2) The generated runtimeconfig and deps.json does not respect TargetName

Moving over to the SDK.
Most helpful comment
I looked into this, there's SDK bugs here:
1) The generated host exe does not respect
TargetName2) The generated runtimeconfig and deps.json does not respect
TargetNameMoving over to the SDK.