tags:

views:

658

answers:

2

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?

+1  A: 

This would be a function of the CoreCompile task, you would have to override it to modify the /out switch on csc. This is not recommended practice but would achieve your goal.

Adam Fyles
+2  A: 

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

Clive
That's what I ended up doing. I also added a pre-build event that deletes the target file if it already exists. Rename would sometimes fail without this.
aoven