[#AZURE] HowTo: Publish a #ClickOnce application using and #AZURE website

image

Buenas,

 

Today he has a tutorial on those fast which I hope to save you some time, instead of investigating how to do it.What we want to do is simple: publish a WPF application with ClickOnce using a website of Azure as our point of distributing and updating. We are going with the step by step.

1. AZURE portal (www.azure.com) create a new item of type “COMPUTE / / WEB SITE / QUICK CREATE”.

image

2. For this demo created website is identified with http://elbrunoclickonce.azurewebsites.net .

3. AZURE ready, now go to Visual Studio 2012 and create a new WPF Application project. In this case I’ve called it “ElBrunoClickOnce”.

image

4. This step is optional but comes in handy to test our deployments, we will show the version number of the deployment of ClickOnce in the MainWindow title.

5. We add a reference to System.Deployment.

6 We modify the code of the MainWindow

   1: using System.Windows;
   2:  
   3: namespace ElBrunoClickOnce
   4: {
   5:     public partial class MainWindow : Window
   6:     {
   7:         public MainWindow()
   8:         {
   9:             InitializeComponent();
  10:             DisplayVersion();
  11:         }
  12:  
  13:         private void DisplayVersion()
  14:         {
  15:             var version = string.Format("assembly: {0}", ((System.Reflection.AssemblyFileVersionAttribute)
  16: (System.Reflection.Assembly.GetExecutingAssembly().
  17: GetCustomAttributes(typeof(System.Reflection.AssemblyFileVersionAttribute), 
  18: false)[0])).Version);
  19:  
  20:             if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
  21:             {
  22:                 System.Deployment.Application.ApplicationDeployment ad =
  23:                 System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
  24:                 version = string.Format("ClickOnce: {0}", ad.CurrentVersion.ToString());
  25:             }
  26:             Title = version;
  27:         }
  28:     }
  29: }

7. If we run the application we will see the version number by default of the Assembly

image

8. Now that we have our application, we will proceed to publish the same in Azure website. For this, we will first add a project ASP.Net MVC 4 to our solution. In this case I called it “ElBrunoClickOncePublish”.

image

9. Inside of the new project we created a folder called “install”

image

10. Now we will publish our web project to Azure. Luckily the friends of Microsoft have done more easier and, with each new upgrade of AZURE. We’re going for the easy way of all: we select our project Web, deplegamos the context menu and select “Publish”

image

11. Then select a profile for the publication. You can download this profile from the AZURE of our website management console.

image

12. A more simple, available since the last update of AZURE, method is to select “Import” and select the target website using our credentials of AZURE,.

image

13. Once imported profile we can follow the step by step Publishing Wizard. The final step allows us to make a preview of the items to publish and launch the publication.

image

14. Once published we can see the site online

15. Now we are going to configure ClickOnce deployment. We access the WPF project properties and in the Publish section we complete the following values:

Publishing Folder:…\ElBrunoClickOncePublish\install\ (this configuration publishes ClickOnce files directly to the Web site project directory)

Installation Folder: http://elbrunoclickonce.azurewebsites.net/install/

image

16. In the updates section, we defined that our application should be validated by new versions before launching and define again the upgrade path.

image

17 We complete the settings in the section “Options”

image

18 It is important to define a publication for our project page, in this case > publish.htm

image

19 And we’re ready, click “Publish Now” and launched a publication.

20. When you have finished publishing, selected the option to show all files in the web project and see that the ClickOnce publishing elements are inside the folder “install”

image

21 Add them as part of the website and launched a publication to AZURE from our website.

image

22. Our url of publication is ready, in this case it is http://elbrunoclickonce.azurewebsites.net/install/publish.htm, if we sailed it we will see that we have the installation of our app page.

image

23. An important detail. As I haven’t used any “good” certificate for the publication, at the time of install Win8 warns us that this may be a software of dubious origin. As in this case, it comes from my own, select the option “more info” and then “run anyway”

image

24. Then we can install the application.

image

25 Then again validate the security, already we can see our application running and displaying the ClickOnce version number.

image

26. Now we will generate a new version of the WPF app. We do a publish it again and we will see in the web project, we have 2 versions

image

27. Now we add to the project the generated version and I aconsejor remove the previous version. (I.e. AZURE, the space is paid!)

image

28. Publish our web project back to AZURE and if we navigate the installation page will see that it has been updated.

image

29. Now, try ClickOnce. We launched the application and see that we have an available update.

image

30. We apply the update, a pair of security warnings and ready! We have the updated version

image

And only 30 steps Risa

Saludos @ Home

El Bruno

image image image

8 comments

  1. I’d like to publish my desktop wpf app via an azure website. I carefully followed your instructions several times, but it always faults at step 25 with error 404 (missing file/ missing website). would you consult (fee ok)? I don’t speak Spanish…

    Like

    1. Hi Felipo, you can do this with TFS also.
      You need to customize a build process to add a step to publish to ClickOnce.
      Which version of TFS are you using?
      Regards
      -Bruno

      Like

  2. This was really helpful! Obviously, the Azure UI is a lot different now, but the same concepts still applied. Thanks!

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.