Showing posts with label UWP. Show all posts
Showing posts with label UWP. Show all posts

Wednesday, March 21, 2018

Exploring Advanced Installer Express free edition to convert legacy apps to UWP

Earlier back in 2016 when Microsoft released Project centennail, I have blogged about it which you can find here

To know more about Desktop bridge and UWP conversion have a look here




Recently Advanced Installer has released a free express edition which is a GUI based tool to simplify the process of converting legacy exe/msi to appx format.They have also stated to support the new MSIX format in their upcoming release.

You can download the free  Advanced Installer express version here.

Pre-Req: Install windows sdk from here 

After downloading install the windows sdk first and then install  the Advanced Installer express edition in a clean virtual machine.After Installing you will be prompted to register using your mail ID to get the free license .After validating click on new and select the Convert Desktop App as shown below and click next.




Provide the setup path (msi/exe) and add any parameters if you wish to add.In this example I have used google chrome msi package to convert to appx format.


Provide the output path or leave to default location.


After clicking Next, the tool will do pre-capture, install the google chrome msi and then do the post capture during the Installation monitoring phase.


Once done, click next. It will list out what all files,registries,scheduled tasks etc..
You can do cleanup in this section and then click import.





Click build icon to create uwp app.If there are any issues, it will show build failed.



You can see that in the below screen it says that the Appx package must be digitally signed to install.


I have ignored this warning and proceeded next.You can see the output files. Inside Google Chrome-BuildUwpAppx folder you can see the Google Chrome.appx file created.







To install the Google Chrome.appx, open elevated powershell window and run the below command.


Add-AppxPackage "Path to .AppX File"

You can see that the command fails stating that there is no valid digital signature.



For testing purpose, I have created a dummy certificate following the steps provided here


After that in the Advanced Installer project, I scrolled to Digital Signature tab and added the above created google.pfx file and selected enable signing option as shown below.


Click build option to add the certificate inside the output .appx file.Once done run the below command to test the output package.

Testing :Open elevated powershell and run the below command.

Add-AppxPackage "Path to .AppX File"

This will install the package successfully.If you are facing issues during Install because of certificates, follow these steps as mentioned here.

From my testing I found the below Pro's using the Advanced Installer express edition.

1. User Friendly GUI which makes even a beginner to convert legacy apps to UWP easily.
2. No need of docker image and desktop bridge powershell commands to convert anymore. We can install the Advanced Installer application in the virtual machine and use it directly to convert.
3. With the same project we can also create msi/exe output files (makes life easy).
4. Highlights the issues found during build phase which really helps us to easily resolve it.

Con's:

1. Install Monitoring Phase takes quite some time which can be made faster.

So why wait, go and grab the free Advanced Installer express edition and convert your legacy apps to UWP easily.
 

Thursday, April 28, 2016

Project Centennial - First hands on Converting desktop apps to Universal Windows Platform (UWP)

There was a huge expectation about the Project Centennial also famously known as Project C. I promise it will not disappoint any of you. I was very eager to have my hands on it and experiment it more and so here I am explaining the conversion steps in detail with a test desktop app.

Prior to conversion one should know the advantages of converting desktop apps to UWP. To know more check the below link.

https://msdn.microsoft.com/windows/uwp/porting/desktop-to-uwp-root

Microsoft has released its pre-release version of Desktop App Converter tool which can be used to convert all the existing desktop apps written for .NET 4.6.1 or Win32 to the Universal Windows Platform (UWP).

Desktop App Converter tool converts a desktop Windows installer such as MSI or EXE to an AppX package that can be deployed to a Windows 10 desktop.

Requirements:

1. Windows 10 Build 10.0.14316.0 or higher(Should be installed physically. Converter will fail in a VM image)
2. Desktop App Converter ( Download - Here )
3. Windows Software Development Kit (SDK) for Windows 10 ( Download Here )

The Desktop App Converter will download two files. BaseImage-14316.wim and
DesktopAppConverter.zip.Extract the DesktopAppConverter.zip files to a desired location.


You can see that there are two files (DesktopAppConverter.cmd and DesktopAppConverter.ps1) DesktopAppConverter.cmd is a cmd wrapper for DesktopAppConverter.ps1.To know more type DesktopAppConverter.cmd -? You can use either CMD or Powershell file for converting purposes.


Now lets convert a test desktop app. Here I am going to use Notepad++ to convert into UWP.
 
Open Powershell as admin and set the execution policy to unrestricted or bypass.



