Freigeben über


SYSK 2: A word on versions – deployment, assembly, file…

Assembly version, a.k.a. product version is used by CLR when loading dependent assemblies.  As in .NET 1.X, you can see/change the ProductVersion in assembly manifest by using [assembly:AssemblyVersion(“2.1.6.432”)] attribute.  In VS2005, there is now UI for the ProductVersion -- Project Properties->Application Tab->Assembly Information.  Programmatically, you can get this version by calling Application.ProductVersion property.

File version existed in VS2003, although some people didn’t know about it because it wasn’t automatically added to AssemblyInfo.cs.  AssemblyFileVersion attribute is what the shown in Version tab in Windows Explorer when you look at assembly properties. If you want compatibility, don't change the AssemblyVersion, but use the AssemblyFileVersion to track your builds and versions;  only increment the AssemblyVersion when you are breaking compatibility and want to force a recompile and
allow side-by-side execution.  Note: if you exclude the AssemblyFileVersion, then the value is set to the same as AssemblyVersion.  Check out FileVersionInfo class for more info.

Finally, with ClickOnce, we now have the deployment (a.k.a. publish version).  This is what’s used to figure out if the client installation is up-to-date or a newer version is available.  Programmatically, you can get this version by calling System.Deplolyment.ApplicationDeployment.CurrentDeployment.CurrentVersion property (make sure to check that the deployment was done via ClickOnce by calling System.Deployment.ApplicationDeployment.IsNetworkDeployed).

It usually makes sense to keep ProductVersion and DeploymentVersion in sync, but you don't have to.  

If the application is deployed via ClickOnce, it is  recommended to display the deployment version.
For more information, check out the MSDN Webcast: Using Visual Studio's ClickOnce Technology to Deploy a Smart Client Application (Level 200) http://www.microsoft.com/events/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032270519%22%2f%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22%2f%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22%2f%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22%2f%5e%7esParams%5e%7e%2fsParams%5e%7e%2fCMTYDataSvcParams%5e

Comments

  • Anonymous
    January 20, 2006
    Thank you very much for this info.
    There is al litte problem with the namespace
    This works fine on my machine:

    private void helpToolStripButton_Click(object sender, EventArgs e)
    {
    String msg = "Not available";
    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
    msg += string.Format("nApplication Version {0}", System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion);
    MessageBox.Show(msg,"Help",MessageBoxButtons.OK,MessageBoxIcon.Information);
    }

    HTH
    Claudio

  • Anonymous
    August 11, 2006
    OK, that makes a few things clear.  I'm wondering how I can automate the keeping in synch of the deployment version with the assembly version.  The deployment version is automatically increased each time I publish, but this does not affect the assembly version in any way.

    regards,
    Phil

  • Anonymous
    August 11, 2006
    On my projects, we do it in the deployment script, i.e. the deployment script changes the assembly version to match the deployment version during the build phase...

  • Anonymous
    February 08, 2007
    Could you please post the code from your deployment script which changes the assembly version to match the deployment version during the build phase? Thanks, spencer

  • Anonymous
    February 08, 2007
    Sorry -- it's been so long ago, I no longer have access to the code.