.NET Framework Developer Center > .NET Development Forums > Windows Workflow Foundation > Re-hosting, how-to change version number of generated assembly
Ask a questionAsk a question
 

AnswerRe-hosting, how-to change version number of generated assembly

  • Thursday, September 24, 2009 5:55 AMMasus_84 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi everyone!

    I know this question is somewhat off-topic for this forum but atleast it is related:)

    I've got the re-hosting of the workflow designer to work but when I compile the workflow I would like to change the versio number of the generated assembly (default seems to be 0.0.0.0). 

    Is there any good way of doing this?

    Best regards!

Answers

  • Wednesday, September 30, 2009 5:46 AMAndrew_ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,Marcus

    If you are using Visual Studio, there is a AssemblyInfo.cs file in your project, open this file, and you can change the version info here. then rebuild the project.
    Also Check this thread:
    http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/b3106ede-8028-46fe-b8bb-dbf66e4d2e93
    Microsoft Online Community Support
  • Friday, October 30, 2009 9:48 AMMasus_84 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Managed to solve it. By adding a CodeAttributeDeclaration in the CodeCompileUnit.AssemblyCustomAttributes collection I managed to get the [assembly:] attribute to be generated along with the code.

    Here is the code I used:

    public static CodeCompileUnit UpdateAssemblyInformation(CodeCompileUnit unit, String description, String version)
    {
        CodeAttributeArgument[] versionArguments = new CodeAttributeArgument[1];
        versionArguments[0] = new CodeAttributeArgument(
            new CodePrimitiveExpression(version));
    
        CodeAttributeDeclaration assemblyVersion = new CodeAttributeDeclaration(
            new CodeTypeReference(ASSEMBLY_VERSION), versionArguments);
    
        CodeAttributeDeclaration assemblyFileVersion = new CodeAttributeDeclaration(
           new CodeTypeReference(ASSEMBLY_FILEVERSION), versionArguments);
    
        unit.AssemblyCustomAttributes.Add(assemblyVersion);
        unit.AssemblyCustomAttributes.Add(assemblyFileVersion);
    
        CodeAttributeArgument[] descriptionArguments = new CodeAttributeArgument[1];
        descriptionArguments[0] = new CodeAttributeArgument(
            new CodePrimitiveExpression(description));//Create parameter for attribute 
    
        CodeAttributeDeclaration assemblyDescription = new CodeAttributeDeclaration(
            new CodeTypeReference(ASSEMBLY_DESCRIPTION), descriptionArguments);
    
        unit.AssemblyCustomAttributes.Add(assemblyDescription);
        return unit;
    }

    • Marked As Answer byMasus_84 Friday, October 30, 2009 9:48 AM
    •  

All Replies

  • Wednesday, September 30, 2009 5:46 AMAndrew_ZhuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,Marcus

    If you are using Visual Studio, there is a AssemblyInfo.cs file in your project, open this file, and you can change the version info here. then rebuild the project.
    Also Check this thread:
    http://social.msdn.microsoft.com/Forums/en-US/windowsworkflowfoundation/thread/b3106ede-8028-46fe-b8bb-dbf66e4d2e93
    Microsoft Online Community Support
  • Tuesday, October 27, 2009 1:05 PMMasus_84 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi! Sorry for the later answer to your suggestion. I use the Rehost designer to compile the workflow. It generates a .dll files based on the current workflow and has nothing to do with a VS project etc. Is it possible to generate the assembly info file with the .dll in anyway? What is best practise regarding this? I'm using the WorkflowCompiler class to compile codebeside file.
  • Friday, October 30, 2009 9:48 AMMasus_84 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Managed to solve it. By adding a CodeAttributeDeclaration in the CodeCompileUnit.AssemblyCustomAttributes collection I managed to get the [assembly:] attribute to be generated along with the code.

    Here is the code I used:

    public static CodeCompileUnit UpdateAssemblyInformation(CodeCompileUnit unit, String description, String version)
    {
        CodeAttributeArgument[] versionArguments = new CodeAttributeArgument[1];
        versionArguments[0] = new CodeAttributeArgument(
            new CodePrimitiveExpression(version));
    
        CodeAttributeDeclaration assemblyVersion = new CodeAttributeDeclaration(
            new CodeTypeReference(ASSEMBLY_VERSION), versionArguments);
    
        CodeAttributeDeclaration assemblyFileVersion = new CodeAttributeDeclaration(
           new CodeTypeReference(ASSEMBLY_FILEVERSION), versionArguments);
    
        unit.AssemblyCustomAttributes.Add(assemblyVersion);
        unit.AssemblyCustomAttributes.Add(assemblyFileVersion);
    
        CodeAttributeArgument[] descriptionArguments = new CodeAttributeArgument[1];
        descriptionArguments[0] = new CodeAttributeArgument(
            new CodePrimitiveExpression(description));//Create parameter for attribute 
    
        CodeAttributeDeclaration assemblyDescription = new CodeAttributeDeclaration(
            new CodeTypeReference(ASSEMBLY_DESCRIPTION), descriptionArguments);
    
        unit.AssemblyCustomAttributes.Add(assemblyDescription);
        return unit;
    }

    • Marked As Answer byMasus_84 Friday, October 30, 2009 9:48 AM
    •