CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    76

    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

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    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.

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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>
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    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.

  5. #5
    Join Date
    Jan 2003
    Posts
    76

    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
  •  





Click Here to Expand Forum to Full Width

Featured