Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the Assembly Name in C# Programmatically

Tags:

c#

assemblies

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?

like image 996
Muhammad Ummar Avatar asked Sep 15 '09 05:09

Muhammad Ummar


People also ask

What is the assembly name?

An assembly's name is stored in metadata and has a significant impact on the assembly's scope and use by an application. A strong-named assembly has a fully qualified name that includes the assembly's name, culture, public key, version number, and, optionally, processor architecture.

How do I find the name of an assembly?

Open Visual Studio Go to Tools –> External Tools –> Add Title: Get Qualified Assembly Name Command: Powershell.exe Arguments: -command "[System. Reflection. AssemblyName]::GetAssemblyName(\"$(TargetPath)\"). FullName" Check "Use Output Window".

What is assembly qualified name?

The assembly-qualified name of a type consists of the type name, including its namespace, followed by a comma, followed by the display name of the assembly. The display name of an assembly is obtained using the Assembly. FullName property.


1 Answers

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).

Note: if the assembly file name has space then insert $(TargetFileName) between two quotation, like this: "$(TargetFileName)"

like image 74
Thomas Avatar answered Oct 01 '22 20:10

Thomas