Installer "Catch 22"(?) and Versioning

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arun Bhalla

    #1

    Installer "Catch 22"(?) and Versioning

    I'm borrowing some code from Pavel's Command Prompt Explorer Bar installer
    to use in my own explorer bar's installer.

    Recently I've been thinking that using an assembly version like "1.0.*"
    (hence, for example, "1.0.1304.25935 ") would be useful, at least for
    development and debugging purposes. (Someone please point out the cons to
    this idea!)

    Well, anyway, Pavel's installer basically exists to register the assembly,
    and unregister the assembly at uninstallation. So it all comes down to
    getting the relevant assembly so it can be fed to
    RegistrationSer vices.RegisterA ssembly().

    Currently the code for getting the relevant assembly looks like this:

    Assembly VisITBarAssembl y{ get { return
    AppDomain.Curre ntDomain.Load(" VisIT, Version=1.0.0.0 , Culture=neutral ,
    PublicKeyToken= 4d504ee06f99380 a"); }}

    This works because the version is hardcoded to "1.0.0.0" in Installer.cs as
    well as AssemblyInfo.cs . I'd like to remove this string from Installer.cs so
    I can only worry about AssemblyInfo.cs whenever I want to bump up a version
    number. (Bonus points if I could remove the need to change both
    AssemblyInfo.cs and the version number in the Setup project! Additional
    bonus points if I can access the Setup project's "Manufactur er" etc. fields
    from the application, but I guess the best (or only?) solution would be to
    use the Registry.)

    So what are some good ways to go about this? I think using the Registry
    might be one way to go about it, having to store the assembly's full name
    somehow (programmatical ly) in a registry entry. Personally I think it would
    be nicer to avoid it, but hey! If I assume a constant GUID, then I could
    look it up in the registry (it's already stored there, but then again, this
    might implicitly get stored from the RegisterAssembl y call).

    It would be even nicer, I think, to have a dynamic GUID, that allows the
    GUID to change with the Product GUID (set in the Setup project), but I don't
    know if that's feasible.

    And furthermore, what can I do with the savedState object that is an
    argument to so many Installer event handlers?

    Any tips, comments, or smooth suggestions?

    Thanks,
    Arun


  • David Barnard

    #2
    Re: Installer "Catch 22"(?) and Versioning

    I _think_ you are making this far harder than it should be. If the assembly
    you are registering is the same assembly that the installer class is in,
    then all you need to do is grab the executing assembly.
    Assembly.GetExe cutingAssembly( );

    If this is not the case, then you should be able to load the correct
    assembly with a partial name, and grab the version from there (only you
    won't because you will have the correct assembly already!).
    Assembly.LoadWi thPartialName(n ame); // you will need to ensure the correct
    assembly is in the correct place for this to work.

    Or, if you only know the filename, you can just load the file.

    I'm afraid there is no way to synchronise versions across projects, and yes,
    you will have to use the registry to get the additional information you
    need.

    David

    "Arun Bhalla" <bhalla@arun.gr oogroo.com> wrote in message
    news:eH60K2TVDH A.2248@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I'm borrowing some code from Pavel's Command Prompt Explorer Bar installer
    > to use in my own explorer bar's installer.
    >
    > Recently I've been thinking that using an assembly version like "1.0.*"
    > (hence, for example, "1.0.1304.25935 ") would be useful, at least for
    > development and debugging purposes. (Someone please point out the cons to
    > this idea!)
    >
    > Well, anyway, Pavel's installer basically exists to register the assembly,
    > and unregister the assembly at uninstallation. So it all comes down to
    > getting the relevant assembly so it can be fed to
    > RegistrationSer vices.RegisterA ssembly().
    >
    > Currently the code for getting the relevant assembly looks like this:
    >
    > Assembly VisITBarAssembl y{ get { return
    > AppDomain.Curre ntDomain.Load(" VisIT, Version=1.0.0.0 , Culture=neutral ,
    > PublicKeyToken= 4d504ee06f99380 a"); }}
    >
    > This works because the version is hardcoded to "1.0.0.0" in Installer.cs[/color]
    as[color=blue]
    > well as AssemblyInfo.cs . I'd like to remove this string from Installer.cs[/color]
    so[color=blue]
    > I can only worry about AssemblyInfo.cs whenever I want to bump up a[/color]
    version[color=blue]
    > number. (Bonus points if I could remove the need to change both
    > AssemblyInfo.cs and the version number in the Setup project! Additional
    > bonus points if I can access the Setup project's "Manufactur er" etc.[/color]
    fields[color=blue]
    > from the application, but I guess the best (or only?) solution would be to
    > use the Registry.)
    >
    > So what are some good ways to go about this? I think using the Registry
    > might be one way to go about it, having to store the assembly's full name
    > somehow (programmatical ly) in a registry entry. Personally I think it[/color]
    would[color=blue]
    > be nicer to avoid it, but hey! If I assume a constant GUID, then I could
    > look it up in the registry (it's already stored there, but then again,[/color]
    this[color=blue]
    > might implicitly get stored from the RegisterAssembl y call).
    >
    > It would be even nicer, I think, to have a dynamic GUID, that allows the
    > GUID to change with the Product GUID (set in the Setup project), but I[/color]
    don't[color=blue]
    > know if that's feasible.
    >
    > And furthermore, what can I do with the savedState object that is an
    > argument to so many Installer event handlers?
    >
    > Any tips, comments, or smooth suggestions?
    >
    > Thanks,
    > Arun
    >
    >[/color]


    Comment

    • Arun Bhalla

      #3
      Re: Installer &quot;Catch 22&quot;(?) and Versioning

      Hmm, I'll look into it. Currently (and presumably, always) the installer is
      not in the same assembly.
      The installer is "Installer.exe, " and the assembly is just a DLL.
      Assembly.LoadWi thPartialName() might
      do the trick. I imagined that I might have to iterate through a bunch of
      assemblies with a certain name and try
      to find the assembly with some appropriate version number (perhaps the
      maximum version number).

      Thanks,
      Arun


      "David Barnard" <msdn.newsgroup s@didactylos.ne t> wrote in message
      news:u8dezKXVDH A.2004@TK2MSFTN GP11.phx.gbl...[color=blue]
      > I _think_ you are making this far harder than it should be. If the[/color]
      assembly[color=blue]
      > you are registering is the same assembly that the installer class is in,
      > then all you need to do is grab the executing assembly.
      > Assembly.GetExe cutingAssembly( );
      >
      > If this is not the case, then you should be able to load the correct
      > assembly with a partial name, and grab the version from there (only you
      > won't because you will have the correct assembly already!).
      > Assembly.LoadWi thPartialName(n ame); // you will need to ensure the correct
      > assembly is in the correct place for this to work.
      >
      > Or, if you only know the filename, you can just load the file.
      >
      > I'm afraid there is no way to synchronise versions across projects, and[/color]
      yes,[color=blue]
      > you will have to use the registry to get the additional information you
      > need.
      >
      > David
      >
      > "Arun Bhalla" <bhalla@arun.gr oogroo.com> wrote in message
      > news:eH60K2TVDH A.2248@TK2MSFTN GP10.phx.gbl...[color=green]
      > > I'm borrowing some code from Pavel's Command Prompt Explorer Bar[/color][/color]
      installer[color=blue][color=green]
      > > to use in my own explorer bar's installer.
      > >
      > > Recently I've been thinking that using an assembly version like "1.0.*"
      > > (hence, for example, "1.0.1304.25935 ") would be useful, at least for
      > > development and debugging purposes. (Someone please point out the cons[/color][/color]
      to[color=blue][color=green]
      > > this idea!)
      > >
      > > Well, anyway, Pavel's installer basically exists to register the[/color][/color]
      assembly,[color=blue][color=green]
      > > and unregister the assembly at uninstallation. So it all comes down to
      > > getting the relevant assembly so it can be fed to
      > > RegistrationSer vices.RegisterA ssembly().
      > >
      > > Currently the code for getting the relevant assembly looks like this:
      > >
      > > Assembly VisITBarAssembl y{ get { return
      > > AppDomain.Curre ntDomain.Load(" VisIT, Version=1.0.0.0 , Culture=neutral ,
      > > PublicKeyToken= 4d504ee06f99380 a"); }}
      > >
      > > This works because the version is hardcoded to "1.0.0.0" in Installer.cs[/color]
      > as[color=green]
      > > well as AssemblyInfo.cs . I'd like to remove this string from[/color][/color]
      Installer.cs[color=blue]
      > so[color=green]
      > > I can only worry about AssemblyInfo.cs whenever I want to bump up a[/color]
      > version[color=green]
      > > number. (Bonus points if I could remove the need to change both
      > > AssemblyInfo.cs and the version number in the Setup project! Additional
      > > bonus points if I can access the Setup project's "Manufactur er" etc.[/color]
      > fields[color=green]
      > > from the application, but I guess the best (or only?) solution would be[/color][/color]
      to[color=blue][color=green]
      > > use the Registry.)
      > >
      > > So what are some good ways to go about this? I think using the Registry
      > > might be one way to go about it, having to store the assembly's full[/color][/color]
      name[color=blue][color=green]
      > > somehow (programmatical ly) in a registry entry. Personally I think it[/color]
      > would[color=green]
      > > be nicer to avoid it, but hey! If I assume a constant GUID, then I could
      > > look it up in the registry (it's already stored there, but then again,[/color]
      > this[color=green]
      > > might implicitly get stored from the RegisterAssembl y call).
      > >
      > > It would be even nicer, I think, to have a dynamic GUID, that allows the
      > > GUID to change with the Product GUID (set in the Setup project), but I[/color]
      > don't[color=green]
      > > know if that's feasible.
      > >
      > > And furthermore, what can I do with the savedState object that is an
      > > argument to so many Installer event handlers?
      > >
      > > Any tips, comments, or smooth suggestions?
      > >
      > > Thanks,
      > > Arun
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Suzanne Cook [MS]

        #4
        Re: Installer &quot;Catch 22&quot;(?) and Versioning

        Don't use LoadWithPartial Name(). See

        for why not. That may help you in the development environment, but will
        come back to haunt you in the shipping code.

        Instead, for development purposes, I recommend that you just not change your
        assembly version between shipping builds. See

        for details.

        Suzanne Cook
        My .NET CLR Loader blog: http://blogs.gotdotnet.com/suzcook/
        --
        Please do not respond directly to this alias. This alias is for newsgroup
        purposes only. This posting is provided "AS IS" with no warranties, and
        confers no rights.



        "Arun Bhalla" <bhalla@arun.gr oogroo.com> wrote in message
        news:uEPufBhVDH A.2352@TK2MSFTN GP12.phx.gbl...[color=blue]
        > Hmm, I'll look into it. Currently (and presumably, always) the installer[/color]
        is[color=blue]
        > not in the same assembly.
        > The installer is "Installer.exe, " and the assembly is just a DLL.
        > Assembly.LoadWi thPartialName() might
        > do the trick. I imagined that I might have to iterate through a bunch of
        > assemblies with a certain name and try
        > to find the assembly with some appropriate version number (perhaps the
        > maximum version number).
        >
        > Thanks,
        > Arun
        >
        >
        > "David Barnard" <msdn.newsgroup s@didactylos.ne t> wrote in message
        > news:u8dezKXVDH A.2004@TK2MSFTN GP11.phx.gbl...[color=green]
        > > I _think_ you are making this far harder than it should be. If the[/color]
        > assembly[color=green]
        > > you are registering is the same assembly that the installer class is in,
        > > then all you need to do is grab the executing assembly.
        > > Assembly.GetExe cutingAssembly( );
        > >
        > > If this is not the case, then you should be able to load the correct
        > > assembly with a partial name, and grab the version from there (only you
        > > won't because you will have the correct assembly already!).
        > > Assembly.LoadWi thPartialName(n ame); // you will need to ensure the[/color][/color]
        correct[color=blue][color=green]
        > > assembly is in the correct place for this to work.
        > >
        > > Or, if you only know the filename, you can just load the file.
        > >
        > > I'm afraid there is no way to synchronise versions across projects, and[/color]
        > yes,[color=green]
        > > you will have to use the registry to get the additional information you
        > > need.
        > >
        > > David
        > >
        > > "Arun Bhalla" <bhalla@arun.gr oogroo.com> wrote in message
        > > news:eH60K2TVDH A.2248@TK2MSFTN GP10.phx.gbl...[color=darkred]
        > > > I'm borrowing some code from Pavel's Command Prompt Explorer Bar[/color][/color]
        > installer[color=green][color=darkred]
        > > > to use in my own explorer bar's installer.
        > > >
        > > > Recently I've been thinking that using an assembly version like[/color][/color][/color]
        "1.0.*"[color=blue][color=green][color=darkred]
        > > > (hence, for example, "1.0.1304.25935 ") would be useful, at least for
        > > > development and debugging purposes. (Someone please point out the cons[/color][/color]
        > to[color=green][color=darkred]
        > > > this idea!)
        > > >
        > > > Well, anyway, Pavel's installer basically exists to register the[/color][/color]
        > assembly,[color=green][color=darkred]
        > > > and unregister the assembly at uninstallation. So it all comes down to
        > > > getting the relevant assembly so it can be fed to
        > > > RegistrationSer vices.RegisterA ssembly().
        > > >
        > > > Currently the code for getting the relevant assembly looks like this:
        > > >
        > > > Assembly VisITBarAssembl y{ get { return
        > > > AppDomain.Curre ntDomain.Load(" VisIT, Version=1.0.0.0 , Culture=neutral ,
        > > > PublicKeyToken= 4d504ee06f99380 a"); }}
        > > >
        > > > This works because the version is hardcoded to "1.0.0.0" in[/color][/color][/color]
        Installer.cs[color=blue][color=green]
        > > as[color=darkred]
        > > > well as AssemblyInfo.cs . I'd like to remove this string from[/color][/color]
        > Installer.cs[color=green]
        > > so[color=darkred]
        > > > I can only worry about AssemblyInfo.cs whenever I want to bump up a[/color]
        > > version[color=darkred]
        > > > number. (Bonus points if I could remove the need to change both
        > > > AssemblyInfo.cs and the version number in the Setup project![/color][/color][/color]
        Additional[color=blue][color=green][color=darkred]
        > > > bonus points if I can access the Setup project's "Manufactur er" etc.[/color]
        > > fields[color=darkred]
        > > > from the application, but I guess the best (or only?) solution would[/color][/color][/color]
        be[color=blue]
        > to[color=green][color=darkred]
        > > > use the Registry.)
        > > >
        > > > So what are some good ways to go about this? I think using the[/color][/color][/color]
        Registry[color=blue][color=green][color=darkred]
        > > > might be one way to go about it, having to store the assembly's full[/color][/color]
        > name[color=green][color=darkred]
        > > > somehow (programmatical ly) in a registry entry. Personally I think it[/color]
        > > would[color=darkred]
        > > > be nicer to avoid it, but hey! If I assume a constant GUID, then I[/color][/color][/color]
        could[color=blue][color=green][color=darkred]
        > > > look it up in the registry (it's already stored there, but then again,[/color]
        > > this[color=darkred]
        > > > might implicitly get stored from the RegisterAssembl y call).
        > > >
        > > > It would be even nicer, I think, to have a dynamic GUID, that allows[/color][/color][/color]
        the[color=blue][color=green][color=darkred]
        > > > GUID to change with the Product GUID (set in the Setup project), but I[/color]
        > > don't[color=darkred]
        > > > know if that's feasible.
        > > >
        > > > And furthermore, what can I do with the savedState object that is an
        > > > argument to so many Installer event handlers?
        > > >
        > > > Any tips, comments, or smooth suggestions?
        > > >
        > > > Thanks,
        > > > Arun
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...