Igor Kondrasovas
Igor Kondrasovas

Reputation: 1681

How to change assembly name depending on configuration (and launch debugger)

I have a Visual Studio C# .exe project where I have edited the .csproj to define different assembly names depending on the build configuration:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ConfigADebug|AnyCPU'">
    <AssemblyName>MyNameA</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ConfigBDebug|AnyCPU'">
    <AssemblyName>MyNameB</AssemblyName>
</PropertyGroup>

This works fine during compilation, but when I change for example from ConfigADebug to ConfigBDebug on the IDE and start debugging, I get an error message that indicates MyNameA.exe was not found. But in reality, I am debuging MyNameB.exe

The only workaround I found so far (also mentioned in a comment in this thread) is to reload the project after changing the configuration.

Is there any way I can do that without having to reload the project?

Upvotes: 3

Views: 710

Answers (1)

Richard
Richard

Reputation: 109100

I suspect not.

MSBuild and project files allow far more flexibility than the Visual Studio IDE does. Somethings edited in the project file will work, but others not so much.

With Core projects you can have multiple debug settings – which can specify a different startup executable. You would need to change selected debug configuration alongside you target platform.

With Framework you can link configuration settings to the build configuration to set to launch an external program.

(This is for console projects, other project types vary.)

Upvotes: 1

Related Questions