Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / Universal Windows Platform
Tip/Trick

Update UWP Application like ClickOnce

Rate me:
Please Sign up or sign in to vote.
1.33/5 (3 votes)
3 Dec 2017CPOL1 min read 8.1K   41   2   4
Make auto updater for UWP applications, because UWP doesn't have auto update functionality (like WPF ClickOnce).

Introduction

Make auto updater for UWP applications, because UWP does not have auto update functionality (like WPF ClickOnce).

Background

Set privileges to network folder. Develop C# Console Application.

Using the Code

By Panagiotis D. Satos, Arta - Greece

  1. Create a C# Console Application (Project Name: Updater).

    Inside the Main method, write the following code block:

    C#
    Console.Write("Update Applications...");
    Excel(); //See the attached file.

This is the method, from which the application (Updater.exe) reads the new version paths for installed UWP applications.

C#
private static void Excel()
        {            
            string l_strFileName = "\\\\192.168.1.3\\update\\Updater\\Updater.xls";
            String l_strCon = "provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + l_strFileName + "';Extended Properties='Excel 12.0;HDR=No'";
            OleDbConnection l_oleDBcon = new OleDbConnection(l_strCon);
            l_oleDBcon.Open();
            DataTable dt = l_oleDBcon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            String[] l_strExcelSheetsNames = new String[dt.Rows.Count];
            int i = 0;
            foreach (DataRow row in dt.Rows)
            {
                l_strExcelSheetsNames[i] = row["TABLE_NAME"].ToString();
                i++;
            }
            OleDbCommand l_oleDBcommand = new OleDbCommand("SELECT * FROM [" + l_strExcelSheetsNames[0] + "]", l_oleDBcon);
            OleDbDataAdapter l_loeDBadapter = new OleDbDataAdapter();
            l_loeDBadapter.SelectCommand = l_oleDBcommand;
            DataSet l_ds = new DataSet();
            l_loeDBadapter.Fill(l_ds);
            ArrayList l_listPaths = new ArrayList();
            string l_strPath;
            for (i = 0; i <= l_ds.Tables[0].Rows.Count - 1; i++)
            {
                l_strPath = l_ds.Tables[0].Rows[i].ItemArray[0].ToString();
                if (l_strPath.Equals(""))
                {
                    continue;
                }
                else
                {
                    l_listPaths.Add(l_strPath);
                }
            }
            l_oleDBcon.Close();
            if (l_listPaths.Count > 0)
            {
                for (i = 0; i < l_listPaths.Count; i++)
                {
                    System.Diagnostics.Process.Start(l_listPaths[i].ToString());
                }                
            }                     
        }
  1. Add the Console Application (Updater.exe) at network path (folder), which is the same path from which our Applications were installed to our LAN computers. For example:
    \\192.168.1.3\update\Updater\
  2. At the same path, also add an Excel file (Updater.xls). There, you can add the paths of new versions of your applications. For example, these are the paths of new versions of two applications:
    • \\192.168.1.3\update\Updater\UWP\AppPackages\UWP_1.0.8.0_Debug_Test\UWP_1.0.8.0_x86_x64_arm_Debug.appxbundle
    • \\192.168.1.3\update\Updater\AppUpdate\AppPackages\AppUpdate_1.0.3.0_Debug_Test\AppUpdate_1.0.3.0_x86_x64_arm_Debug.appxbundle
  3. Create a shortcup of Updater.exe (\\192.168.1.3\update\Updater\Updater.exe) in startup folder (Open folder: press WinKey + R (Run...), write: shell:startup, press Enter key) of each LAN computer.

    Open starup folder

  4. Add server path \\192.168.1.3 at Intranet Settings:

    Intranet settings

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Greece Greece
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionExplanations Pin
Wendelius30-Nov-17 18:47
mentorWendelius30-Nov-17 18:47 
AnswerRe: Explanations Pin
psatos2-Dec-17 9:21
psatos2-Dec-17 9:21 
GeneralRe: Explanations Pin
Wendelius2-Dec-17 20:00
mentorWendelius2-Dec-17 20:00 
In my opinion the missing part is the actual code. From the excerpt I see that you call a method named Excel but what does it do?

What a reader at CodeProject would except is to see code fragments along with explanations like "this code fragment does ... and I decided to do it like this because ...".
GeneralRe: Explanations Pin
psatos2-Dec-17 22:54
psatos2-Dec-17 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.