|
-
November 17th, 2009, 11:10 AM
#1
Changing Assembly name at Build time
Hi all
I have an GUI application written in c# VS 2005. I want to be able to to modify the assembly name and other assembly information depending on the context in which the application is built. for example whether it is built as debug or release, or some other configuration.
I had thought of doing this as a prebuild step but have been unable to find any examples of this.
Anybody have any suggestions ?
any help would be appreciated
regards
simon
-
November 18th, 2009, 05:50 AM
#2
Re: Changing Assembly name at Build time
You can use #if compiler pragma in AssemblyInfo.cs too.
Something like
Code:
#if DEBUG
[assembly: AssemblyTitle("Debug build of application")]
#else
[assembly: AssemblyTitle("Application")]
#endif
should be possible. But keep in mind, that it has not to be compatible with some tasks for msbuild.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
November 19th, 2009, 12:02 PM
#3
Re: Changing Assembly name at Build time
You can also do this from the project file, which normally looks like this:
Code:
<PropertyGroup>
...
<AssemblyName>WindowsForms1</AssemblyName>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
</PropertyGroup>
You can add the assembly name to each configuration:
Code:
<PropertyGroup>
...
<AssemblyName>WindowsForms1</AssemblyName>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<AssemblyName>WindowsForms1D</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<AssemblyName>WindowsForms1R</AssemblyName>
</PropertyGroup>
-
November 20th, 2009, 02:55 AM
#4
Re: Changing Assembly name at Build time
But this change the name of the output file, not just the metainformation in it. I cannot now image a scenario where I'd use it, but is not bad to know it.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
November 20th, 2009, 06:22 AM
#5
Re: Changing Assembly name at Build time
Hi Boudino & Cilu
thanks for the replies. I put some conditional statements in the assemblyinfo.cs. Like you state this changes the assembly title etc which is half of what I wanted to achieve.
I also wanted to have the name of the exe changed as well, so I'll experiment with changing the project file.
thanks
simon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|