Enter the below command in the Powershell.The setup command will make the Converter to expand the given base image(BaseImage-14316.wim). To know more about these parameters have a look at the below article.

https://msdn.microsoft.com/windows/uwp/porting/desktop-to-uwp-run-desktop-app-converter


"path to DesktopAppConverter.ps1" -Setup -BaseImage "path to BaseImage-14316.wim"

If it asks for reboot,Restart the machine and run the command again.

Also note that if you give the absolute path for the DesktopAppConverter.ps1 it will fail. You would need to give the relative path to make it work properly.





It will take some time to expand the base image, so you would need to wait patiently.
It expands the base image to the below path.



Enter the below command to perform conversion in an elevated Powershell.
"path to DesktopAppConverter.ps1" Installer "C:\test\npp.6.8.2.Installer.exe" -InstallerArguments "/S" -Destination "C:\Output\notepadplusplus"
-PackageName "Notepadplus" -Publisher "CN=Notepadplusplus" -Version 6.8.2.0 -ExpandedBaseImage C:\ProgramData\Microsoft\Windows\Images\BaseImage-14316 -Verbose -LogFile "c:\notepad.log"

Make sure you do not keep any other application in the folder. keep only the application that needs to be converted in the Installer location. In this case only notepad++ installer exe should be kept.








This command will run the notepad++ Installer silently in an isolated environment using a clean base image which we downloaded along with the converter(We have expanded the WIM image earlier). It will capture all the changes like registry and file system I/O made by the notepad++ installer and packages it as part of the output.

You can see the verbose log in the screen as we have used -verbose parameter. Also a log file will be generated in the C:\ drive as we have explicitly mentioned in the above command using -LogFile parameter.


So what happens exactly when running the above script. will see more (Refer the above screenshots while reading the below steps for easy understanding).
  1. The script does a Pre-Requisite check like checking Minimum Windows Version,PowerShell Version etc..
  2. It Validates the given parameters like Installer presence, Output Folder presence (If it is not there it will create the folder)
  3. It will Setup Conversion Environment for Capturing.
  4. It Creates AppX Manifest file. This acts as the Core DNA of the Application. It is the Metadata for the package that contains all the required information including extension points, FTA's, shortcuts and the identity names associated with the package.You can customize this file for any changes to be made after capturing the package.
  5. It Generates Virtual File System (VFS). All the files that are captured will be placed here.Additionally there will be Assets Folder which contains Icons [This is created by the Converter].If you are working on App-V then you can relate these things as both are quite same.
  6. It Generates Virtual Registry System (Registry.dat). It Contains all the registry changes that were made by the Installer.
Output – Below is the image of the output that we get,




Assets folder contains the icons for the package. By default it shows X symbol (I guess this will be rectified in the original release). You would need to change these to original icons. Just extract the icons and replace them here with the same name, so that there will be no changes required to modify the AppXmanifest file further.




If we want to create .AppX Package then we need to follow the below steps.

Use MakeAppX.exe to convert to Appx format (It will be available as a part of Windows SDK)


MakeAppx.exe Pack -d "Path of Directory Containing the VFS, Registry.Dat & AppXManifest.xml"-p "Path to output folder"



This will build the loose files to a single AppX package .



In-order to deploy and test the .appx package using the Add-AppxPackage cmdlet, it requires that the application package (.appx) must be signed. For this we can use SignTool.exe, which comes with the Microsoft Windows 10 SDK.





Once signed (you can use a dummy certificate for this step), you can install it successfully.

Testing :Open elevated powershell and run the below command.


Add-AppxPackage "Path to .AppX File"

This will install the package successfully.


NOTE:

At present the Desktop App Converter supports the conversion process only on a 64-bit OS. You can deploy the converted .appx packages to a 64-bit OS only. Desktop App Converter requires the desktop installer to run under unattended mode.

MVP Tim Mangan has mentioned in his blog that there is a bug in the converter.If you give it a MSI based installer, it ignores the command line parameters that you provide and injects it’s own.To know more check his official blog page.(Interesting read :) )
http://www.tmurgent.com/TmBlog/?p=2448
Also check the review from MVP Rory Monaghan about Project C in his blog below.
http://rorymon.com/blog/?p=3490
Also check the blog post from Simon Binder below.
https://bindertech.wordpress.com/2016/04/08/get-started-with-project-centennial/

You can also watch the below video from Microsoft Channel9  to know more about the use of Desktop App Converter tool to convert desktop apps to UWP with demo.


To know more check the below official link from Microsoft.

https://developer.microsoft.com/en-us/windows/bridges/desktop