Tutorial :MSBuild: How to override output filename to be different from Assembly Name?



Question:

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?


Solution:1

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


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »