DermFrench
DermFrench

Reputation: 4057

Click Once Update To Specific Version

I would like my users to be able to update to a specific version using click once. Currently we have Help | Check for updates, which just updates to a latest version.

I'd like to add a Help | Update to version (which would then prompt for a version number that the user could enter and it would update them to that version (both if they are currently on a lower version or they are on a higher version)).

The application is developed using c#

Upvotes: 3

Views: 1957

Answers (3)

Uwy
Uwy

Reputation: 487

Not ideal but it can help if you're desperate enough to retrieve old binaries

  1. Go to the ClickOnce server folder, it has a setup.exe, publish.htm myapplicationname.application among other files, it also has a folder named Application Files
  2. In this Application Files folder you will find all previously ClickOnce uploaded versions
  3. Copy / Download the folder for your version (named like myapplicationname_1_2_30_145)
  4. Rename all files ending with "*.deploy" to remove that extension :
 find -type f -name '*.deploy' | while read f; do mv "$f" "${f%.deploy}"; done

Now you can basically use it like you would with a portable application, double click the executable or something

Upvotes: 1

Oliver
Oliver

Reputation: 651

I’ve been able to get this functionality implemented with only a little additional work after each publish with no detailed instructions required by the user. The way this gets a specific version is that you need to have multiple clickonce directories for each version

After you publish you need to open the myApplication.application in notepad and make a change

<deploymentProvider codebase="http://www.example.com/ClickOnce/MyApplication/MyApplication.application" />

to

<deploymentProvider codebase="http://www.example.com/ClickOnce/MyApplication1.02.03.45/MyApplication.application" />

or whatever version you will be making available; before uploading to clickonce.

Here is how the user can get a specific version

    Public Shared Sub GetSpecificVersion()
            Try
                Dim spre As String = InputBox("press enter to download the current version of myApplication. If you would want to download a specific version of myApplication please append the version number  i.e myApplication1.02.03.45", , "myApplication") 
                Dim spost As String = "/myApplication.application"
                Dim finalUrl As String = "http://www.example.com/clickonce/"
                finalUrl = finalUrl & spre & spost
                Try
                    My.Computer.Network.DownloadFile(finalUrl, "C:/ProgramFiles", Nothing, Nothing, Nothing, 

1000, True) 'url/filename/username/password/showui/timeout/overwriteExiting
                Process.Start("C:/ProgramFiles/myApplication.application")
                Application.Current.Shutdown()
                Dim r As String
            Catch ex As Exception
                MsgBox("The desired version of myApplication may not be typed correctly or is unavailable on clickonce. alternatively a connection could not be established to the clickonce server")
                MsgBox(ex.ToString())
            End Try
        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try
    End Sub

To get the specific version all the user needs to do is to enter the version "myApplication1.02.34

a side effect of this is that checking for successive updates using the manifest will only check that specific folder, I created a second method for getting the latest version from a default directory:

heres to get central version

Public Shared Sub GetLatestCentralizedVersion()
Try
              My.Computer.Network.DownloadFile("http://www.example.com/clickonce/myApplication/myApplication.application", "C:/ProgramFiles/myApplication.application", Nothing, Nothing, Nothing, 1000, True) 'url/filename/username/password/showui/timeout/overwrite
            Process.Start("C:/ProgramFiles/myApplication.application")
            Application.Current.Shutdown()
        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try
    End Sub

Upvotes: 2

Jaycee
Jaycee

Reputation: 3118

You're hitting a limitation of ClickOnce, no way to do it. There's one manifest which must contain a single identity pointing to a server containing a version (new or old). Pointing the app to multiple versions won't work.

To provide a choice of versions you would need to do something outside of the ClickOnce infrastructure for your application, such as another app allowing the user to choose to install specific versions - this would be a very simple download a manifest type program and then permit the user to launch. Unfortunately each app would have to be made available from different locations with a different name, such as appending the version number.

Upvotes: 0

Related Questions