Sync file version with assembly version

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Altman

    #1

    Sync file version with assembly version

    Hi all,

    I have a C++/CLI project (VS 2005) that produces a DLL that exports C bindings.
    Internally, this DLL contains routines compiled with /clr.

    I notice that my DLL doesn't have a version resource. I assume that, unlike C#
    and VB, C++ doesn't automatically generate a version resource. Is there any way
    to make this happen? In particular, I don't want to have to manually update the
    file version in the version resource to keep it in sync with the AssemblyVersion
    attribute.

    TIA - Bob


  • Charles Wang[MSFT]

    #2
    RE: Sync file version with assembly version

    Hi Bob,
    You can simply add a version resource in your C++/CLI project. Please refer
    to the following steps:
    In Solution Explorer, expand Resource Files, double click app.rc, right
    click your app.rc folder and click Add Resource..., select Version and
    click New.
    Then you can change the version number.

    Hope this helps. Please feel free to let me know if you have any other
    questions or concerns. Have a nice day!

    Best regards,
    Charles Wang
    Microsoft Online Community Support
    =============== =============== =============== ==============
    Delighting our customers is our #1 priority. We welcome your
    comments and suggestions about how we can improve the
    support we provide to you. Please feel free to let my manager
    know what you think of the level of service provided. You can
    send feedback directly to my manager at: msdnmg@microsof t.com.
    =============== =============== =============== ==============
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscripti...ult.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for
    non-urgent issues where an initial response from the community
    or a Microsoft Support Engineer within 1 business day is acceptable.
    Please note that each follow up response may take approximately
    2 business days as the support professional working with you may
    need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by
    contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== ===============
    This posting is provided "AS IS" with no warranties, and confers no rights.
    =============== =============== =============== ============

    Comment

    • Bob Altman

      #3
      Re: Sync file version with assembly version

      No, I'm not asking how to create a version resource. I'm asking if there is
      some way to automatically synchronize the file version in the version
      resource with the assembly version, which is specified by the
      AssemblyVersion attribute. In other .Net languages (VB and C#), you don't
      deal directly with the version resource. The compiler creates a version
      resource for you, using assembly attributes to fill in the various resource
      values (file version, description, copyright, etc.). As near as I can tell,
      in C++ I need to maintain these values in two places (the version resource
      and AssemblyInfo.cp p), and I need to manually ensure that the values are the
      same in both places.

      Let me ask the question a little bit differently: I have a bunch of
      projects (most in VB, some in C++) that I build at the same time. When I
      build them, I want them all to have the same assembly and file version
      strings. I have a string constant in one of my assemblies, defined (in VB)
      as:

      Public Class Version
      Public Const AssemblyVersion = "1.2.3.4"
      End Class

      In all of my projects (both VB and C++) I use that constant to set the
      assembly version. In C++, my AssemblyInfo.cp p contains something like this:

      [AssemblyVersion (MyNamespace::V ersion::Assembl yVersion)]

      In VB, that's all I need to do, and the resultant executable gets a version
      resource with the file version equal to the assembly version. But in C++ I
      apparently need to manually create an edit a version resource. But it's not
      practical for me to manually update the version resource when the assembly
      version changes. Often as not I'll make a change to some other project and
      bump the assembly versions as a result. In that scenario, I never even
      touch the C++ project, much less fiddle with its version resource.

      Comment

      • Ben Voigt [C++ MVP]

        #4
        Re: Sync file version with assembly version


        "Bob Altman" <rda@nospam.nos pamwrote in message
        news:erAywxWoIH A.1580@TK2MSFTN GP06.phx.gbl...
        No, I'm not asking how to create a version resource. I'm asking if there
        is some way to automatically synchronize the file version in the version
        resource with the assembly version, which is specified by the
        AssemblyVersion attribute. In other .Net languages (VB and C#), you don't
        deal directly with the version resource. The compiler creates a version
        resource for you, using assembly attributes to fill in the various
        resource values (file version, description, copyright, etc.). As near as
        I can tell, in C++ I need to maintain these values in two places (the
        version resource and AssemblyInfo.cp p), and I need to manually ensure that
        the values are the same in both places.
        You could probably use a #define to accomplish this.
        >
        Let me ask the question a little bit differently: I have a bunch of
        projects (most in VB, some in C++) that I build at the same time. When I
        build them, I want them all to have the same assembly and file version
        strings. I have a string constant in one of my assemblies, defined (in
        VB) as:
        >
        Public Class Version
        Public Const AssemblyVersion = "1.2.3.4"
        End Class
        >
        In all of my projects (both VB and C++) I use that constant to set the
        assembly version. In C++, my AssemblyInfo.cp p contains something like
        this:
        >
        [AssemblyVersion (MyNamespace::V ersion::Assembl yVersion)]
        >
        In VB, that's all I need to do, and the resultant executable gets a
        version resource with the file version equal to the assembly version. But
        in C++ I apparently need to manually create an edit a version resource.
        But it's not practical for me to manually update the version resource when
        the assembly version changes. Often as not I'll make a change to some
        other project and bump the assembly versions as a result. In that
        scenario, I never even touch the C++ project, much less fiddle with its
        version resource.
        If you need the version from some other assembly, I guess you'd need to
        define a pre-build step that runs a simple tool that uses reflection to
        retrieve the value, and then writes a file which you'd #include in your main
        ..rc file.

        Comment

        • Charles Wang [MSFT]

          #5
          Re: Sync file version with assembly version

          Yes, it is a good idea to do so. If you have any other questions or
          concerns, please feel free to let us know.

          Have a nice day!

          Best regards,
          Charles Wang
          Microsoft Online Community Support
          =============== =============== =============== ============
          Delighting our customers is our #1 priority. We welcome your
          comments and suggestions about how we can improve the
          support we provide to you. Please feel free to let my manager
          know what you think of the level of service provided. You can
          send feedback directly to my manager at: msdnmg@microsof t.com.
          =============== =============== =============== ============
          This posting is provided "AS IS" with no warranties, and confers no rights.
          =============== =============== =============== ============

          Comment

          Working...