Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change assembly name based on configuration (Visual Studio 2005/2008)

Is it possible to change the assembly name based on the project configuration?

I have tried conditional pragmas on the assemblyinfo.cs file, but that only changes the assembly attributes, not the name itself.

like image 832
Rob Hunter Avatar asked May 21 '09 13:05

Rob Hunter


People also ask

How do I rename an assembly in visual studio?

visual studio change assembly name * Right-click the project again and select Properties. Change the "Assembly name" and "Default namespace" on the Application tab. * Right-click the project again and select Refactor -> Adjust Namespaces. Accept the changes.

What is assembly name in VB net?

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.

Where is the assembly name visual studio?

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


1 Answers

If you right click on your project and choose "Edit Project File" (I'm in 2008 here and it may be a new option, if it is then just open the project file in any old text editor) you should see something similar to the following:

  <PropertyGroup>     ...     <AssemblyName>ClassLibrary1</AssemblyName>     ...   </PropertyGroup>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">     ...   </PropertyGroup>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">     ...   </PropertyGroup> 

Basically any properties that aren't overriden in a more specific property group are inherited from the more general, first group. So to achieve what you want just edit the file so that the AssemblyName tag is defined in each of the specific groups:

  <PropertyGroup>     ...     <AssemblyName>ClassLibrary1</AssemblyName>     ...   </PropertyGroup>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">     ...     <AssemblyName>ClassLibrary1Debug</AssemblyName>   </PropertyGroup>   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">     ...     <AssemblyName>ClassLibrary1Release</AssemblyName>   </PropertyGroup> 

This will change the assembly name on a per config basis.

like image 184
Martin Harris Avatar answered Sep 25 '22 05:09

Martin Harris