Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Assembly Version to track the Publish Version
 

Assembly Version to track the Publish Version

Is there any way of synchronising the Assembly Version with the Publish Version (- or visa versa). I am intrigued that the Publish Version an be automatically incremented (very useful imo to ensure which variant i am deploying), but the Assembly Version can't be automatically incremented when re-built.

I haven't got my head around the idea of having multiple versions associated with the same application.

Is there any way for the Application to (easily) read the Publish Version.

I a newbie to ClickOnce so apologies if i am asking dumb questions!

regards

Paul
Paul Durdin  Thursday, October 01, 2009 7:06 AM
No, you have to synchronise the two values manually. We mostly ignore the assembly version. I update it with each major release just so the developers know what version we are testing/working on when we run the application. We display the version number on our login/splash screen. Here is the code that we use. If running it in VS, it will show the assembly version; if running as a ClickOnce app, this returns the deployment version.

/// <summary>
/// Return the current version. If running the deployed version, returns that version number,
/// otherwise returns the assembly version.
/// </summary>
/// <returns>Version number</returns>
public static string GetVersion()
{
    string ourVersion = string.Empty;
    //if running the deployed application, you can get the version
    //  from the ApplicationDeployment information. If you try
    //  to access this when you are running in Visual Studio, it will not work.
    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
        ourVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
    else
    {
        System.Reflection.Assembly assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly();
        if (assemblyInfo != null)
            ourVersion = assemblyInfo.GetName().Version.ToString();
    }
    return ourVersion;
}




RobinDotNet
Click here to visit my ClickOnce blog!
RobinDotNet  Thursday, October 01, 2009 7:54 AM
No, you have to synchronise the two values manually. We mostly ignore the assembly version. I update it with each major release just so the developers know what version we are testing/working on when we run the application. We display the version number on our login/splash screen. Here is the code that we use. If running it in VS, it will show the assembly version; if running as a ClickOnce app, this returns the deployment version.

/// <summary>
/// Return the current version. If running the deployed version, returns that version number,
/// otherwise returns the assembly version.
/// </summary>
/// <returns>Version number</returns>
public static string GetVersion()
{
    string ourVersion = string.Empty;
    //if running the deployed application, you can get the version
    //  from the ApplicationDeployment information. If you try
    //  to access this when you are running in Visual Studio, it will not work.
    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
        ourVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
    else
    {
        System.Reflection.Assembly assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly();
        if (assemblyInfo != null)
            ourVersion = assemblyInfo.GetName().Version.ToString();
    }
    return ourVersion;
}




RobinDotNet
Click here to visit my ClickOnce blog!
RobinDotNet  Thursday, October 01, 2009 7:54 AM
Hi Paul,

In addition to Robin’s answer, here is my opinion to the question.

1. ClickOnce publish version and assembly version are two different versions. Once you publish a new version of ClickOnce application, the version will be increased but AssemblyVersion won’t if you write down the exact number.

2. AssemblyVersion also can be increased automatically, please look at this document.
http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute%28VS.71%29.aspx

3. From the document you can know that AssemblyVersion can be auto increased if you put “*” instead of the exact number. For example, 1.0.0.* or 1.0.* You can set the version number in the AssemblyInfo.cs file.

4. Even if the AssemblyVersion is auto increased, you cannot synchronize it with ClickOnce publish version.

Hope my answer also helps you. Thanks for Robin’s sharing.
If you have any further question, please feel free to tell us.

Sincerely,
Kira Qian
Send us any feedback you have about the help from MSFT at EMAIL REMOVED
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Friday, October 02, 2009 8:08 AM

You can use google to search for other answers

Custom Search

More Threads

• Desktop and Start Menu Icon?
• Save local state
• .NET 3.5 SP1 generic bootstrapper pre-requiste package.
• Reliable enough?
• Need help with a deployment.
• Custom Deployment for ClassLibrary
• Add primary output as Desktop and Programs Menu shortcuts in VS2008 setup project?
• Keeping custom directory structure during custom prerequisite download
• smart client security exception with mshtml component, please help!!
• An error occurred while signing: Invalid character in the given encoding.