tags:

views:

551

answers:

2

I want to change the name of my Assembly Programmatically in C#, there is a way through which I can change it from Project Properties, but I want to change it Programmatically, so that my output .exe name is changed.. Any trick for that?

+2  A: 

You could do this in the Post-Build Event. These scripts are commandline scripts that get executed after the Build process finished

ren $(TargetFileName) new-filename.exe

Edit:

You can configure the Postbuild Event by right-clicking on your Project in Visual Studio and selecting Properties. There you have a Tab called Buildevents. There is one for Prebuild and one for Postbuild. At the bottom you can select under what circumstances the Script should be run. This description assumes you are using Visual Studio 2008. The Events are also available in earlier versions, and the way to reach them should be similar (sorry, can't remember exactly howto).

Thomas Schreiner
Can you please tell me how to configure the Post Build Events??
Ummar
+1  A: 

In a post-build event, this should do the trick:

if <Condition> == <truevalue> xcopy output.dll newassembly.dll /y /s /d

To configure post-build events: right-click the project in Solution Explorer, click Properties, then click Build Events.

HiredMind