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?
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.
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".
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.
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
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)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With