C# – MSBuild: How to override output filename to be different from Assembly Name


I have 2 C# projects in my solution, both of them DLLs:

  • MyApp.UI.WPF.csproj
  • MyApp.UI.WinForms.csproj

My setup process guarantees that only one of them will be installed at any given time. Whichever that might be, it will be picked up by the MyApp.exe bootstrapper when user runs the application.

Since both DLLs contain the same entry point, I'd like to keep the bootstrapper generic:

class Bootstrapper
    static void Main()
        var asm = Assembly.Load("MyApp.UI");

        // Execute the UI entry point here.

This means I have to give both DLLs the same Assembly Name in project options: "MyApp.UI". The problem is that MSBuild uses the Assembly Name as the output name which poses a conflict for me.

Is it possible to convince MSBuild to use a different filename instead, e.g. the project name?

Best Solution

You could add a <PostBuildEvent> to your build to rename your output assemblies to a common name.