diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 new file mode 100644 index 000000000..344ff8fbd --- /dev/null +++ b/msix/CreateMsix.ps1 @@ -0,0 +1,306 @@ +<# +.SYNOPSIS + Script to handle a zip file by either copying it from a local location or downloading it from a URL. + +.DESCRIPTION + This script automates the process of creating an MSIX package for OpenJDK distributions. It accepts either a local zip file path or a URL to a zip file (containing a zip file of the JDK binaries), extracts the contents, and prepares the necessary folder structure. The script generates an AppXManifest.xml file using provided metadata, copies required configuration files, and uses Windows SDK tools to package the files into an MSIX installer. Optionally, it can sign the resulting MSIX package if a signing certificate and password are provided. The script supports customization of package metadata such as display name, description, vendor, and output file name. + +.PARAMETER ZipFilePath + Optional. The local path to a zip file to be copied and unzipped. + +.PARAMETER ZipFileUrl + Optional. The URL of a zip file to be downloaded and unzipped. + +.PARAMETER PackageName + Optional. The name of the package. Cannot contain spaces or underscores. + IMPORTANT: This needs to be consistent with previous releases for upgrades to work as expected + Note: The output file will be named: $PackageName.msix + If not provided, a default name will have the following format: "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion" + +.PARAMETER Vendor + Optional. Default: Eclipse Adoptium + +.PARAMETER VendorBranding + Optional. Helps determine default values for $MSIXDisplayName and $Description, + but goes unused if those are both provided. + Default: Eclipse Temurin + +.PARAMETER MsixDisplayName + Optional. Example: "Eclipse Temurin 17.0.15+6 (x64)". + This is the display name of the MSIX package. + Default: "$VendorBranding $ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion+$ProductBuildNumber ($Arch)". + +.PARAMETER Description + Optional. Example: "Eclipse Temurin Development Kit with Hotspot". + Default: $VendorBranding + +.PARAMETER ProductMajorVersion + Example: if the version is 17.0.15+6, this is 17 + +.PARAMETER ProductMinorVersion + Example: if the version is 17.0.15+6, this is 0 + +.PARAMETER ProductMaintenanceVersion + Example: if the version is 17.0.15+6, this is 15 + +.PARAMETER ProductBuildNumber + Example: if the version is 17.0.15+6, this is 6 + +.PARAMETER Arch + Valid architectures: x86, x64, arm, arm64, x86a64, neutral + +.PARAMETER PublisherCN + Set this to everything on the right side of your `CN=` field in your .pfx file. + This may include additional fields in the name, such as 'O=...', 'L=...', 'S=...', and/or others. + +.PARAMETER SigningCertPath + Optional. The path to the signing certificate (.pfx) file used to sign the package. + If not provided, the script will not sign the package. + +.PARAMETER SigningPassword + Optional. The password for the signing certificate. + Only needed if the SigningCertPath is provided. + +.PARAMETER OutputFileName + Optional. The name of the output file. + If not provided, a default name will be generated based of the following format: + "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion_$ProductBuildNumber.msix" + +.PARAMETER License + Optional. The URL to the license file. + Default: "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html" + +.PARAMETER VerboseTools + Optional. If set to $true, the script will output verbose messages. + Default: $false + +.EXAMPLE + # Only mandatory inputs are defined here + .\CreateMsix.ps1 ` + -ZipFilePath "C:\path\to\file.zip" ` + -PackageName "OpenJDK17U-jdk-x64-windows-hotspot" ` + -PublisherCN "ExamplePublisher" ` + -ProductMajorVersion 17 ` + -ProductMinorVersion 0 ` + -ProductMaintenanceVersion 15 ` + -ProductBuildNumber 6 ` + -Arch "x64" ` + +.EXAMPLE + # All inputs are defined here + .\CreateMsix.ps1 ` + # Mandatory inputs + -ZipFileUrl "https://example.com/file.zip" ` + -PackageName "OpenJDK21U-jdk-x64-windows-hotspot" ` + -PublisherCN "ExamplePublisher" ` + -ProductMajorVersion 21 ` + -ProductMinorVersion 0 ` + -ProductMaintenanceVersion 7 ` + -ProductBuildNumber 6 ` + -Arch "aarch64" ` + # Optional inputs: These are the defaults that will be used if not specified + -Vendor "Eclipse Adoptium" ` + -VendorBranding "Eclipse Temurin" ` + -MsixDisplayName "Eclipse Temurin 17.0.15+6 (x64)" ` + -Description "Eclipse Temurin" ` + # Optional Inputs: omitting these inputs will cause their associated process to be skipped + -SigningCertPath "C:\path\to\cert.pfx" + -SigningPassword "your cert's password" + -OutputFileName "OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6.msix" ` + +.NOTES + Ensure that you have downloaded the Windows SDK (typically through installing Visual Studio). For more information, please see the #Dependencies section of the README.md file. After doing so, please modify the following environment variables if the defaults shown below are not correct: + $Env:WIN_SDK_FULL_VERSION = "10.0.22621.0" + $Env:WIN_SDK_MAJOR_VERSION = "10" +#> + +param ( + [Parameter(Mandatory = $false)] + [string]$ZipFilePath, + + [Parameter(Mandatory = $false)] + [string]$ZipFileUrl, + + [Parameter(Mandatory = $true)] + [string]$PackageName, + + [Parameter(Mandatory = $true)] + [string]$PublisherCN, + + [Parameter(Mandatory = $true)] + [int]$ProductMajorVersion, + + [Parameter(Mandatory = $true)] + [int]$ProductMinorVersion, + + [Parameter(Mandatory = $true)] + [int]$ProductMaintenanceVersion, + + [Parameter(Mandatory = $true)] + [int]$ProductBuildNumber, + + [Parameter(Mandatory = $true)] + [string]$Arch, + + [Parameter(Mandatory = $false)] + [string]$Vendor = "Eclipse Adoptium", + + [Parameter(Mandatory = $false)] + [string]$VendorBranding = "Eclipse Temurin", + + [Parameter(Mandatory = $false)] + [string]$MsixDisplayName = "", + + [Parameter(Mandatory = $false)] + [string]$OutputFileName, + + [Parameter(Mandatory = $false)] + [string]$Description = "", + + [Parameter(Mandatory = $false)] + [string]$SigningCertPath, + + [Parameter(Mandatory = $false)] + [string]$SigningPassword, + + [Parameter(Mandatory = $false)] + [string]$License = "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html", + + [Parameter(Mandatory = $false)] + [Alias("v")] + [switch]$VerboseTools +) + +# Get the path to msix folder (parent directory of this script) +$MsixDirPath = Split-Path -Parent $MyInvocation.MyCommand.Path + +# Find and source the Helpers.ps1 script located in the scripts folder to get access to helper functions +$HelpersScriptPath = Join-Path -Path $MsixDirPath -ChildPath "scripts\Helpers.ps1" +if (-not (Test-Path -Path $HelpersScriptPath)) { + throw "Error: The Helpers.ps1 script was not found at '$HelpersScriptPath'." +} +. $HelpersScriptPath +# Validate the inputs +## Ensure that we have an AppXManifestTemplate.xml file corresponding to the provided jdk major version +ValidateMajorVersion -majorVersion $ProductMajorVersion + +## Ensure that either a local zip file path or a URL is provided, but not both +ValidateZipFileInput -ZipFilePath $ZipFilePath -ZipFileUrl $ZipFileUrl +## Ensure that both or neither of the signing inputs are provided +ValidateSigningInput -SigningCertPath $SigningCertPath -SigningPassword $SigningPassword + +# Set default values if optional parameters are not provided +$MsixDisplayName = SetDefaultIfEmpty ` + -InputValue $MsixDisplayName ` + -DefaultValue "$VendorBranding $ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion+$ProductBuildNumber ($Arch)" + +$Description = SetDefaultIfEmpty ` + -InputValue $Description ` + -DefaultValue "$VendorBranding" + +$OutputFileName = SetDefaultIfEmpty ` + -InputValue $OutputFileName ` + -DefaultValue "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion_$ProductBuildNumber.msix" + +# Ensure SetupEnv.ps1 exists, then source it for access to functions +$SetupEnvScriptPath = Join-Path -Path $MsixDirPath -ChildPath "scripts\SetupEnv.ps1" +if (-not (Test-Path -Path $SetupEnvScriptPath)) { + throw "Error: The SetupEnv.ps1 script was not found at '$SetupEnvScriptPath'." +} +. $SetupEnvScriptPath +# Get the path to the Windows SDK tools +$WindowsSdkPath = Get-WindowsSdkPath ` + -WIN_SDK_FULL_VERSION $Env:WIN_SDK_FULL_VERSION ` + -WIN_SDK_MAJOR_VERSION $Env:WIN_SDK_MAJOR_VERSION ` + -Arch $Arch +Write-Host "Windows SDK path: $WindowsSdkPath" + +# Clean the srce, workspace, and output folders +$srcFolder = Clear-TargetFolder ` + -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "src") ` + -ExcludeSubfolder "_msix_logos" +$workspaceFolder = Clear-TargetFolder -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "workspace") +$outputFolder = Clear-TargetFolder -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "output") +Write-Host "Folders cleaned: $srcFolder, $workspaceFolder, $outputFolder" + +# Download zip file if a URL is provided, otherwise use the local path +if ($ZipFileUrl) { + Write-Host "Downloading zip file from URL: $ZipFileUrl" + $ZipFilePath = DownloadFileFromUrl -Url $ZipFileUrl -DestinationDirectory $workspaceFolder +} +Write-Host "Using ZipFilePath: $ZipFilePath" +UnzipFile -ZipFilePath $ZipFilePath -DestinationPath $workspaceFolder + +# Move contents of the unzipped file to $srcFolder +$unzippedFolder = Join-Path -Path $workspaceFolder -ChildPath (Get-ChildItem -Path $workspaceFolder -Directory | Select-Object -First 1).Name +Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $srcFolder -Force +Remove-Item -Path $unzippedFolder -Recurse -Force + +$appxTemplate = Join-Path -Path $MsixDirPath -ChildPath "templates\AppXManifestTemplate${ProductMajorVersion}.xml" +$content = Get-Content -Path $appxTemplate + +# Replace all instances of placeholders with the provided values +$updatedContent = $content ` + -replace "\{VENDOR\}", $Vendor ` + -replace "\{MSIX_DISPLAYNAME\}", $MsixDisplayName ` + -replace "\{PACKAGE_NAME\}", $PackageName ` + -replace "\{DESCRIPTION\}", "$Description using license: $License" ` + -replace "\{PRODUCT_MAJOR_VERSION\}", $ProductMajorVersion ` + -replace "\{PRODUCT_MINOR_VERSION\}", $ProductMinorVersion ` + -replace "\{PRODUCT_MAINTENANCE_VERSION\}", $ProductMaintenanceVersion ` + -replace "\{PRODUCT_BUILD_NUMBER\}", $ProductBuildNumber ` + -replace "\{ARCH\}", $Arch ` + -replace "\{PUBLISHER_CN\}", $PublisherCN + + +# Write the updated content to the new AppXManifest.xml file +$appxManifestPath = Join-Path -Path $srcFolder -ChildPath "AppXManifest.xml" +Set-Content -Path $appxManifestPath -Value $updatedContent +Write-Host "AppXManifest.xml created at '$appxManifestPath'" + +# Copy pri_config.xml to the target folder (path from SetupEnv.ps1) +$priConfig = Join-Path -Path $MsixDirPath -ChildPath "templates\pri_config.xml" +Copy-Item -Path $priConfig -Destination $srcFolder -Force +Write-Host "pri_config.xml copied to '$srcFolder'" + +# Set EXTRA_ARGS to '/v' if VerboseTools is specified +if ($VerboseTools) { + $EXTRA_ARGS = '/v' +} +else { + $EXTRA_ARGS = '' +} + +# Create _resources.pri file based on pri_config.xml +& "$WindowsSdkPath\makepri.exe" new $EXTRA_ARGS ` + /Overwrite ` + /ProjectRoot $srcFolder ` + /ConfigXml "$srcFolder\pri_config.xml" ` + /OutputFile "$srcFolder\_resources.pri" ` + /MappingFile appx + +CheckForError -ErrorMessage "Error: makepri.exe failed to create _resources.pri file." + +# Create the MSIX package +& "$WindowsSdkPath\makeappx.exe" pack $EXTRA_ARGS ` + /overwrite ` + /d "$srcFolder" ` + /p "$outputFolder\$OutputFileName" + +CheckForError -ErrorMessage "Error: makeappx.exe failed to create the MSIX package." + +# Sign the MSIX package if a signing certificate is provided +if ($SigningCertPath) { + & "$WindowsSdkPath\signtool.exe" sign $EXTRA_ARGS ` + /fd SHA256 ` + /a ` + /f $SigningCertPath ` + /p "$SigningPassword" ` + "$outputFolder\$OutputFileName" + + CheckForError -ErrorMessage "Error: signtool.exe failed to sign the MSIX package." + Write-Host "MSIX package signed successfully." +} +else { + Write-Host "SigningCertPath not provided. Skipping signing process." +} diff --git a/msix/README.md b/msix/README.md new file mode 100644 index 000000000..b0484f583 --- /dev/null +++ b/msix/README.md @@ -0,0 +1,161 @@ +# Introduction +This tool is designed to create MSIX files, the modern installer format supported by Microsoft for Windows applications. MSIX packages provide a reliable, secure, and user-friendly installation experience, including a graphical installer interface that achieves the highest standards for accessibility. When installed, java.exe is placed at `C:\Users\${env:USERNAME}\AppData\Local\${Vendor}\WindowsApps` and the rest of the binary files are downloaded to: `C:\Program Files\WindowsApps\` (See [this section](#check-info-of-installed-msix) to see how to get the package ful name). MSIX is also the required package type for distributing applications through the Microsoft Store. + +Note: Users must be on `Windows 7 SP1 (Build 7601)` or higher to install from `.msix` files. Windows users on versions prior to `Windows 10 version 1809` may need to enable sideloading in order for this installer format to work on their machine. If you are using a computer with an earlier version, you will need to enable sideloading to use `.msix` files: +1. Navigate to `Settings` > `Update & Security` > `For Developers` +1. Select `Sideload apps` +1. Restart if prompted + +If you are on Windows `7` or `8.1`, you will also need to install `MSIX Core` to enable MSIX package installation. Documentation on `MSIX Core` and links to the latest release can be found here: https://learn.microsoft.com/en-us/windows/msix/msix-core/msixcore + +# How to create MSIX files + +## Dependencies +The following files are required in order to successfully run `CreateMsix.ps1`. These files can be found within the `Windows Kits` section of the `Windows SDK` directory. +- `makepri.exe` +- `makeappx.exe` +- `signtool.exe` + +When running the `CreateMsix.ps1`, you will need to check which version(s) of the `Windows SDK` are installed. If you want to use a version other than `10.0.22621.0`, please set the following environment variables: +- `$Env:WIN_SDK_FULL_VERSION=` # (Default: 10.0.22621.0) +- `$Env:WIN_SDK_MAJOR_VERSION=` # (Default: 10) + +In order to run the commands below, you may need to add the `bin` directory of the `Windows Kits` section of the Windows SDK. We currently default to using `10.0.22621.0`, so the default path that we use in the script is: `C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64` (here, the `10` is the `WIN_SDK_MAJOR_VERSION`). + +## Creating MSIX files through CreateMsix.ps1 +Please take a look at the [Dependencies](#dependencies) section above to make sure that you have everything needed in order to run our `CreateMsix.ps1` script successfully. In this section, you will find a few examples for how to run our script from a powershell terminal. + +For more information on each variable, use the `powershell` command `Get-Help -Detailed .\CreateMsix.ps1` or see the `powershell` style header within `msix/CreateMsix.ps1` + +IMPORTANT: Make sure to set the `-PackageName`, as this needs to be consistent between releases for upgrades to work as expected. This also dictates the output file's name (which becomes `$PackageName.msix`) + +**First Example**: Running with all required + optional inputs. Below, you will see the inputs divided into sections: required, optional with a default value (shown below), and optional + changes behavior if omitted. This example builds an Eclipse Temurin msix file for jdk `21.0.7+6` +```powershell +.\CreateMsix.ps1 ` + # Mandatory inputs + -ZipFileUrl "https://example.com/file.zip" ` + -PackageName "OpenJDK21U-jdk-x64-windows-hotspot" ` # Cannot contain spaces or underscores + -PublisherCN "ExamplePublisher" ` # everything on the right side of your `CN=` field in your .pfx file. + -ProductMajorVersion 21 ` + -ProductMinorVersion 0 ` + -ProductMaintenanceVersion 7 ` + -ProductBuildNumber 6 ` + -Arch "aarch64" ` + # Optional inputs: These are the defaults that will be used if not specified + -Vendor "Eclipse Adoptium" ` + -VendorBranding "Eclipse Temurin" ` # Only determines default values for $MsixDisplayName and $Description, unused if those both provided + -MsixDisplayName "Eclipse Temurin 21.0.7+6 (x64)" ` + -OutputFileName "OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6.msix" ` + -Description "Eclipse Temurini using license: https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html" ` # Example: "Eclipse Temurin Development Kit with Hotspot" + # Optional Inputs: omitting these inputs will cause their associated process to be skipped + -SigningCertPath "C:\path\to\cert.pfx" # Used to sign with signtool.exe, typically .pfx file + -SigningPassword "your cert's password" + -License "https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html" # The URL to the license file. + -VerboseTools # Sets Windows SDK tools to verbose output +``` + +**Second Example**: Running with only required inputs. This will produce an MSIX file, but many values (ex: MsixDisplayName) will take the default Eclipse/Adoptium value. Note: either `-ZipFilePath` or `-ZipFileUrl` are required inputs, but you cannot specify both. This example builds an Eclipse Temurin msix file for jdk `17.0.15+6` +```powershell +.\CreateMsix.ps1 ` + -ZipFilePath "C:\path\to\file.zip" ` + -PackageName "OpenJDK17U-jdk-x64-windows-hotspot" ` # Cannot contain spaces or underscores + -PublisherCN "ExamplePublisher" ` # everything on the right side of your `CN=` field in your .pfx file. + -ProductMajorVersion 17 ` + -ProductMinorVersion 0 ` + -ProductMaintenanceVersion 15 ` + -ProductBuildNumber 6 ` + -Arch "x64" ` +``` +## Creating MSIX Files Manually +Here, much of the work comes from ensuring that the `AppXManifest.xml` file contains the correct configuration parameters. If you would like to manually build your `msix` files, you can follow the commands in the sections below after: +1. Copying `msix/templates/pri_config.xml` to your project root +2. Creating `AppXManifest.xml` in your project root (you may find that our template file at `msix/templates/AppXManifestTemplate.xml` will be a good place to start) +3. Following the instructions in the [Dependencies](#dependencies) section + +### Make resources.pri file (Needed for MSIX creation) +Assumptions: +- There is a file in the `/pr` (project root) directory called `AppXManifest.xml` + - If not, please specify the `/mn` flag and set the path to your manifest xml file. This will create the `.pri` file that we need to create `.msix` files +- The bin `bin` of the `Windows Kits` section of the `Windows SDK` directory is added to your path. + - We currently default to using `10.0.22621.0`, so the default path that we use in the script is: `C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64` + - Alternative: each command can be run by specifying the full path to the file. Example: `C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\makepri.exe` +```powershell +makepri.exe new ` + /o ` + /pr "C:\path\to\your\project\root\dir" ` + /cf "C:\path\to\pri\config.xml" ` + /of "C:\output_filename.pri" ` + /mf appx +``` + +### Make .msix file +Now, we will use the generated `.pri` file to create our `.msix` file +```powershell +makeappx.exe pack ` + /o ` + /d "C:\path\to\your\content\directory" ` + /p "output_filename.msix" +``` + +### Sign MSIX file +Notes +- See [this page](https://learn.microsoft.com/en-us/windows/win32/appxpkg/how-to-create-a-package-signing-certificate) for help on creating your .pfx file +- You will also need to add your cert to your list of trusted publishers +- Windows will not allow you to install an unsigned MSIX file, even in developer mode + - ie: the step above is mandatory for testing new `msix` files made locally, even if they are not intended to be published +```powershell +signtool.exe sign ` + /fd SHA256 ` + /a ` + /f "C:\path\to\your\certfile.pfx" ` + /p "your_pfx_file_password" ` + your_package_file.msix +``` + +# Using MSIX files +Note: These commands must be run from a terminal with administrator privileges + +## Install using MSIX file +- If your `.msix` file was signed with a certificate trusted by Microsoft, you should be able to double-click it and install it via the GUI. +- If it was signed by a certificate trusted only by the local computer, you need to run the PowerShell command below from a terminal with administrator privileges +- If your `.msix` file is not signed, you will not be able to install it (even if your machine is in developer mode. See [the developer's section](#installing-test-builds-as-a-developer) for an alternate solution in that case.) +```powershell +Add-AppxPackage -Path C:\path\to\msix\file.msix -AllowUnsigned -verbose +``` + +## Installing test builds as a developer + +If you are testing a new `.msix` file as a developer, there is another way to test installation: +1. Enable Developer Mode enabled on your PC +1. Rename the `.msix` to a `.zip` file +1. Extract it +1. Run the following powershell command to "install" an unsigned package: +```powershell +Add-AppxPackage -Register +``` + +## Check info of installed MSIX +Get info on all packages installed via MSIX: + +**Note**: You can add the `AllUsers` flag to `Get-AppxPackage` to see the output for every user on the PC. +```powershell +Get-AppxPackage | Select Name, PackageFullName +``` + +Narrow down the information to only packages containing the substring `jdk`: +```powershell +Get-AppxPackage -Name *jdk* | Select-Object Name, PackageFullName +``` + +Get more detailed information on a specific MSIX package: +```powershell +Get-AppxPackage -Name "package-name" +``` + +## Uninstall MSIX +```powershell +Remove-AppxPackage -package "package-full-name" +``` +**Note 1**: The `package-full-name` must appear as it does in the `PackageFullName` attribute found via `Get-AppPackage`, including the package_ID at the end + +**Note 2**: You can add the `AllUsers` flag to `Remove-AppxPackage` to remove the package for every user on the PC. \ No newline at end of file diff --git a/msix/scripts/Helpers.ps1 b/msix/scripts/Helpers.ps1 new file mode 100644 index 000000000..cea626d79 --- /dev/null +++ b/msix/scripts/Helpers.ps1 @@ -0,0 +1,125 @@ +<# +.SYNOPSIS + Helper functions for OpenJDK MSIX packaging scripts. + +.DESCRIPTION + This script provides utility functions for validating input, downloading files, unzipping archives, and handling signing parameters. + Intended for use in the OpenJDK MSIX installer build process. + +.NOTES + File Name: Helpers.ps1 + +#> + +function ValidateMajorVersion { + param( + [Parameter(Mandatory=$true)] + [int]$majorVersion + ) + + # Define valid major versions + $validMajorVersions = @(11, 17, 21) + + if ($validMajorVersions -contains $majorVersion) { + Write-Host "The major version ($majorVersion) is valid." + } else { + Write-Host "The major version ($majorVersion) is NOT valid. Valid versions are: $($validVersions -join ', ')." + exit 1 + } +} + +function ValidateZipFileInput { + param ( + [string]$ZipFilePath, + [string]$ZipFileUrl + ) + if (-not $ZipFilePath -and -not $ZipFileUrl) { + throw "Error: You must provide either -ZipFilePath or -ZipFileUrl." + } + elseif ($ZipFilePath -and $ZipFileUrl) { + throw "Error: You cannot provide both -ZipFilePath and -ZipFileUrl." + } + else { + Write-Host "ZipFile input validation passed." + } +} + +function ValidateSigningInput { + param ( + [string]$SigningCertPath, + [string]$SigningPassword + ) + if ( + ($SigningPassword -and -not $SigningCertPath) -or + ($SigningCertPath -and -not $SigningPassword) + ) { + throw "Error: Both SigningCertPath and SigningPassword must be provided together." + } + else { + Write-Host "Signing input validation passed." + } +} + +function SetDefaultIfEmpty { + param ( + [string]$InputValue, + [string]$DefaultValue + ) + if (-not $InputValue) { + return $DefaultValue + } + else { + return $InputValue + } +} + +function DownloadFileFromUrl { + param ( + [string]$Url, + [string]$DestinationDirectory + ) + if (-not (Test-Path -Path $DestinationDirectory)) { + New-Item -ItemType Directory -Path $DestinationDirectory | Out-Null + } + $fileName = [System.IO.Path]::GetFileName($ZipFileUrl) + $downloadPath = Join-Path -Path $DestinationDirectory -ChildPath $fileName + + Write-Host "Downloading file from $Url to $DestinationDirectory" + + # download zip file (needs to be silent or it will print the progress bar and take ~30 times as long to download) + $OriginalLocalProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $Url -OutFile $downloadPath + $ProgressPreference = $OriginalLocalProgressPreference + + return $downloadPath +} + +function UnzipFile { + param ( + [string]$ZipFilePath, + [string]$DestinationPath + ) + if (-not (Test-Path -Path $ZipFilePath)) { + throw "Error: Zip file not found at path: $ZipFilePath" + } + if (-not (Test-Path -Path $DestinationPath)) { + New-Item -ItemType Directory -Path $DestinationPath | Out-Null + } + Write-Host "Unzipping file $ZipFilePath to $DestinationPath" + + # Unzip file (needs to be silent or it will print the progress bar and take much longer) + $OriginalProgressPreference = $global:ProgressPreference + $global:ProgressPreference = 'SilentlyContinue' + Expand-Archive -Path $ZipFilePath -DestinationPath $DestinationPath -Force + $global:ProgressPreference = $OriginalProgressPreference +} + +function CheckForError { + param ( + [string]$ErrorMessage + ) + if ($LASTEXITCODE -ne 0) { + throw "Error: $ErrorMessage" + } +} \ No newline at end of file diff --git a/msix/scripts/SetupEnv.ps1 b/msix/scripts/SetupEnv.ps1 new file mode 100644 index 000000000..d820982c2 --- /dev/null +++ b/msix/scripts/SetupEnv.ps1 @@ -0,0 +1,58 @@ +<# +.SYNOPSIS + Helper script for defining functions that help setup the build environment. + +.DESCRIPTION + This script provides a helper function to assist with build environment setup. + It includes functions to get the path to the Windows SDK and to clean a target folder. + +.NOTES + File Name: SetupEnv.ps1 +#> + +function Get-WindowsSdkPath { + param( + [string]$Arch, + [string]$WIN_SDK_FULL_VERSION = $null, + [string]$WIN_SDK_MAJOR_VERSION = $null + ) + + # Set defaults if parameters are not provided + if (-not $WIN_SDK_FULL_VERSION) { + $WIN_SDK_FULL_VERSION = "10.0.22621.0" + } + if (-not $WIN_SDK_MAJOR_VERSION) { + $WIN_SDK_MAJOR_VERSION = "10" + } + + Write-Host "WIN_SDK_FULL_VERSION is set to $WIN_SDK_FULL_VERSION." + Write-Host "WIN_SDK_MAJOR_VERSION is set to $WIN_SDK_MAJOR_VERSION." + + $WindowsSdkPath = Join-Path -Path "${Env:ProgramFiles(x86)}\Windows Kits\$WIN_SDK_MAJOR_VERSION\bin\$WIN_SDK_FULL_VERSION" -ChildPath $Arch + + return $WindowsSdkPath +} + +function Clear-TargetFolder { + param( + [string]$TargetFolder, + [string]$ExcludeSubfolder = $null + ) + if (-not (Test-Path -Path $TargetFolder)) { + New-Item -ItemType Directory -Path $TargetFolder | Out-Null + Write-Host "Created folder: $TargetFolder" + } + + if ($ExcludeSubfolder) { + Get-ChildItem -Path $TargetFolder -Recurse | Where-Object { + $_.FullName -notlike "*\$ExcludeSubfolder*" + } | Remove-Item -Recurse -Force + Write-Host "Cleaned $TargetFolder, excluding $ExcludeSubfolder." + } + else { + Get-ChildItem -Path $TargetFolder -Recurse | Remove-Item -Recurse -Force + Write-Host "Cleaned $TargetFolder." + } + + return $TargetFolder +} \ No newline at end of file diff --git a/msix/src/_msix_logos/duke150.png b/msix/src/_msix_logos/duke150.png new file mode 100644 index 000000000..1eb0a8fc9 Binary files /dev/null and b/msix/src/_msix_logos/duke150.png differ diff --git a/msix/src/_msix_logos/duke44.png b/msix/src/_msix_logos/duke44.png new file mode 100644 index 000000000..c3c28472b Binary files /dev/null and b/msix/src/_msix_logos/duke44.png differ diff --git a/msix/src/_msix_logos/duke50.png b/msix/src/_msix_logos/duke50.png new file mode 100644 index 000000000..6516e2a32 Binary files /dev/null and b/msix/src/_msix_logos/duke50.png differ diff --git a/msix/templates/AppXManifestTemplate11.xml b/msix/templates/AppXManifestTemplate11.xml new file mode 100644 index 000000000..d6a7ed7fe --- /dev/null +++ b/msix/templates/AppXManifestTemplate11.xml @@ -0,0 +1,849 @@ + + + + + + + {MSIX_DISPLAYNAME} + {VENDOR} + {DESCRIPTION} + _msix_logos/duke50.png + disabled + disabled + defer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .jar + + + open + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msix/templates/AppXManifestTemplate17.xml b/msix/templates/AppXManifestTemplate17.xml new file mode 100644 index 000000000..0e78a3c0f --- /dev/null +++ b/msix/templates/AppXManifestTemplate17.xml @@ -0,0 +1,769 @@ + + + + + + + {MSIX_DISPLAYNAME} + {VENDOR} + {DESCRIPTION} + _msix_logos/duke50.png + disabled + disabled + defer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .jar + + + open + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msix/templates/AppXManifestTemplate21.xml b/msix/templates/AppXManifestTemplate21.xml new file mode 100644 index 000000000..95f7e07d9 --- /dev/null +++ b/msix/templates/AppXManifestTemplate21.xml @@ -0,0 +1,789 @@ + + + + + + + {MSIX_DISPLAYNAME} + {VENDOR} + {DESCRIPTION} + _msix_logos/duke50.png + disabled + disabled + defer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .jar + + + open + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msix/templates/pri_config.xml b/msix/templates/pri_config.xml new file mode 100644 index 000000000..501c2b401 --- /dev/null +++ b/msix/templates/pri_config.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file