none
CompileAssemblyFromSource - How to set the generated assembly's version number. RRS feed

  • Question

  • I cannot see any way to set or control the version number of an assembly that is created by CompileAssemblyFromSource in the CSharpCodeProvider class.

    The assemblies that do get created appear to be versioned as 0.0.0.0

    Is there a way?

    Thx
    Sunday, February 22, 2009 2:33 PM

Answers

  • Does the code you compile contain [AssemblyVersion]? 
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, February 27, 2009 9:12 AM
    Sunday, February 22, 2009 5:17 PM
    Moderator

All replies

  • Does the code you compile contain [AssemblyVersion]? 
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, February 27, 2009 9:12 AM
    Sunday, February 22, 2009 5:17 PM
    Moderator
  • nobugz said:

    Does the code you compile contain [AssemblyVersion]? 


    Hans Passant.



    Hans

    No it doesnt't (yet) it is a single C# src file, defining a single class that implements a special (simple) interface.

    I want the user ideally, to be able to set the version when the build and publish the assembly.

    Thx
    H
    Monday, February 23, 2009 7:31 AM
  • Well, that's why then.  You'll have to create your own AssemblyInfo.cs file.
    Hans Passant.
    Monday, February 23, 2009 10:12 AM
    Moderator
  • nobugz said:

    Well, that's why then.  You'll have to create your own AssemblyInfo.cs file.


    Hans Passant.



    Hi

    OK well one more question, the CompileAssemblyFromSource takes only a single string, to do what you suggest, means I would need to concatenate the two source streams and use that as input to the compiler?

    Our system has no disk files for source code, only streams (that are persisted to a database).

    Thx
    H
    Tuesday, February 24, 2009 7:04 PM
  • nobugz said:

    Well, that's why then.  You'll have to create your own AssemblyInfo.cs file.


    Hans Passant.



    Actually its dead easy, I can just automatically prepend:

    [assembly: System.Reflection.AssemblyVersion("3.2.0.0")]  (Or whatever version it happens to be)

    to the start of the file, or use the compile batch support (that takes an array of strings).

    Thx
    H
    Tuesday, February 24, 2009 8:02 PM
  • Yup, that's all it takes.
    Hans Passant.
    Tuesday, February 24, 2009 8:11 PM
    Moderator