This is one in a series of articles about Time Tortoise, a Universal Windows Platform app for planning and tracking your work schedule. For more on the development of this app and the ideas behind it, see my Time Tortoise category page.
Last week I covered some of the requirements for self-hosting Time Tortoise. The next step is to package and deploy a self-hosted version of the app, without disrupting the ability to run it in debug mode in Visual Studio.
Create and Installing an App Package
In order to run a UWP app outside of Visual Studio, it must be installed from a package. For end users, this is a seamless process that happens from the Windows Store interface. For developers, the process requires a few more steps.
With the Time Tortoise solution open in Visual Studio, a package can be created as follows:
- Right-click on the TimeTortoise.UWP (Universal Windows) project and select Store – Create App Packages.
- On the Create Your Packages page, answer No to the question Do you want to build packages to upload to the Windows Store? That’s a job for later this year. For now, I just need a package that I can install locally.
- On the Select and Configure Packages page, the default values are fine.
- Click Create.
After a few minutes, all of the required files are created at the selected location. For my test, they were under a directory called
At this point, we have all of the files required to install Time Tortoise locally, assuming the local machine is enabled for sideloading apps. To start the process, right-click on
Add-AppDevPackage.ps1 and select Run with PowerShell.
One of the first things this PowerShell script does is install the certificate from the app package. To see this certificate, you can run
certmgr.msc and navigate to Certificates – Current User -> Trusted People -> Certificates. UWP apps are designed to require a certificate as a security feature. In this case, we’re just using a temporary self-signed certificate for testing purposes.
Next, the script tries to install the app itself. This is where I encountered the following error message:
The current user has already installed an unpackaged version of this app. A packaged version cannot replace this.
The problem is that Windows does not allow two copies of the same app to be installed on the same machine. Fortunately, it’s easy to convince Windows that an app is different: simply change its package name. Since my goal is to run a dev version of Time Tortoise side by side with a self-hosted version, I used the following process:
Remove-AppxPackage [package_name]to remove the currently-installed version of Time Tortoise.
- In Package.appxmanifest, set the package name to
- Run the steps above to create and install the package. This is the self-host version.
- In Package.appxmanifest, change the package name to
Now when Time Tortoise is run from within Visual Studio, it will be seen as a different app called TimeTortoise-dev. This means its database will be isolated in a different folder under
%UserProfile%\AppData\Local\Packages. As I mentioned last week, keeping development and self-host databases separate is a key requirement for self-hosting.
Running a self-host version of Time Tortoise with this process allows using the app for real scenarios, while improving the dev version using feedback from those scenarios. The self-host version can then be periodically updated with the latest improvements.