From 806dd66415c68053f8f95190a7dec2dcc32c1c68 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 13 May 2025 10:31:55 -0700 Subject: [PATCH 01/39] Initial commit to new MSIX method --- msix/README.md | 51 ++++++ msix/create_msix.ps1 | 215 ++++++++++++++++++++++++ msix/resources/duke150.png | Bin 0 -> 924 bytes msix/resources/duke44.png | Bin 0 -> 311 bytes msix/resources/duke50.png | Bin 0 -> 358 bytes msix/templates/AppXManifestTemplate.xml | 100 +++++++++++ msix/templates/pri_config.xml | 28 +++ 7 files changed, 394 insertions(+) create mode 100644 msix/README.md create mode 100644 msix/create_msix.ps1 create mode 100644 msix/resources/duke150.png create mode 100644 msix/resources/duke44.png create mode 100644 msix/resources/duke50.png create mode 100644 msix/templates/AppXManifestTemplate.xml create mode 100644 msix/templates/pri_config.xml diff --git a/msix/README.md b/msix/README.md new file mode 100644 index 000000000..b58bfee98 --- /dev/null +++ b/msix/README.md @@ -0,0 +1,51 @@ +# How to create MSIX files + +## Make resources.pri file (Needed for MSIX creation) +```shell +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 +``` +Note: This assumes you have a file in your `/pr` directory called AppXManifest.xml. If not, you will need to specify the `/mn` flag and set the path to your manifest xml file + +## Make .msix file +```shell +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 let you install from an unsigned MSIX file, even in developer mode +```shell +signtool.exe sign /fd SHA256 /a /f C:\path\to\your\certfile.pfx /p "your_pfx_file_password" your_package_file.msix +``` + +# Install, get info, and uninstall +Note: Must be run from a terminal with administrator privileges] + +## Install from msix file +```shell +Add-AppPackage -Path C:\path\to\msix\file.msix -AllowUnsigned -verbose +``` + +## Check info of insallted MSIX +Get info on all packages installed via MSIX: +```shell +Get-AppPackage -AllUsers | Select Name, PackageFullName +``` + +Narrow down info to just packages containing the substring `jdk`: +```shell +Get-AppPackage -AllUsers | Select Name, PackageFullName | Select-String -Pattern "jdk" +``` + +Get more detailed information on a specific MSIX package: +```shell +Get-AppPackage -Name "package-name" +``` + +## Uninstall MSIX +```shell +Remove-AppPackage -AllUsers -package "package-full-name" +``` +Note: Name must appear as it does when found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file diff --git a/msix/create_msix.ps1 b/msix/create_msix.ps1 new file mode 100644 index 000000000..1dbc9d8ad --- /dev/null +++ b/msix/create_msix.ps1 @@ -0,0 +1,215 @@ +<# +.SYNOPSIS + Script to handle a zip file by either copying it from a local location or downloading it from a URL. + +.DESCRIPTION + This script accepts one of two optional inputs: + 1. A local zip file path to copy and unzip into the 'src' folder. + 2. A URL to download a zip file and unzip it into the 'src' folder. + If neither or both inputs are provided, the script will throw an error. + +.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 Vendor + Optional. Example: Eclipse Adoptium. + +.PARAMETER VendorBranding + Optional. Example: Eclipse Temurin + +.PARAMETER Description + Optional. Example: "Development Kit with Hotspot". + +.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 + Examples: x86, x64, arm64. + +.PARAMETER PublisherCN + Set this to anything 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. + +.EXAMPLE + .\create_msix.ps1 -ZipFilePath "C:\path\to\file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 17 -ProductMinorVersion 0 -ProductMaintenanceVersion 15 -ProductBuildNumber 6 -Arch "x64" -PublisherCN "ExamplePublisher" -SigningCertPath "C:\path\to\cert.pfx" -SigningPassword "myPass" + +.EXAMPLE + .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" + +.NOTES + Ensure the 'src' folder exists in the current directory before running the script. +#> + +param ( + [Parameter(Mandatory = $false)] + [string]$ZipFilePath, + + [Parameter(Mandatory = $false)] + [string]$ZipFileUrl, + + [Parameter(Mandatory = $false)] + [string]$Vendor = "Eclipse Adoptium", + + [Parameter(Mandatory = $false)] + [string]$VendorBranding = "Eclipse Temurin", + + [Parameter(Mandatory = $false)] + [string]$Description = "Development Kit with Hotspot" + + [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 = $true)] + [string]$PublisherCN, + + [Parameter(Mandatory = $false)] + [string]$SigningCertPath, + + [Parameter(Mandatory = $false)] + [string]$SigningPassword, +) + +# Validate inputs +if (-not $ZipFilePath -and -not $ZipFileUrl) { + throw "Error: You must provide either -ZipFilePath or -ZipFileUrl." +} +if ($ZipFilePath -and $ZipFileUrl) { + throw "Error: You cannot provide both -ZipFilePath and -ZipFileUrl." +} + +# Ensure 'src' folder exists +$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path +$srcFolder = Join-Path -Path $scriptPath -ChildPath "src" +if (-not (Test-Path -Path $srcFolder)) { + New-Item -ItemType Directory -Path $srcFolder | Out-Null +} + +# Handle ZipFilePath +if ($ZipFilePath) { + if (-not (Test-Path -Path $ZipFilePath)) { + throw "Error: The file at path '$ZipFilePath' does not exist." + } + $destinationPath = Join-Path -Path $srcFolder -ChildPath (Split-Path -Leaf $ZipFilePath) + # Copy and unzip the file + Copy-Item -Path $ZipFilePath -Destination $destinationPath + Expand-Archive -Path $destinationPath -DestinationPath $srcFolder -Force + # Remove the zip file since contents are extracted + Remove-Item -Path $destinationPath -Force + Write-Host "Zip file copied and extracted to 'src' folder." +} + +# Handle ZipFileUrl +if ($ZipFileUrl) { + $fileName = [System.IO.Path]::GetFileName($ZipFileUrl) + $downloadPath = Join-Path -Path $srcFolder -ChildPath $fileName + # download zip file + Invoke-WebRequest -Uri $ZipFileUrl -OutFile $downloadPath + # unzip file + Expand-Archive -Path $downloadPath -DestinationPath $srcFolder -Force + # remove zip file since conentets are extracted + Remove-Item -Path $downloadPath -Force + Write-Host "Zip file downloaded and extracted to 'src' folder." +} + +## Update the file content of AppXManifest.xml +# Define the path to the file +$appxTemplate = Join-Path -Path $scriptPath -ChildPath "tempaltes\AppXManifestTemplate.xml" +$priConfig = Join-Path -Path $scriptPath -ChildPath "tempaltes\pri_config.xml" + +# Read the content of the file +$content = Get-Content -Path $appxTemplate + +# Create a variable by replacing spaces and underscores with dashes in $VendorBranding +$vendorBrandingDashes = $VendorBranding -replace "[ _]", "-" + +# Replace all instances of placeholders with the provided values +$updatedContent = $content ` + -replace "\{VENDOR\}", $Vendor ` + -replace "\{VENDORBRANDING\}", $VendorBranding ` + -replace "\{VENDORBRANDINGDASHES\}", $vendorBrandingDashes ` + -replace "\{DESCRIPTION\}", $Description ` + -replace "\{PRODUCTMAJORVERSION\}", $ProductMajorVersion ` + -replace "\{PRODUCTMINORVERSION\}", $ProductMinorVersion ` + -replace "\{PRODUCTMAINTENANCEVERSION\}", $ProductMaintenanceVersion ` + -replace "\{PRODUCTBUILDNUMBER\}", $ProductBuildNumber ` + -replace "\{ARCH\}", $Arch ` + -replace "\{PUBLISHERCN\}", $PublisherCN + + +# Ensure there is only one folder in the 'src' directory +$subFolders = Get-ChildItem -Path $srcFolder -Directory +if ($subFolders.Count -ne 1) { + throw "Error: The 'src' folder must contain exactly one subfolder." +} + +# Define the path to the new AppXManifest.xml file +$targetFolder = $subFolders[0].FullName +$appxManifestPath = Join-Path -Path $targetFolder -ChildPath "AppXManifest.xml" + +# Write the updated content to the new AppXManifest.xml file +Set-Content -Path $appxManifestPath -Value $updatedContent +Write-Host "AppXManifest.xml created at '$appxManifestPath'" + +# Copy pri_config.xml to the target folder +Copy-Item -Path $priConfig -Destination $targetFolder -Force +Write-Host "pri_config.xml copied to '$targetFolder'" + +makepri.exe new ` + /o ` + /pr $targetFolder ` + /cf $targetFolder\pri_config.xml ` + /of $targetFolder\_resources.pri ` + /mf appx + +makeappx.exe pack ` + /o ` + /d $targetFolder ` + /p $vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch.msix + + +if ($SigningCertPath) { + # Run signtool to sign the package without printing to logs (keeps password secret) + Start-Process -FilePath "signtool.exe" -ArgumentList @( + "sign", + "/fd", "SHA256", + "/a", + "/f", $SigningCertPath, + "/p", $SigningPassword, + ".\$vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch.msix" + ) -NoNewWindow -Wait -PassThru | Out-Null + Write-Host "MSIX package signed successfully." +} else { + Write-Host "SigningCertPath not provided. Skipping signing process." +} \ No newline at end of file diff --git a/msix/resources/duke150.png b/msix/resources/duke150.png new file mode 100644 index 0000000000000000000000000000000000000000..1eb0a8fc9882097810f823cca646c30842296f16 GIT binary patch literal 924 zcmeAS@N?(olHy`uVBq!ia0vp^(?FPm2}o{Eezui?fjQaJ#WAE}&fB>M^A0Nru+Cof z|NrTij3>Kh9b?;kVD{6qd-?7r=B)Di`1of{outwI)#3?N8=Y*zI*xOFj8K%*K9by8 zu|}X@^bv~SKAs*6wPyrYJGn*mDh0X zq1qEGKLi(OI-gltpe>|j_fbsOE=i9_fcFHv_rj8WLw)* zwIeoM+f_RcReL_=Fzh@u_vC^N>dROZ(*kx_RIKVCYsJ{5hU zWuvzATltNRa;DRZxK>M~hv(eCvS8^3#e;&I_w8Di))B>ZyJIWIoAnAyKAa0S$a;76 zx*$*BFPEsJhJU4vk52pEb*f%ViGR^_z1{XsuWp=K|3S8K<2jc{ks4c9W>2V6^3pJ| zT@&8nyvpDrv0<({fRd2;jIV`Y3Xlfn!taQ^j3QHrXP}JU47G za|!QAZ#r;tQN@mxY0Txcq0^ zjHmG&`li#;{an^L HB{Ts5bc~nC literal 0 HcmV?d00001 diff --git a/msix/resources/duke44.png b/msix/resources/duke44.png new file mode 100644 index 0000000000000000000000000000000000000000..c3c28472b927bc1c77f901ed35920d24390de566 GIT binary patch literal 311 zcmV-70m%M|P)<@-0002~Nkl>2pMJlE;6z{v z@fxc?oQg4lct2OU2eDIey2S7%W#;2M_83;g@x)W0IH0o`{dI^ht3I5HVfuAkGUyIy z3lCj;j4?va5W2M|zcI!Dk&t1G@Xr!ML*!%_Afh&m(M6SB0mEWmF9gbE_!kGdoLx@1kKtKTlOpe-ud?xh!^H6S8#nn$wvSH002ov JPDHLkV1l>Ue}4b~ literal 0 HcmV?d00001 diff --git a/msix/resources/duke50.png b/msix/resources/duke50.png new file mode 100644 index 0000000000000000000000000000000000000000..6516e2a32f45d697f9c8c4143ab05c48e1469879 GIT binary patch literal 358 zcmV-s0h#`ZP)>Yb`6Px~)xB zmax*cj*?P@)wR{@i3=-gYa}KptfDPhNkmvVTZjy|uv)fo4L)Hn$2onS+JX4LkH^+g z0Ci0LL5Hx=wI%mVk&eoYwQZetuK&FwtwnqMQvEjrimCh?x0DS`A+1w zuK6G$6PCeN{3!}gu>FXUfraT@6f3Kx0dowt;q8u{CcFEhi7LW~-7{k!;N#*$eqR)*4m9T0>iF z-foOmVX#)J8m%~dI$aNUth24FXin?4`wf|)ZY)c^0s63Gh<}goz5oCK07*qoM6N<$ Ef+07cOaK4? literal 0 HcmV?d00001 diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml new file mode 100644 index 000000000..e647b26e3 --- /dev/null +++ b/msix/templates/AppXManifestTemplate.xml @@ -0,0 +1,100 @@ + + + + + + + {VENDOR_BRANDING} {PRODUCT_MAJOR_VERSION}.{PRODUCT_MINOR_VERSION}.{PRODUCT_MAINTENANCE_VERSION}+{PRODUCT_BUILD_NUMBER} ({ARCH}) + {VENDOR} + {VENDOR_BRANDING} {DESCRIPTION} + resources/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 From 521e1a56b17d42226e775683195e9ae694a402e6 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 13 May 2025 15:00:38 -0700 Subject: [PATCH 02/39] Cleaned up code, now fully able to download + sign from URL --- msix/create_msix.ps1 | 145 +++++++++++++----------- msix/resources/duke150.png | Bin 924 -> 0 bytes msix/resources/duke44.png | Bin 311 -> 0 bytes msix/resources/duke50.png | Bin 358 -> 0 bytes msix/scripts/setup-env.ps1 | 39 +++++++ msix/templates/AppXManifestTemplate.xml | 10 +- 6 files changed, 125 insertions(+), 69 deletions(-) delete mode 100644 msix/resources/duke150.png delete mode 100644 msix/resources/duke44.png delete mode 100644 msix/resources/duke50.png create mode 100644 msix/scripts/setup-env.ps1 diff --git a/msix/create_msix.ps1 b/msix/create_msix.ps1 index 1dbc9d8ad..2d169342c 100644 --- a/msix/create_msix.ps1 +++ b/msix/create_msix.ps1 @@ -50,11 +50,15 @@ Optional. The password for the signing certificate. Only needed if the SigningCertPath is provided. +.PARAMETER Quiet + Optional. If specified, suppresses output messages. Recommended for use in automated scripts, or when downloading zip files from a URL. + This is an alias for -q. + .EXAMPLE .\create_msix.ps1 -ZipFilePath "C:\path\to\file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 17 -ProductMinorVersion 0 -ProductMaintenanceVersion 15 -ProductBuildNumber 6 -Arch "x64" -PublisherCN "ExamplePublisher" -SigningCertPath "C:\path\to\cert.pfx" -SigningPassword "myPass" .EXAMPLE - .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" + .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" -Quiet .NOTES Ensure the 'src' folder exists in the current directory before running the script. @@ -74,7 +78,7 @@ param ( [string]$VendorBranding = "Eclipse Temurin", [Parameter(Mandatory = $false)] - [string]$Description = "Development Kit with Hotspot" + [string]$Description = "Development Kit with Hotspot", [Parameter(Mandatory = $true)] [int]$ProductMajorVersion, @@ -99,117 +103,130 @@ param ( [Parameter(Mandatory = $false)] [string]$SigningPassword, + + [Parameter(Mandatory = $false, HelpMessage = "Include this flag to output verbose messages.")] + [Alias("v")] + [switch]$VerboseOutput ) -# Validate inputs +###### Validate inputs if (-not $ZipFilePath -and -not $ZipFileUrl) { throw "Error: You must provide either -ZipFilePath or -ZipFileUrl." } if ($ZipFilePath -and $ZipFileUrl) { throw "Error: You cannot provide both -ZipFilePath and -ZipFileUrl." } +if (($SigningPassword -and -not $SigningCertPath) -or ($SigningCertPath -and -not $SigningPassword)) { + throw "Error: Both SigningCertPath and SigningPassword must be provided together." +} +# Set $ProgressPreference to 'SilentlyContinue' if the the verbose flag is not set +if (-not $VerboseOutput) { + $OriginalProgressPreference = $global:ProgressPreference + $global:ProgressPreference = 'SilentlyContinue' +} +###### End: Validate inputs -# Ensure 'src' folder exists +###### Set environment variables $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path -$srcFolder = Join-Path -Path $scriptPath -ChildPath "src" -if (-not (Test-Path -Path $srcFolder)) { - New-Item -ItemType Directory -Path $srcFolder | Out-Null +# Run the setup-env.ps1 script located in the scripts folder +# Setup $Env:Windows_tools_base, $Env:srcFolder, $Env:appxTemplate, and $Env:priConfig env vars +$setupEnvScriptPath = Join-Path -Path $scriptPath -ChildPath "scripts\setup-env.ps1" +if (-not (Test-Path -Path $setupEnvScriptPath)) { + throw "Error: The setup-env.ps1 script was not found at '$setupEnvScriptPath'." } +& $setupEnvScriptPath +Write-Host "Environment setup script executed successfully." +###### End: Set environment variables -# Handle ZipFilePath +# Handles local zip file if ($ZipFilePath) { if (-not (Test-Path -Path $ZipFilePath)) { throw "Error: The file at path '$ZipFilePath' does not exist." } - $destinationPath = Join-Path -Path $srcFolder -ChildPath (Split-Path -Leaf $ZipFilePath) # Copy and unzip the file - Copy-Item -Path $ZipFilePath -Destination $destinationPath - Expand-Archive -Path $destinationPath -DestinationPath $srcFolder -Force - # Remove the zip file since contents are extracted - Remove-Item -Path $destinationPath -Force - Write-Host "Zip file copied and extracted to 'src' folder." + Expand-Archive -Path $ZipFilePath -DestinationPath $Env:workspace -Force + Write-Host "Zip file extracted to 'workspace' folder." } - -# Handle ZipFileUrl -if ($ZipFileUrl) { +# Handles zip from URL +elseif ($ZipFileUrl) { $fileName = [System.IO.Path]::GetFileName($ZipFileUrl) - $downloadPath = Join-Path -Path $srcFolder -ChildPath $fileName - # download zip file + $downloadPath = Join-Path -Path $Env:workspace -ChildPath $fileName + + # download zip file (needs to be silent or it will print the progress bar and take ~10 times as long to download) + $OriginalLocalProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri $ZipFileUrl -OutFile $downloadPath + $ProgressPreference = $OriginalLocalProgressPreference + # unzip file - Expand-Archive -Path $downloadPath -DestinationPath $srcFolder -Force + Expand-Archive -Path $downloadPath -DestinationPath $Env:workspace -Force # remove zip file since conentets are extracted Remove-Item -Path $downloadPath -Force - Write-Host "Zip file downloaded and extracted to 'src' folder." + Write-Host "Zip file downloaded and extracted to 'workspace' folder." } -## Update the file content of AppXManifest.xml -# Define the path to the file -$appxTemplate = Join-Path -Path $scriptPath -ChildPath "tempaltes\AppXManifestTemplate.xml" -$priConfig = Join-Path -Path $scriptPath -ChildPath "tempaltes\pri_config.xml" +# Move contents of the unzipped file to $Env:srcFolder +$unzippedFolder = Join-Path -Path $Env:workspace -ChildPath (Get-ChildItem -Path $Env:workspace -Directory | Select-Object -First 1).Name +Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $Env:srcFolder -Force +Remove-Item -Path $unzippedFolder -Recurse -Force -# Read the content of the file -$content = Get-Content -Path $appxTemplate +# Read the content of the appx template (path from setup-env.ps1) +$content = Get-Content -Path $Env:appxTemplate # Create a variable by replacing spaces and underscores with dashes in $VendorBranding $vendorBrandingDashes = $VendorBranding -replace "[ _]", "-" +$outputFileName = "$vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch.msix" # Replace all instances of placeholders with the provided values $updatedContent = $content ` -replace "\{VENDOR\}", $Vendor ` - -replace "\{VENDORBRANDING\}", $VendorBranding ` - -replace "\{VENDORBRANDINGDASHES\}", $vendorBrandingDashes ` + -replace "\{VENDOR_BRANDING\}", $VendorBranding ` + -replace "\{VENDOR_BRANDING_DASHES\}", $vendorBrandingDashes ` -replace "\{DESCRIPTION\}", $Description ` - -replace "\{PRODUCTMAJORVERSION\}", $ProductMajorVersion ` - -replace "\{PRODUCTMINORVERSION\}", $ProductMinorVersion ` - -replace "\{PRODUCTMAINTENANCEVERSION\}", $ProductMaintenanceVersion ` - -replace "\{PRODUCTBUILDNUMBER\}", $ProductBuildNumber ` + -replace "\{PRODUCT_MAJOR_VERSION\}", $ProductMajorVersion ` + -replace "\{PRODUCT_MINOR_VERSION\}", $ProductMinorVersion ` + -replace "\{PRODUCT_MAINTENANCE_VERSION\}", $ProductMaintenanceVersion ` + -replace "\{PRODUCT_BUILD_NUMBER\}", $ProductBuildNumber ` -replace "\{ARCH\}", $Arch ` - -replace "\{PUBLISHERCN\}", $PublisherCN + -replace "\{PUBLISHER_CN\}", $PublisherCN -# Ensure there is only one folder in the 'src' directory -$subFolders = Get-ChildItem -Path $srcFolder -Directory -if ($subFolders.Count -ne 1) { - throw "Error: The 'src' folder must contain exactly one subfolder." -} - -# Define the path to the new AppXManifest.xml file -$targetFolder = $subFolders[0].FullName -$appxManifestPath = Join-Path -Path $targetFolder -ChildPath "AppXManifest.xml" - # Write the updated content to the new AppXManifest.xml file +$appxManifestPath = Join-Path -Path $Env: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 -Copy-Item -Path $priConfig -Destination $targetFolder -Force -Write-Host "pri_config.xml copied to '$targetFolder'" +# Copy pri_config.xml to the target folder (path from setup-env.ps1) +Copy-Item -Path $Env:priConfig -Destination $Env:srcFolder -Force +Write-Host "pri_config.xml copied to '$Env:srcFolder'" -makepri.exe new ` +& "$Env:Windows_tools_base\makepri.exe" new ` /o ` - /pr $targetFolder ` - /cf $targetFolder\pri_config.xml ` - /of $targetFolder\_resources.pri ` + /pr $Env:srcFolder ` + /cf "$Env:srcFolder\pri_config.xml" ` + /of "$Env:srcFolder\_resources.pri" ` /mf appx -makeappx.exe pack ` +& "$Env:Windows_tools_base\makeappx.exe" pack ` /o ` - /d $targetFolder ` - /p $vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch.msix + /d "$Env:srcFolder" ` + /p "$Env:output\$outputFileName" if ($SigningCertPath) { - # Run signtool to sign the package without printing to logs (keeps password secret) - Start-Process -FilePath "signtool.exe" -ArgumentList @( - "sign", - "/fd", "SHA256", - "/a", - "/f", $SigningCertPath, - "/p", $SigningPassword, - ".\$vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch.msix" - ) -NoNewWindow -Wait -PassThru | Out-Null + & "$Env:Windows_tools_base\signtool.exe" sign ` + /fd SHA256 ` + /a ` + /f $SigningCertPath ` + /p "$SigningPassword" ` + $Env:output\$outputFileName Write-Host "MSIX package signed successfully." -} else { +} +else { Write-Host "SigningCertPath not provided. Skipping signing process." +} + +# Set $ProgressPreference back to its original value +if (-not $VerboseOutput) { + $global:ProgressPreference = $OriginalProgressPreference } \ No newline at end of file diff --git a/msix/resources/duke150.png b/msix/resources/duke150.png deleted file mode 100644 index 1eb0a8fc9882097810f823cca646c30842296f16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 924 zcmeAS@N?(olHy`uVBq!ia0vp^(?FPm2}o{Eezui?fjQaJ#WAE}&fB>M^A0Nru+Cof z|NrTij3>Kh9b?;kVD{6qd-?7r=B)Di`1of{outwI)#3?N8=Y*zI*xOFj8K%*K9by8 zu|}X@^bv~SKAs*6wPyrYJGn*mDh0X zq1qEGKLi(OI-gltpe>|j_fbsOE=i9_fcFHv_rj8WLw)* zwIeoM+f_RcReL_=Fzh@u_vC^N>dROZ(*kx_RIKVCYsJ{5hU zWuvzATltNRa;DRZxK>M~hv(eCvS8^3#e;&I_w8Di))B>ZyJIWIoAnAyKAa0S$a;76 zx*$*BFPEsJhJU4vk52pEb*f%ViGR^_z1{XsuWp=K|3S8K<2jc{ks4c9W>2V6^3pJ| zT@&8nyvpDrv0<({fRd2;jIV`Y3Xlfn!taQ^j3QHrXP}JU47G za|!QAZ#r;tQN@mxY0Txcq0^ zjHmG&`li#;{an^L HB{Ts5bc~nC diff --git a/msix/resources/duke44.png b/msix/resources/duke44.png deleted file mode 100644 index c3c28472b927bc1c77f901ed35920d24390de566..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 311 zcmV-70m%M|P)<@-0002~Nkl>2pMJlE;6z{v z@fxc?oQg4lct2OU2eDIey2S7%W#;2M_83;g@x)W0IH0o`{dI^ht3I5HVfuAkGUyIy z3lCj;j4?va5W2M|zcI!Dk&t1G@Xr!ML*!%_Afh&m(M6SB0mEWmF9gbE_!kGdoLx@1kKtKTlOpe-ud?xh!^H6S8#nn$wvSH002ov JPDHLkV1l>Ue}4b~ diff --git a/msix/resources/duke50.png b/msix/resources/duke50.png deleted file mode 100644 index 6516e2a32f45d697f9c8c4143ab05c48e1469879..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmV-s0h#`ZP)>Yb`6Px~)xB zmax*cj*?P@)wR{@i3=-gYa}KptfDPhNkmvVTZjy|uv)fo4L)Hn$2onS+JX4LkH^+g z0Ci0LL5Hx=wI%mVk&eoYwQZetuK&FwtwnqMQvEjrimCh?x0DS`A+1w zuK6G$6PCeN{3!}gu>FXUfraT@6f3Kx0dowt;q8u{CcFEhi7LW~-7{k!;N#*$eqR)*4m9T0>iF z-foOmVX#)J8m%~dI$aNUth24FXin?4`wf|)ZY)c^0s63Gh<}goz5oCK07*qoM6N<$ Ef+07cOaK4? diff --git a/msix/scripts/setup-env.ps1 b/msix/scripts/setup-env.ps1 new file mode 100644 index 000000000..9daae5a72 --- /dev/null +++ b/msix/scripts/setup-env.ps1 @@ -0,0 +1,39 @@ + +# Set default windows SDK version to use if not already set +if (-not $Env:WIN_SDK_FULL_VERSION) { + $Env:WIN_SDK_FULL_VERSION = "10.0.22621.0" +} +if (-not $Env:WIN_SDK_MAJOR_VERSION) { + $Env:WIN_SDK_MAJOR_VERSION = "10" +} +Write-Host "WIN_SDK_FULL_VERSION is set to $Env:WIN_SDK_FULL_VERSION." +Write-Host "WIN_SDK_MAJOR_VERSION is set to $Env:WIN_SDK_MAJOR_VERSION." +$Env:Windows_tools_base = "$Env:ProgramFiles (x86)\Windows Kits\$Env:WIN_SDK_MAJOR_VERSION\bin\$Env:WIN_SDK_FULL_VERSION\$Arch" + +# Set path to src folder +$Env:srcFolder = Join-Path -Path $scriptPath -ChildPath "src" +# Clean src folder by deleting all contents of the src folder except what is in src\_msix_logos +Get-ChildItem -Path $Env:srcFolder -Recurse | Where-Object { + $_.FullName -notlike "*\_msix_logos*" +} | Remove-Item -Recurse -Force + +# Ensure 'workspace' folder exists +$Env:workspace = Join-Path -Path $scriptPath -ChildPath "workspace" +if (-not (Test-Path -Path $Env:workspace)) { + New-Item -ItemType Directory -Path $Env:workspace | Out-Null +} +# Clean workspace folder by deleting all contents +Get-ChildItem -Path $Env:workspace -Recurse | Remove-Item -Recurse -Force + +# Ensure 'output' folder exists +$Env:output = Join-Path -Path $scriptPath -ChildPath "output" +if (-not (Test-Path -Path $Env:output)) { + New-Item -ItemType Directory -Path $Env:output | Out-Null +} +# Clean output folder by deleting all contents +Get-ChildItem -Path $Env:output -Recurse | Remove-Item -Recurse -Force + +## Update the file content of AppXManifest.xml +# Define the path to the file +$Env:appxTemplate = Join-Path -Path $scriptPath -ChildPath "templates\AppXManifestTemplate.xml" +$Env:priConfig = Join-Path -Path $scriptPath -ChildPath "templates\pri_config.xml" \ No newline at end of file diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index e647b26e3..8b97badf6 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -33,7 +33,7 @@ Variables to replace: {VENDOR_BRANDING} {PRODUCT_MAJOR_VERSION}.{PRODUCT_MINOR_VERSION}.{PRODUCT_MAINTENANCE_VERSION}+{PRODUCT_BUILD_NUMBER} ({ARCH}) {VENDOR} {VENDOR_BRANDING} {DESCRIPTION} - resources/duke50.png + _msix_logos/duke50.png disabled disabled defer @@ -56,8 +56,8 @@ Variables to replace: desktop4:Subsystem="console"> @@ -75,8 +75,8 @@ Variables to replace: desktop4:Subsystem="console"> From 7d0b3259a38c25277f4c1d600aff8970c7115afa Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 13 May 2025 15:07:22 -0700 Subject: [PATCH 03/39] Added info to README.md --- msix/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msix/README.md b/msix/README.md index b58bfee98..b7ab5f659 100644 --- a/msix/README.md +++ b/msix/README.md @@ -48,4 +48,4 @@ Get-AppPackage -Name "package-name" ```shell Remove-AppPackage -AllUsers -package "package-full-name" ``` -Note: Name must appear as it does when found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file +Note: The "package-full-name" must appear as it does in the `PackageFullName` attribute found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file From 5e7630e76cae4af32fdf2ab50810c1a2220091ac Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 13 May 2025 15:09:40 -0700 Subject: [PATCH 04/39] Updated comments --- msix/create_msix.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/msix/create_msix.ps1 b/msix/create_msix.ps1 index 2d169342c..868f93785 100644 --- a/msix/create_msix.ps1 +++ b/msix/create_msix.ps1 @@ -129,7 +129,8 @@ if (-not $VerboseOutput) { ###### Set environment variables $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path # Run the setup-env.ps1 script located in the scripts folder -# Setup $Env:Windows_tools_base, $Env:srcFolder, $Env:appxTemplate, and $Env:priConfig env vars +# Sets $Env:Windows_tools_base, $Env:srcFolder, $Env:workspace, $Env:output, $Env:appxTemplate, and $Env:priConfig env vars +# Cleans src and workspace folders $setupEnvScriptPath = Join-Path -Path $scriptPath -ChildPath "scripts\setup-env.ps1" if (-not (Test-Path -Path $setupEnvScriptPath)) { throw "Error: The setup-env.ps1 script was not found at '$setupEnvScriptPath'." From b54560a27249a1231aafe108da47a51e8720174b Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 13 May 2025 15:24:41 -0700 Subject: [PATCH 05/39] Renamed scripts --- msix/{create_msix.ps1 => CreateMsix.ps1} | 10 +++++----- msix/scripts/{setup-env.ps1 => SetupEnv.ps1} | 0 2 files changed, 5 insertions(+), 5 deletions(-) rename msix/{create_msix.ps1 => CreateMsix.ps1} (96%) rename msix/scripts/{setup-env.ps1 => SetupEnv.ps1} (100%) diff --git a/msix/create_msix.ps1 b/msix/CreateMsix.ps1 similarity index 96% rename from msix/create_msix.ps1 rename to msix/CreateMsix.ps1 index 868f93785..72abea45e 100644 --- a/msix/create_msix.ps1 +++ b/msix/CreateMsix.ps1 @@ -128,12 +128,12 @@ if (-not $VerboseOutput) { ###### Set environment variables $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path -# Run the setup-env.ps1 script located in the scripts folder +# Run the SetupEnv.ps1 script located in the scripts folder # Sets $Env:Windows_tools_base, $Env:srcFolder, $Env:workspace, $Env:output, $Env:appxTemplate, and $Env:priConfig env vars # Cleans src and workspace folders -$setupEnvScriptPath = Join-Path -Path $scriptPath -ChildPath "scripts\setup-env.ps1" +$setupEnvScriptPath = Join-Path -Path $scriptPath -ChildPath "scripts\SetupEnv.ps1" if (-not (Test-Path -Path $setupEnvScriptPath)) { - throw "Error: The setup-env.ps1 script was not found at '$setupEnvScriptPath'." + throw "Error: The SetupEnv.ps1 script was not found at '$setupEnvScriptPath'." } & $setupEnvScriptPath Write-Host "Environment setup script executed successfully." @@ -171,7 +171,7 @@ $unzippedFolder = Join-Path -Path $Env:workspace -ChildPath (Get-ChildItem -Path Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $Env:srcFolder -Force Remove-Item -Path $unzippedFolder -Recurse -Force -# Read the content of the appx template (path from setup-env.ps1) +# Read the content of the appx template (path from SetupEnv.ps1) $content = Get-Content -Path $Env:appxTemplate # Create a variable by replacing spaces and underscores with dashes in $VendorBranding @@ -197,7 +197,7 @@ $appxManifestPath = Join-Path -Path $Env: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 setup-env.ps1) +# Copy pri_config.xml to the target folder (path from SetupEnv.ps1) Copy-Item -Path $Env:priConfig -Destination $Env:srcFolder -Force Write-Host "pri_config.xml copied to '$Env:srcFolder'" diff --git a/msix/scripts/setup-env.ps1 b/msix/scripts/SetupEnv.ps1 similarity index 100% rename from msix/scripts/setup-env.ps1 rename to msix/scripts/SetupEnv.ps1 From e0e54ac74a6197aba8729ca0369288b63620246c Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 13 May 2025 15:53:23 -0700 Subject: [PATCH 06/39] Added way to name output files --- msix/CreateMsix.ps1 | 17 +++++++++++++---- msix/templates/AppXManifestTemplate.xml | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 72abea45e..df6e2ded3 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -50,6 +50,10 @@ Optional. The password for the signing certificate. Only needed if the SigningCertPath is provided. +.PARAMETER outputName + Optional. The name of the output file without the file extension. + If not provided, a default name will be generated based on the VendorBranding and version information. + .PARAMETER Quiet Optional. If specified, suppresses output messages. Recommended for use in automated scripts, or when downloading zip files from a URL. This is an alias for -q. @@ -104,6 +108,9 @@ param ( [Parameter(Mandatory = $false)] [string]$SigningPassword, + [Parameter(Mandatory = $false)] + [string]$outputName, + [Parameter(Mandatory = $false, HelpMessage = "Include this flag to output verbose messages.")] [Alias("v")] [switch]$VerboseOutput @@ -176,13 +183,15 @@ $content = Get-Content -Path $Env:appxTemplate # Create a variable by replacing spaces and underscores with dashes in $VendorBranding $vendorBrandingDashes = $VendorBranding -replace "[ _]", "-" -$outputFileName = "$vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch.msix" - +if (-not $outputName) { + $outputName = "$vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch" +} # Replace all instances of placeholders with the provided values $updatedContent = $content ` -replace "\{VENDOR\}", $Vendor ` -replace "\{VENDOR_BRANDING\}", $VendorBranding ` -replace "\{VENDOR_BRANDING_DASHES\}", $vendorBrandingDashes ` + -replace "\{OUTPUT_NAME\}", $outputName ` -replace "\{DESCRIPTION\}", $Description ` -replace "\{PRODUCT_MAJOR_VERSION\}", $ProductMajorVersion ` -replace "\{PRODUCT_MINOR_VERSION\}", $ProductMinorVersion ` @@ -211,7 +220,7 @@ Write-Host "pri_config.xml copied to '$Env:srcFolder'" & "$Env:Windows_tools_base\makeappx.exe" pack ` /o ` /d "$Env:srcFolder" ` - /p "$Env:output\$outputFileName" + /p "$Env:output\$outputName.msix" if ($SigningCertPath) { @@ -220,7 +229,7 @@ if ($SigningCertPath) { /a ` /f $SigningCertPath ` /p "$SigningPassword" ` - $Env:output\$outputFileName + "$Env:output\$outputName.msix" Write-Host "MSIX package signed successfully." } else { diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index 8b97badf6..eea3e2fbe 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -4,6 +4,7 @@ Variables to replace: - VENDOR - Example: Eclipse Adoptium - VENDOR_BRANDING - Example: Eclipse Temurin - VENDOR_BRANDING_DASHES - replace all '_' and ' ' with '-' to avoid errors in the Name attribute + - OUTPUT_NAME - Example: Eclipse-Temurin-17.0.15-6-x64 - DESCRIPTION - This is optional. Example: "Development Kit with Hotspot" - PRODUCT_MAJOR_VERSION - Example: if the version is 17.0.15+6, this is 17 - PRODUCT_MINOR_VERSION - Example: if the version is 17.0.15+6, this is 0 @@ -25,7 +26,7 @@ Variables to replace: xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4" xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"> - From 39fe8cd7923987fbc4b58cbde611f218767e8be1 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 09:36:13 -0700 Subject: [PATCH 07/39] updated header --- msix/CreateMsix.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index df6e2ded3..ee68d37f4 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -62,7 +62,7 @@ .\create_msix.ps1 -ZipFilePath "C:\path\to\file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 17 -ProductMinorVersion 0 -ProductMaintenanceVersion 15 -ProductBuildNumber 6 -Arch "x64" -PublisherCN "ExamplePublisher" -SigningCertPath "C:\path\to\cert.pfx" -SigningPassword "myPass" .EXAMPLE - .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" -Quiet + .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" --outputName 'Eclipse-Temurin-21.0.7-aarch64' -Quiet .NOTES Ensure the 'src' folder exists in the current directory before running the script. From 37f76a06dea976629c2a537424ca88df3262650a Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 10:21:57 -0700 Subject: [PATCH 08/39] Added debug --- msix/CreateMsix.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index ee68d37f4..c7591ccb4 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -153,7 +153,7 @@ if ($ZipFilePath) { } # Copy and unzip the file Expand-Archive -Path $ZipFilePath -DestinationPath $Env:workspace -Force - Write-Host "Zip file extracted to 'workspace' folder." + Write-Host "Zip file extracted to: $Env:workspace." } # Handles zip from URL elseif ($ZipFileUrl) { @@ -170,12 +170,17 @@ elseif ($ZipFileUrl) { Expand-Archive -Path $downloadPath -DestinationPath $Env:workspace -Force # remove zip file since conentets are extracted Remove-Item -Path $downloadPath -Force - Write-Host "Zip file downloaded and extracted to 'workspace' folder." + Write-Host "Zip file downloaded and extracted to: $Env:workspace" } +Write-Host "Contents of workspace folder:" +ls $Env:workspace + # Move contents of the unzipped file to $Env:srcFolder $unzippedFolder = Join-Path -Path $Env:workspace -ChildPath (Get-ChildItem -Path $Env:workspace -Directory | Select-Object -First 1).Name Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $Env:srcFolder -Force +Write-Host "Contents of zip file moved to: $Env:srcFolder" +ls $Env:srcFolder Remove-Item -Path $unzippedFolder -Recurse -Force # Read the content of the appx template (path from SetupEnv.ps1) From 1293a6ac601b1563b6240a45c136344b338ea824 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 10:29:45 -0700 Subject: [PATCH 09/39] readded _msix_logos --- msix/src/_msix_logos/duke150.png | Bin 0 -> 924 bytes msix/src/_msix_logos/duke44.png | Bin 0 -> 311 bytes msix/src/_msix_logos/duke50.png | Bin 0 -> 358 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 msix/src/_msix_logos/duke150.png create mode 100644 msix/src/_msix_logos/duke44.png create mode 100644 msix/src/_msix_logos/duke50.png diff --git a/msix/src/_msix_logos/duke150.png b/msix/src/_msix_logos/duke150.png new file mode 100644 index 0000000000000000000000000000000000000000..1eb0a8fc9882097810f823cca646c30842296f16 GIT binary patch literal 924 zcmeAS@N?(olHy`uVBq!ia0vp^(?FPm2}o{Eezui?fjQaJ#WAE}&fB>M^A0Nru+Cof z|NrTij3>Kh9b?;kVD{6qd-?7r=B)Di`1of{outwI)#3?N8=Y*zI*xOFj8K%*K9by8 zu|}X@^bv~SKAs*6wPyrYJGn*mDh0X zq1qEGKLi(OI-gltpe>|j_fbsOE=i9_fcFHv_rj8WLw)* zwIeoM+f_RcReL_=Fzh@u_vC^N>dROZ(*kx_RIKVCYsJ{5hU zWuvzATltNRa;DRZxK>M~hv(eCvS8^3#e;&I_w8Di))B>ZyJIWIoAnAyKAa0S$a;76 zx*$*BFPEsJhJU4vk52pEb*f%ViGR^_z1{XsuWp=K|3S8K<2jc{ks4c9W>2V6^3pJ| zT@&8nyvpDrv0<({fRd2;jIV`Y3Xlfn!taQ^j3QHrXP}JU47G za|!QAZ#r;tQN@mxY0Txcq0^ zjHmG&`li#;{an^L HB{Ts5bc~nC literal 0 HcmV?d00001 diff --git a/msix/src/_msix_logos/duke44.png b/msix/src/_msix_logos/duke44.png new file mode 100644 index 0000000000000000000000000000000000000000..c3c28472b927bc1c77f901ed35920d24390de566 GIT binary patch literal 311 zcmV-70m%M|P)<@-0002~Nkl>2pMJlE;6z{v z@fxc?oQg4lct2OU2eDIey2S7%W#;2M_83;g@x)W0IH0o`{dI^ht3I5HVfuAkGUyIy z3lCj;j4?va5W2M|zcI!Dk&t1G@Xr!ML*!%_Afh&m(M6SB0mEWmF9gbE_!kGdoLx@1kKtKTlOpe-ud?xh!^H6S8#nn$wvSH002ov JPDHLkV1l>Ue}4b~ literal 0 HcmV?d00001 diff --git a/msix/src/_msix_logos/duke50.png b/msix/src/_msix_logos/duke50.png new file mode 100644 index 0000000000000000000000000000000000000000..6516e2a32f45d697f9c8c4143ab05c48e1469879 GIT binary patch literal 358 zcmV-s0h#`ZP)>Yb`6Px~)xB zmax*cj*?P@)wR{@i3=-gYa}KptfDPhNkmvVTZjy|uv)fo4L)Hn$2onS+JX4LkH^+g z0Ci0LL5Hx=wI%mVk&eoYwQZetuK&FwtwnqMQvEjrimCh?x0DS`A+1w zuK6G$6PCeN{3!}gu>FXUfraT@6f3Kx0dowt;q8u{CcFEhi7LW~-7{k!;N#*$eqR)*4m9T0>iF z-foOmVX#)J8m%~dI$aNUth24FXin?4`wf|)ZY)c^0s63Gh<}goz5oCK07*qoM6N<$ Ef+07cOaK4? literal 0 HcmV?d00001 From 5319200ca998ed5f2f27c99290022e1d5a62ded5 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 12:15:58 -0700 Subject: [PATCH 10/39] Updated headers and defaults --- msix/CreateMsix.ps1 | 37 +++++++++++++++++-------- msix/templates/AppXManifestTemplate.xml | 11 ++++---- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index c7591ccb4..72af75738 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -15,13 +15,19 @@ Optional. The URL of a zip file to be downloaded and unzipped. .PARAMETER Vendor - Optional. Example: Eclipse Adoptium. + Optional. Default: Eclipse Adoptium. .PARAMETER VendorBranding - Optional. Example: Eclipse Temurin + Optional. 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: "Development Kit with Hotspot". + Optional. Example: "Eclipse Temurin Development Kit with Hotspot". + Default: $VendorBranding. .PARAMETER ProductMajorVersion Example: if the version is 17.0.15+6, this is 17. @@ -36,7 +42,7 @@ Example: if the version is 17.0.15+6, this is 6. .PARAMETER Arch - Examples: x86, x64, arm64. + Valid architectures: x86, x64, arm, arm64, x86a64, neutral .PARAMETER PublisherCN Set this to anything on the right side of your `CN=` field in your .pfx file. @@ -62,7 +68,7 @@ .\create_msix.ps1 -ZipFilePath "C:\path\to\file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 17 -ProductMinorVersion 0 -ProductMaintenanceVersion 15 -ProductBuildNumber 6 -Arch "x64" -PublisherCN "ExamplePublisher" -SigningCertPath "C:\path\to\cert.pfx" -SigningPassword "myPass" .EXAMPLE - .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" --outputName 'Eclipse-Temurin-21.0.7-aarch64' -Quiet + .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -MsixDisplayName "Eclipse Temurin 17.0.15+6 (x64)" -Description "Eclipse Temurin Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" --outputName 'Eclipse-Temurin-21.0.7-aarch64' -Quiet .NOTES Ensure the 'src' folder exists in the current directory before running the script. @@ -82,7 +88,10 @@ param ( [string]$VendorBranding = "Eclipse Temurin", [Parameter(Mandatory = $false)] - [string]$Description = "Development Kit with Hotspot", + [string]$MsixDisplayName = "", + + [Parameter(Mandatory = $false)] + [string]$Description = "", [Parameter(Mandatory = $true)] [int]$ProductMajorVersion, @@ -131,6 +140,15 @@ if (-not $VerboseOutput) { $OriginalProgressPreference = $global:ProgressPreference $global:ProgressPreference = 'SilentlyContinue' } +if (-not $Description) { + $Description = $VendorBranding +} +if (-not $MsixDisplayName) { + $MsixDisplayName = "$VendorBranding $ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion+$ProductBuildNumber ($Arch)" +} +if (-not $outputName) { + $outputName = "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber" +} ###### End: Validate inputs ###### Set environment variables @@ -186,16 +204,11 @@ Remove-Item -Path $unzippedFolder -Recurse -Force # Read the content of the appx template (path from SetupEnv.ps1) $content = Get-Content -Path $Env:appxTemplate -# Create a variable by replacing spaces and underscores with dashes in $VendorBranding -$vendorBrandingDashes = $VendorBranding -replace "[ _]", "-" -if (-not $outputName) { - $outputName = "$vendorBrandingDashes-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber-$Arch" -} # Replace all instances of placeholders with the provided values $updatedContent = $content ` -replace "\{VENDOR\}", $Vendor ` -replace "\{VENDOR_BRANDING\}", $VendorBranding ` - -replace "\{VENDOR_BRANDING_DASHES\}", $vendorBrandingDashes ` + -replace "\{MSIX_DISPLAYNAME\}", $MsixDisplayName ` -replace "\{OUTPUT_NAME\}", $outputName ` -replace "\{DESCRIPTION\}", $Description ` -replace "\{PRODUCT_MAJOR_VERSION\}", $ProductMajorVersion ` diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index eea3e2fbe..ebdccdf85 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -3,14 +3,15 @@ Variables to replace: - VENDOR - Example: Eclipse Adoptium - VENDOR_BRANDING - Example: Eclipse Temurin - - VENDOR_BRANDING_DASHES - replace all '_' and ' ' with '-' to avoid errors in the Name attribute - - OUTPUT_NAME - Example: Eclipse-Temurin-17.0.15-6-x64 + - MSIX_DISPLAYNAME - Example: Eclipse Temurin with hotspot 17.0.15+6 (x64) + - OUTPUT_NAME - Example: OpenJDK17U-jdk-x64-windows-hotspot-17.0.15-6 + Note: OUTPUT_NAME cannot contain spaces or underscores. - DESCRIPTION - This is optional. Example: "Development Kit with Hotspot" - PRODUCT_MAJOR_VERSION - Example: if the version is 17.0.15+6, this is 17 - PRODUCT_MINOR_VERSION - Example: if the version is 17.0.15+6, this is 0 - PRODUCT_MAINTENANCE_VERSION - Example: if the version is 17.0.15+6, this is 15 - PRODUCT_BUILD_NUMBER - Example: if the version is 17.0.15+6, this is 6 - - ARCH - Example: x86, x64, arm64 + - ARCH - Valid architectures: x86, x64, arm, arm64, x86a64, neutral - PUBLISHER_CN - Set this to anything 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. --> @@ -31,9 +32,9 @@ Variables to replace: Version="{PRODUCT_MAJOR_VERSION}.{PRODUCT_MINOR_VERSION}.{PRODUCT_MAINTENANCE_VERSION}.0" ProcessorArchitecture="{ARCH}" /> - {VENDOR_BRANDING} {PRODUCT_MAJOR_VERSION}.{PRODUCT_MINOR_VERSION}.{PRODUCT_MAINTENANCE_VERSION}+{PRODUCT_BUILD_NUMBER} ({ARCH}) + {MSIX_DISPLAYNAME} {VENDOR} - {VENDOR_BRANDING} {DESCRIPTION} + {DESCRIPTION} _msix_logos/duke50.png disabled disabled From 957653c36778f3ecdc88a419072897167f8f63a3 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 14:14:08 -0700 Subject: [PATCH 11/39] Updated README.md + header comments --- msix/CreateMsix.ps1 | 33 +++++++++++-- msix/README.md | 113 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 123 insertions(+), 23 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 72af75738..57ce4c35a 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -65,13 +65,40 @@ This is an alias for -q. .EXAMPLE - .\create_msix.ps1 -ZipFilePath "C:\path\to\file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -Description "Development Kit with Hotspot" -ProductMajorVersion 17 -ProductMinorVersion 0 -ProductMaintenanceVersion 15 -ProductBuildNumber 6 -Arch "x64" -PublisherCN "ExamplePublisher" -SigningCertPath "C:\path\to\cert.pfx" -SigningPassword "myPass" + .\CreateMsix.ps1 ` + -ZipFilePath "C:\path\to\file.zip" ` + -PublisherCN "ExamplePublisher" ` + -ProductMajorVersion 17 ` + -ProductMinorVersion 0 ` + -ProductMaintenanceVersion 15 ` + -ProductBuildNumber 6 ` + -Arch "x64" ` .EXAMPLE - .\create_msix.ps1 -ZipFileUrl "https://example.com/file.zip" -Vendor "Eclipse Adoptium" -VendorBranding "Eclipse Temurin" -MsixDisplayName "Eclipse Temurin 17.0.15+6 (x64)" -Description "Eclipse Temurin Development Kit with Hotspot" -ProductMajorVersion 21 -ProductMinorVersion 0 -ProductMaintenanceVersion 7 -ProductBuildNumber 6 -Arch "aarch64" -PublisherCN "ExamplePublisher" --outputName 'Eclipse-Temurin-21.0.7-aarch64' -Quiet + .\CreateMsix.ps1 ` + # Mandatory inputs + -ZipFileUrl "https://example.com/file.zip" ` + -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)" ` + -outputName 'Eclipse-Temurin-21.0.7-aarch64' ` + -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" + -VerboseOutput .NOTES - Ensure the 'src' folder exists in the current directory before running the script. + Ensure thatyou 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 ( diff --git a/msix/README.md b/msix/README.md index b7ab5f659..1c2885476 100644 --- a/msix/README.md +++ b/msix/README.md @@ -1,51 +1,124 @@ # How to create MSIX files -## Make resources.pri file (Needed for MSIX creation) -```shell -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 +## Dependencies +The following files are required in order to successlfully run `CreateMsix.ps1`. These files can be found within the `Windows Kits` section of `Visual Studio` installation directories. +- `makepri.exe` +- `makeappx.exe` +- `signtool.exe` + +If you are running the `CreateMsix.ps1` and have all files available, you will need to check which version(s) of `Visual Studio` or `Windows SDK` you have installed. If you want to use a version other than `10.0.22621.0`, you will need to 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` of the `Windows Kits` section of your `Visual Studio` or `Windows SDK` installation directory. We currently default to using `10.0.22621.0`, so the 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, see the `powershell` style header within `msix/CreateMsix.ps1` + +*First Example*: Running with only required inputs. This will produce an MSIX file, but many values (ex: DisplayName) will take the default Eclipse/Temurin value. Note: either `-ZipFilePath` or `-ZipFileUrl` are required inputs, but you cannot specify both. This example builds an Eclipse Temurin msix for jdk `17.0.15+6` +```powershell +.\CreateMsix.ps1 ` + -ZipFilePath "C:\path\to\file.zip" ` + -PublisherCN "ExamplePublisher" ` + -ProductMajorVersion 17 ` + -ProductMinorVersion 0 ` + -ProductMaintenanceVersion 15 ` + -ProductBuildNumber 6 ` + -Arch "x64" ` +``` + +*Second Option*: Running with all required + optional inputs. Below, you will see the inputs divided into sections: required, optional with a default value (shows), optional + changes behavior if omitted. This example builds an Eclipse Temurin msix for jdk `21.0.7+6` +```powershell +.\CreateMsix.ps1 ` + # Mandatory inputs + -ZipFileUrl "https://example.com/file.zip" ` + -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)" ` + -outputName 'Eclipse-Temurin-21.0.7-aarch64' ` # Dictates the output filename without the .msix extension + -Description "Eclipse Temurin" ` # 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" + -VerboseOutput # Keeps $global:ProgressPreference at original value (if not verbose, this value is set to 'SilentlyContinue' which increases the speed of unzipping binaries) +``` +## Creating MSIX Files Manually +If you would like to create MSIX files manually, there are not that many powershell commands to run. A good amount of the work comes form ensuring that the `AppXManifest.xml` file contains the correct configuration parameters. If you would like to manually build your `msix` files, then you can follow the commands in the sections below after: +1. Coppying `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) +Note: This assumes you have a file in your `/pr` directory called `AppXManifest.xml`. If not, you will need to 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 +```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 ``` -Note: This assumes you have a file in your `/pr` directory called AppXManifest.xml. If not, you will need to specify the `/mn` flag and set the path to your manifest xml file -## Make .msix file -```shell -makeappx.exe pack /o /d C:\path\to\your\content\directory /p "output_filename.msix" +### 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 +### 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 let you install from an unsigned MSIX file, even in developer mode -```shell -signtool.exe sign /fd SHA256 /a /f C:\path\to\your\certfile.pfx /p "your_pfx_file_password" your_package_file.msix + - ie: the step above is mandatory for testing new `msix` files made locally, even if it is 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 ``` -# Install, get info, and uninstall -Note: Must be run from a terminal with administrator privileges] +# Using MSIX files +Note: These commands must be run from a terminal with administrator privileges -## Install from msix file -```shell +## Install using MSIX file +- If your `.msix` file was signed with a cert that is trusted by Microsoft, then you should be able to to double click it and install via the GUI. +- If it was signed by a cert that is only trusted by the local computer, you will need to run the powershell command below from a terminal with admin privileges +- If your `.msix` file was not signed at all, you will not be able to install from it (even if your machine is in developer mode) +```powershell Add-AppPackage -Path C:\path\to\msix\file.msix -AllowUnsigned -verbose ``` -## Check info of insallted MSIX +## Check info of installed MSIX Get info on all packages installed via MSIX: -```shell +```powershell Get-AppPackage -AllUsers | Select Name, PackageFullName ``` Narrow down info to just packages containing the substring `jdk`: -```shell +```powershell Get-AppPackage -AllUsers | Select Name, PackageFullName | Select-String -Pattern "jdk" ``` Get more detailed information on a specific MSIX package: -```shell +```powershell Get-AppPackage -Name "package-name" ``` ## Uninstall MSIX -```shell +```powershell Remove-AppPackage -AllUsers -package "package-full-name" ``` -Note: The "package-full-name" must appear as it does in the `PackageFullName` attribute found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file +Note: The `package-full-name` must appear as it does in the `PackageFullName` attribute found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file From 2f4dcfb439596bcf527c792c82f8bfe732461992 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 14:19:15 -0700 Subject: [PATCH 12/39] Testing full ver num --- msix/templates/AppXManifestTemplate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index ebdccdf85..54bc20a74 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -29,7 +29,7 @@ Variables to replace: {MSIX_DISPLAYNAME} From 74180cd5daa3989ceb025b579715cf67e1bb0e86 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 14:40:28 -0700 Subject: [PATCH 13/39] Removed debug --- msix/CreateMsix.ps1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 57ce4c35a..d44996550 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -218,14 +218,9 @@ elseif ($ZipFileUrl) { Write-Host "Zip file downloaded and extracted to: $Env:workspace" } -Write-Host "Contents of workspace folder:" -ls $Env:workspace - # Move contents of the unzipped file to $Env:srcFolder $unzippedFolder = Join-Path -Path $Env:workspace -ChildPath (Get-ChildItem -Path $Env:workspace -Directory | Select-Object -First 1).Name Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $Env:srcFolder -Force -Write-Host "Contents of zip file moved to: $Env:srcFolder" -ls $Env:srcFolder Remove-Item -Path $unzippedFolder -Recurse -Force # Read the content of the appx template (path from SetupEnv.ps1) From 10f4ef891a166f611603164736e33022f8bf02fb Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Wed, 14 May 2025 16:39:02 -0700 Subject: [PATCH 14/39] Updated comments, inputs, order, and spelling --- msix/CreateMsix.ps1 | 66 +++++++++++++++---------- msix/README.md | 24 +++++---- msix/templates/AppXManifestTemplate.xml | 9 ++-- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index d44996550..8d41603eb 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -14,6 +14,12 @@ .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. @@ -56,17 +62,19 @@ Optional. The password for the signing certificate. Only needed if the SigningCertPath is provided. -.PARAMETER outputName - Optional. The name of the output file without the file extension. +.PARAMETER OutputFileName + Optional. The name of the output file. If not provided, a default name will be generated based on the VendorBranding and version information. -.PARAMETER Quiet - Optional. If specified, suppresses output messages. Recommended for use in automated scripts, or when downloading zip files from a URL. - This is an alias for -q. +.PARAMETER VerboseOutput + Optional. If specified, $global:ProgressPreference is not set to 'SilentlyContinue'. + Note: Unzipping binaries is much faster if not verbose. (Because the progress bar is not shown) + Alias: -v. .EXAMPLE .\CreateMsix.ps1 ` -ZipFilePath "C:\path\to\file.zip" ` + -PackageName "OpenJDK17U-jdk-x64-windows-hotspot" ` -PublisherCN "ExamplePublisher" ` -ProductMajorVersion 17 ` -ProductMinorVersion 0 ` @@ -78,6 +86,7 @@ .\CreateMsix.ps1 ` # Mandatory inputs -ZipFileUrl "https://example.com/file.zip" ` + -PackageName "OpenJDK21U-jdk-x64-windows-hotspot" ` -PublisherCN "ExamplePublisher" ` -ProductMajorVersion 21 ` -ProductMinorVersion 0 ` @@ -88,15 +97,15 @@ -Vendor "Eclipse Adoptium" ` -VendorBranding "Eclipse Temurin" ` -MsixDisplayName "Eclipse Temurin 17.0.15+6 (x64)" ` - -outputName 'Eclipse-Temurin-21.0.7-aarch64' ` -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" ` -VerboseOutput .NOTES - Ensure thatyou 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: + 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" #> @@ -108,17 +117,11 @@ param ( [Parameter(Mandatory = $false)] [string]$ZipFileUrl, - [Parameter(Mandatory = $false)] - [string]$Vendor = "Eclipse Adoptium", - - [Parameter(Mandatory = $false)] - [string]$VendorBranding = "Eclipse Temurin", - - [Parameter(Mandatory = $false)] - [string]$MsixDisplayName = "", + [Parameter(Mandatory = $true)] + [string]$PackageName, - [Parameter(Mandatory = $false)] - [string]$Description = "", + [Parameter(Mandatory = $true)] + [string]$PublisherCN, [Parameter(Mandatory = $true)] [int]$ProductMajorVersion, @@ -135,8 +138,17 @@ param ( [Parameter(Mandatory = $true)] [string]$Arch, - [Parameter(Mandatory = $true)] - [string]$PublisherCN, + [Parameter(Mandatory = $false)] + [string]$Vendor = "Eclipse Adoptium", + + [Parameter(Mandatory = $false)] + [string]$VendorBranding = "Eclipse Temurin", + + [Parameter(Mandatory = $false)] + [string]$MsixDisplayName = "", + + [Parameter(Mandatory = $false)] + [string]$Description = "", [Parameter(Mandatory = $false)] [string]$SigningCertPath, @@ -145,7 +157,7 @@ param ( [string]$SigningPassword, [Parameter(Mandatory = $false)] - [string]$outputName, + [string]$OutputFileName, [Parameter(Mandatory = $false, HelpMessage = "Include this flag to output verbose messages.")] [Alias("v")] @@ -162,7 +174,7 @@ if ($ZipFilePath -and $ZipFileUrl) { if (($SigningPassword -and -not $SigningCertPath) -or ($SigningCertPath -and -not $SigningPassword)) { throw "Error: Both SigningCertPath and SigningPassword must be provided together." } -# Set $ProgressPreference to 'SilentlyContinue' if the the verbose flag is not set +# Set $ProgressPreference to 'SilentlyContinue' if the verbose flag is not set if (-not $VerboseOutput) { $OriginalProgressPreference = $global:ProgressPreference $global:ProgressPreference = 'SilentlyContinue' @@ -173,8 +185,8 @@ if (-not $Description) { if (-not $MsixDisplayName) { $MsixDisplayName = "$VendorBranding $ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion+$ProductBuildNumber ($Arch)" } -if (-not $outputName) { - $outputName = "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion-$ProductBuildNumber" +if (-not $OutputFileName) { + $OutputFileName = "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion_$ProductBuildNumber" } ###### End: Validate inputs @@ -213,7 +225,7 @@ elseif ($ZipFileUrl) { # unzip file Expand-Archive -Path $downloadPath -DestinationPath $Env:workspace -Force - # remove zip file since conentets are extracted + # remove zip file since contents are extracted Remove-Item -Path $downloadPath -Force Write-Host "Zip file downloaded and extracted to: $Env:workspace" } @@ -231,7 +243,7 @@ $updatedContent = $content ` -replace "\{VENDOR\}", $Vendor ` -replace "\{VENDOR_BRANDING\}", $VendorBranding ` -replace "\{MSIX_DISPLAYNAME\}", $MsixDisplayName ` - -replace "\{OUTPUT_NAME\}", $outputName ` + -replace "\{PACKAGE_NAME\}", $PackageName ` -replace "\{DESCRIPTION\}", $Description ` -replace "\{PRODUCT_MAJOR_VERSION\}", $ProductMajorVersion ` -replace "\{PRODUCT_MINOR_VERSION\}", $ProductMinorVersion ` @@ -260,7 +272,7 @@ Write-Host "pri_config.xml copied to '$Env:srcFolder'" & "$Env:Windows_tools_base\makeappx.exe" pack ` /o ` /d "$Env:srcFolder" ` - /p "$Env:output\$outputName.msix" + /p "$Env:output\$OutputFileName" if ($SigningCertPath) { @@ -269,7 +281,7 @@ if ($SigningCertPath) { /a ` /f $SigningCertPath ` /p "$SigningPassword" ` - "$Env:output\$outputName.msix" + "$Env:output\$OutputFileName" Write-Host "MSIX package signed successfully." } else { diff --git a/msix/README.md b/msix/README.md index 1c2885476..6947be7f7 100644 --- a/msix/README.md +++ b/msix/README.md @@ -1,7 +1,7 @@ # How to create MSIX files ## Dependencies -The following files are required in order to successlfully run `CreateMsix.ps1`. These files can be found within the `Windows Kits` section of `Visual Studio` installation directories. +The following files are required in order to successfully run `CreateMsix.ps1`. These files can be found within the `Windows Kits` section of `Visual Studio` installation directories. - `makepri.exe` - `makeappx.exe` - `signtool.exe` @@ -15,10 +15,13 @@ In order to run the commands below, you may need to add the `bin` of the `Window ## 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, see the `powershell` style header within `msix/CreateMsix.ps1` +IMPORTANT: make sure to set the `-PackageName` since 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 only required inputs. This will produce an MSIX file, but many values (ex: DisplayName) will take the default Eclipse/Temurin value. Note: either `-ZipFilePath` or `-ZipFileUrl` are required inputs, but you cannot specify both. This example builds an Eclipse Temurin msix for jdk `17.0.15+6` ```powershell .\CreateMsix.ps1 ` -ZipFilePath "C:\path\to\file.zip" ` + -PackageName "OpenJDK17U-jdk-x64-windows-hotspot" ` -PublisherCN "ExamplePublisher" ` -ProductMajorVersion 17 ` -ProductMinorVersion 0 ` @@ -27,11 +30,12 @@ Please take a look at the [Dependencies](#dependencies) section above to make su -Arch "x64" ` ``` -*Second Option*: Running with all required + optional inputs. Below, you will see the inputs divided into sections: required, optional with a default value (shows), optional + changes behavior if omitted. This example builds an Eclipse Temurin msix for jdk `21.0.7+6` +*Second Option*: Running with all required + optional inputs. Below, you will see the inputs divided into sections: required, optional with a default value (shown below), optional + changes behavior if omitted. This example builds an Eclipse Temurin msix for jdk `21.0.7+6` ```powershell .\CreateMsix.ps1 ` # Mandatory inputs -ZipFileUrl "https://example.com/file.zip" ` + -PackageName "OpenJDK21U-jdk-x64-windows-hotspot" ` -PublisherCN "ExamplePublisher" ` -ProductMajorVersion 21 ` -ProductMinorVersion 0 ` @@ -42,21 +46,21 @@ Please take a look at the [Dependencies](#dependencies) section above to make su -Vendor "Eclipse Adoptium" ` -VendorBranding "Eclipse Temurin" ` -MsixDisplayName "Eclipse Temurin 17.0.15+6 (x64)" ` - -outputName 'Eclipse-Temurin-21.0.7-aarch64' ` # Dictates the output filename without the .msix extension - -Description "Eclipse Temurin" ` # Example: "Eclipse Temurin Development Kit with Hotspot" + -Description "Eclipse Temurin" ` # 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 + -SigningCertPath "C:\path\to\cert.pfx" # Used to sign with signtool.exe, typically .pfx file -SigningPassword "your cert's password" - -VerboseOutput # Keeps $global:ProgressPreference at original value (if not verbose, this value is set to 'SilentlyContinue' which increases the speed of unzipping binaries) + -OutputFileName "OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6.msix" ` + -VerboseOutput # Keeps $global:ProgressPreference at original value (if not verbose, this value is set to 'SilentlyContinue' which increases the speed of unzipping binaries) ``` ## Creating MSIX Files Manually -If you would like to create MSIX files manually, there are not that many powershell commands to run. A good amount of the work comes form ensuring that the `AppXManifest.xml` file contains the correct configuration parameters. If you would like to manually build your `msix` files, then you can follow the commands in the sections below after: -1. Coppying `msix/templates/pri_config.xml` to your project root +If you would like to create MSIX files manually, there are not that many powershell commands to run. A good amount 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, then 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) -Note: This assumes you have a file in your `/pr` directory called `AppXManifest.xml`. If not, you will need to 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 +Note: This assumes you have a file in your `/pr` (project root) directory called `AppXManifest.xml`. If not, you will need to 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 ```powershell makepri.exe new ` /o ` @@ -94,7 +98,7 @@ signtool.exe sign ` Note: These commands must be run from a terminal with administrator privileges ## Install using MSIX file -- If your `.msix` file was signed with a cert that is trusted by Microsoft, then you should be able to to double click it and install via the GUI. +- If your `.msix` file was signed with a cert that is trusted by Microsoft, then you should be able to double click it and install via the GUI. - If it was signed by a cert that is only trusted by the local computer, you will need to run the powershell command below from a terminal with admin privileges - If your `.msix` file was not signed at all, you will not be able to install from it (even if your machine is in developer mode) ```powershell diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index 54bc20a74..2b929acc1 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -4,8 +4,9 @@ Variables to replace: - VENDOR - Example: Eclipse Adoptium - VENDOR_BRANDING - Example: Eclipse Temurin - MSIX_DISPLAYNAME - Example: Eclipse Temurin with hotspot 17.0.15+6 (x64) - - OUTPUT_NAME - Example: OpenJDK17U-jdk-x64-windows-hotspot-17.0.15-6 - Note: OUTPUT_NAME cannot contain spaces or underscores. + - PACKAGE_NAME - Example: OpenJDK17U-jdk-x64-windows-hotspot + IMPORTANT: This needs to be consistent with previous releases for upgrades to work as expected + Note: PACKAGE_NAME cannot contain spaces or underscores. - DESCRIPTION - This is optional. Example: "Development Kit with Hotspot" - PRODUCT_MAJOR_VERSION - Example: if the version is 17.0.15+6, this is 17 - PRODUCT_MINOR_VERSION - Example: if the version is 17.0.15+6, this is 0 @@ -13,7 +14,7 @@ Variables to replace: - PRODUCT_BUILD_NUMBER - Example: if the version is 17.0.15+6, this is 6 - ARCH - Valid architectures: x86, x64, arm, arm64, x86a64, neutral - PUBLISHER_CN - Set this to anything 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. + This may include additional fields in the name, such as 'O=...', 'L=...', 'S=...', and/or others. --> - From 9accacf6b377265ac3cce6d9d73d9e186328132a Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Thu, 15 May 2025 17:29:21 -0700 Subject: [PATCH 15/39] First attempt to move to helper files and functions --- msix/CreateMsix.ps1 | 155 ++++++++++++++++++-------------------- msix/scripts/Helpers.ps1 | 84 +++++++++++++++++++++ msix/scripts/SetupEnv.ps1 | 72 ++++++++++-------- 3 files changed, 198 insertions(+), 113 deletions(-) create mode 100644 msix/scripts/Helpers.ps1 diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 8d41603eb..c72dbf8f8 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -164,79 +164,74 @@ param ( [switch]$VerboseOutput ) -###### Validate inputs -if (-not $ZipFilePath -and -not $ZipFileUrl) { - throw "Error: You must provide either -ZipFilePath or -ZipFileUrl." -} -if ($ZipFilePath -and $ZipFileUrl) { - throw "Error: You cannot provide both -ZipFilePath and -ZipFileUrl." -} -if (($SigningPassword -and -not $SigningCertPath) -or ($SigningCertPath -and -not $SigningPassword)) { - throw "Error: Both SigningCertPath and SigningPassword must be provided together." -} # Set $ProgressPreference to 'SilentlyContinue' if the verbose flag is not set +$OriginalProgressPreference = $global:ProgressPreference if (-not $VerboseOutput) { - $OriginalProgressPreference = $global:ProgressPreference $global:ProgressPreference = 'SilentlyContinue' } -if (-not $Description) { - $Description = $VendorBranding -} -if (-not $MsixDisplayName) { - $MsixDisplayName = "$VendorBranding $ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion+$ProductBuildNumber ($Arch)" -} -if (-not $OutputFileName) { - $OutputFileName = "OpenJDK${ProductMajorVersion}U-jdk-$Arch-windows-hotspot-$ProductMajorVersion.$ProductMinorVersion.$ProductMaintenanceVersion_$ProductBuildNumber" -} -###### End: Validate inputs - -###### Set environment variables -$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path -# Run the SetupEnv.ps1 script located in the scripts folder -# Sets $Env:Windows_tools_base, $Env:srcFolder, $Env:workspace, $Env:output, $Env:appxTemplate, and $Env:priConfig env vars -# Cleans src and workspace folders -$setupEnvScriptPath = Join-Path -Path $scriptPath -ChildPath "scripts\SetupEnv.ps1" -if (-not (Test-Path -Path $setupEnvScriptPath)) { - throw "Error: The SetupEnv.ps1 script was not found at '$setupEnvScriptPath'." + +# 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'." } -& $setupEnvScriptPath -Write-Host "Environment setup script executed successfully." -###### End: Set environment variables - -# Handles local zip file -if ($ZipFilePath) { - if (-not (Test-Path -Path $ZipFilePath)) { - throw "Error: The file at path '$ZipFilePath' does not exist." - } - # Copy and unzip the file - Expand-Archive -Path $ZipFilePath -DestinationPath $Env:workspace -Force - Write-Host "Zip file extracted to: $Env:workspace." +. $HelpersScriptPath +# Validate the inputs +## 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'." } -# Handles zip from URL -elseif ($ZipFileUrl) { - $fileName = [System.IO.Path]::GetFileName($ZipFileUrl) - $downloadPath = Join-Path -Path $Env:workspace -ChildPath $fileName - - # download zip file (needs to be silent or it will print the progress bar and take ~10 times as long to download) - $OriginalLocalProgressPreference = $ProgressPreference - $ProgressPreference = 'SilentlyContinue' - Invoke-WebRequest -Uri $ZipFileUrl -OutFile $downloadPath - $ProgressPreference = $OriginalLocalProgressPreference - - # unzip file - Expand-Archive -Path $downloadPath -DestinationPath $Env:workspace -Force - # remove zip file since contents are extracted - Remove-Item -Path $downloadPath -Force - Write-Host "Zip file downloaded and extracted to: $Env:workspace" +. $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 = Clean-ChildFolder ` + -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "src") ` + -ExcludeSubfolder "_msix_logos" +$workspaceFolder = Clean-ChildFolder -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "workspace") +$outputFolder = Clean-ChildFolder -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) { + $ZipFilePath = DownloadFileFromUrl -Url $ZipFileUrl -DestinationDirectory $workspaceFolder } +UnzipFile -ZipFilePath $ZipFilePath -DestinationPath $workspaceFolder -# Move contents of the unzipped file to $Env:srcFolder -$unzippedFolder = Join-Path -Path $Env:workspace -ChildPath (Get-ChildItem -Path $Env:workspace -Directory | Select-Object -First 1).Name -Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $Env:srcFolder -Force +# 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 -# Read the content of the appx template (path from SetupEnv.ps1) -$content = Get-Content -Path $Env:appxTemplate +$appxTemplate = Join-Path -Path $scriptPath -ChildPath "templates\AppXManifestTemplate.xml" +$content = Get-Content -Path $appxTemplate # Replace all instances of placeholders with the provided values $updatedContent = $content ` @@ -254,41 +249,41 @@ $updatedContent = $content ` # Write the updated content to the new AppXManifest.xml file -$appxManifestPath = Join-Path -Path $Env:srcFolder -ChildPath "AppXManifest.xml" +$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) -Copy-Item -Path $Env:priConfig -Destination $Env:srcFolder -Force -Write-Host "pri_config.xml copied to '$Env:srcFolder'" +$priConfig = Join-Path -Path $scriptPath -ChildPath "templates\pri_config.xml" +Copy-Item -Path $priConfig -Destination $srcFolder -Force +Write-Host "pri_config.xml copied to '$srcFolder'" -& "$Env:Windows_tools_base\makepri.exe" new ` +# Create _resources.pri file based on pri_config.xml +& "$WindowsSdkPath\makepri.exe" new ` /o ` - /pr $Env:srcFolder ` - /cf "$Env:srcFolder\pri_config.xml" ` - /of "$Env:srcFolder\_resources.pri" ` + /pr $srcFolder ` + /cf "$srcFolder\pri_config.xml" ` + /of "$srcFolder\_resources.pri" ` /mf appx -& "$Env:Windows_tools_base\makeappx.exe" pack ` +# Create the MSIX package +& "$WindowsSdkPath\makeappx.exe" pack ` /o ` - /d "$Env:srcFolder" ` - /p "$Env:output\$OutputFileName" - + /d "$srcFolder" ` + /p "$outputFolder\$OutputFileName" +# Sign the MSIX package if a signing certificate is provided if ($SigningCertPath) { - & "$Env:Windows_tools_base\signtool.exe" sign ` + & "$WindowsSdkPath\signtool.exe" sign ` /fd SHA256 ` /a ` /f $SigningCertPath ` /p "$SigningPassword" ` - "$Env:output\$OutputFileName" + "$outputFolder\$OutputFileName" Write-Host "MSIX package signed successfully." } else { Write-Host "SigningCertPath not provided. Skipping signing process." } -# Set $ProgressPreference back to its original value -if (-not $VerboseOutput) { - $global:ProgressPreference = $OriginalProgressPreference -} \ No newline at end of file +$global:ProgressPreference = $OriginalProgressPreference \ No newline at end of file diff --git a/msix/scripts/Helpers.ps1 b/msix/scripts/Helpers.ps1 new file mode 100644 index 000000000..2e4583f9c --- /dev/null +++ b/msix/scripts/Helpers.ps1 @@ -0,0 +1,84 @@ + +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-Output "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-Output "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-Output "Downloading file from $Url to $DestinationDirectory" + + # download zip file (needs to be silent or it will print the progress bar and take ~10 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-Output "Unzipping file $ZipFilePath to $DestinationPath" + Expand-Archive -Path $ZipFilePath -DestinationPath $DestinationPath -Force +} + diff --git a/msix/scripts/SetupEnv.ps1 b/msix/scripts/SetupEnv.ps1 index 9daae5a72..d3903ec9f 100644 --- a/msix/scripts/SetupEnv.ps1 +++ b/msix/scripts/SetupEnv.ps1 @@ -1,39 +1,45 @@ +function Get-WindowsSdkPath { + param( + [string]$Arch, + [string]$WIN_SDK_FULL_VERSION = $null, + [string]$WIN_SDK_MAJOR_VERSION = $null + ) -# Set default windows SDK version to use if not already set -if (-not $Env:WIN_SDK_FULL_VERSION) { - $Env:WIN_SDK_FULL_VERSION = "10.0.22621.0" -} -if (-not $Env:WIN_SDK_MAJOR_VERSION) { - $Env:WIN_SDK_MAJOR_VERSION = "10" -} -Write-Host "WIN_SDK_FULL_VERSION is set to $Env:WIN_SDK_FULL_VERSION." -Write-Host "WIN_SDK_MAJOR_VERSION is set to $Env:WIN_SDK_MAJOR_VERSION." -$Env:Windows_tools_base = "$Env:ProgramFiles (x86)\Windows Kits\$Env:WIN_SDK_MAJOR_VERSION\bin\$Env:WIN_SDK_FULL_VERSION\$Arch" + # 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" + } -# Set path to src folder -$Env:srcFolder = Join-Path -Path $scriptPath -ChildPath "src" -# Clean src folder by deleting all contents of the src folder except what is in src\_msix_logos -Get-ChildItem -Path $Env:srcFolder -Recurse | Where-Object { - $_.FullName -notlike "*\_msix_logos*" -} | Remove-Item -Recurse -Force + 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." -# Ensure 'workspace' folder exists -$Env:workspace = Join-Path -Path $scriptPath -ChildPath "workspace" -if (-not (Test-Path -Path $Env:workspace)) { - New-Item -ItemType Directory -Path $Env:workspace | Out-Null -} -# Clean workspace folder by deleting all contents -Get-ChildItem -Path $Env:workspace -Recurse | Remove-Item -Recurse -Force + $WindowsSdkPath = Join-Path -Path "${Env:ProgramFiles(x86)}\Windows Kits\$WIN_SDK_MAJOR_VERSION\bin\$WIN_SDK_FULL_VERSION" -ChildPath $Arch -# Ensure 'output' folder exists -$Env:output = Join-Path -Path $scriptPath -ChildPath "output" -if (-not (Test-Path -Path $Env:output)) { - New-Item -ItemType Directory -Path $Env:output | Out-Null + return $WindowsSdkPath } -# Clean output folder by deleting all contents -Get-ChildItem -Path $Env:output -Recurse | Remove-Item -Recurse -Force -## Update the file content of AppXManifest.xml -# Define the path to the file -$Env:appxTemplate = Join-Path -Path $scriptPath -ChildPath "templates\AppXManifestTemplate.xml" -$Env:priConfig = Join-Path -Path $scriptPath -ChildPath "templates\pri_config.xml" \ No newline at end of file +function Clean-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 From 765b378d914cc5e41af7567c6c36778aff832c80 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Thu, 15 May 2025 18:00:34 -0700 Subject: [PATCH 16/39] Cleaned up code + fixed typos --- msix/CreateMsix.ps1 | 32 ++++++++------------------------ msix/README.md | 5 ++--- msix/scripts/Helpers.ps1 | 20 ++++++++++++-------- 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index c72dbf8f8..6d9c19f93 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -66,11 +66,6 @@ Optional. The name of the output file. If not provided, a default name will be generated based on the VendorBranding and version information. -.PARAMETER VerboseOutput - Optional. If specified, $global:ProgressPreference is not set to 'SilentlyContinue'. - Note: Unzipping binaries is much faster if not verbose. (Because the progress bar is not shown) - Alias: -v. - .EXAMPLE .\CreateMsix.ps1 ` -ZipFilePath "C:\path\to\file.zip" ` @@ -102,7 +97,6 @@ -SigningCertPath "C:\path\to\cert.pfx" -SigningPassword "your cert's password" -OutputFileName "OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6.msix" ` - -VerboseOutput .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: @@ -157,19 +151,9 @@ param ( [string]$SigningPassword, [Parameter(Mandatory = $false)] - [string]$OutputFileName, - - [Parameter(Mandatory = $false, HelpMessage = "Include this flag to output verbose messages.")] - [Alias("v")] - [switch]$VerboseOutput + [string]$OutputFileName ) -# Set $ProgressPreference to 'SilentlyContinue' if the verbose flag is not set -$OriginalProgressPreference = $global:ProgressPreference -if (-not $VerboseOutput) { - $global:ProgressPreference = 'SilentlyContinue' -} - # Get the path to msix folder (parent directory of this script) $MsixDirPath = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -212,17 +196,19 @@ $WindowsSdkPath = Get-WindowsSdkPath ` Write-Host "Windows SDK path: $WindowsSdkPath" # Clean the srce, workspace, and output folders -$srcFolder = Clean-ChildFolder ` +$srcFolder = Clean-TargetFolder ` -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "src") ` -ExcludeSubfolder "_msix_logos" -$workspaceFolder = Clean-ChildFolder -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "workspace") -$outputFolder = Clean-ChildFolder -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "output") +$workspaceFolder = Clean-TargetFolder -TargetFolder (Join-Path -Path $MsixDirPath -ChildPath "workspace") +$outputFolder = Clean-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 @@ -230,7 +216,7 @@ $unzippedFolder = Join-Path -Path $workspaceFolder -ChildPath (Get-ChildItem -Pa Move-Item -Path (Join-Path -Path $unzippedFolder -ChildPath "*") -Destination $srcFolder -Force Remove-Item -Path $unzippedFolder -Recurse -Force -$appxTemplate = Join-Path -Path $scriptPath -ChildPath "templates\AppXManifestTemplate.xml" +$appxTemplate = Join-Path -Path $MsixDirPath -ChildPath "templates\AppXManifestTemplate.xml" $content = Get-Content -Path $appxTemplate # Replace all instances of placeholders with the provided values @@ -254,7 +240,7 @@ 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 $scriptPath -ChildPath "templates\pri_config.xml" +$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'" @@ -285,5 +271,3 @@ if ($SigningCertPath) { else { Write-Host "SigningCertPath not provided. Skipping signing process." } - -$global:ProgressPreference = $OriginalProgressPreference \ No newline at end of file diff --git a/msix/README.md b/msix/README.md index 6947be7f7..818f35b3e 100644 --- a/msix/README.md +++ b/msix/README.md @@ -45,13 +45,12 @@ IMPORTANT: make sure to set the `-PackageName` since this needs to be consistent # 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)" ` + -MsixDisplayName "Eclipse Temurin 21.0.7+6 (x64)" ` + -OutputFileName "OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6.msix" ` -Description "Eclipse Temurin" ` # 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" - -OutputFileName "OpenJDK21U-jdk_x64_windows_hotspot_21.0.7_6.msix" ` - -VerboseOutput # Keeps $global:ProgressPreference at original value (if not verbose, this value is set to 'SilentlyContinue' which increases the speed of unzipping binaries) ``` ## Creating MSIX Files Manually If you would like to create MSIX files manually, there are not that many powershell commands to run. A good amount 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, then you can follow the commands in the sections below after: diff --git a/msix/scripts/Helpers.ps1 b/msix/scripts/Helpers.ps1 index 2e4583f9c..37e553106 100644 --- a/msix/scripts/Helpers.ps1 +++ b/msix/scripts/Helpers.ps1 @@ -11,7 +11,7 @@ function ValidateZipFileInput { throw "Error: You cannot provide both -ZipFilePath and -ZipFileUrl." } else { - Write-Output "ZipFile input validation passed." + Write-Host "ZipFile input validation passed." } } @@ -21,14 +21,13 @@ function ValidateSigningInput { [string]$SigningPassword ) if ( - ($SigningPassword -and -not $SigningCertPath) - -or + ($SigningPassword -and -not $SigningCertPath) -or ($SigningCertPath -and -not $SigningPassword) - ) { + ) { throw "Error: Both SigningCertPath and SigningPassword must be provided together." } else { - Write-Output "Signing input validation passed." + Write-Host "Signing input validation passed." } } @@ -56,9 +55,9 @@ function DownloadFileFromUrl { $fileName = [System.IO.Path]::GetFileName($ZipFileUrl) $downloadPath = Join-Path -Path $DestinationDirectory -ChildPath $fileName - Write-Output "Downloading file from $Url to $DestinationDirectory" + Write-Host "Downloading file from $Url to $DestinationDirectory" - # download zip file (needs to be silent or it will print the progress bar and take ~10 times as long to download) + # 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 @@ -78,7 +77,12 @@ function UnzipFile { if (-not (Test-Path -Path $DestinationPath)) { New-Item -ItemType Directory -Path $DestinationPath | Out-Null } - Write-Output "Unzipping file $ZipFilePath to $DestinationPath" + 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 } From b1928ae75146409aaac45c5380f6e669d81a17ca Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Thu, 15 May 2025 18:05:59 -0700 Subject: [PATCH 17/39] Updated input order --- msix/CreateMsix.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 6d9c19f93..9967961ed 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -141,6 +141,9 @@ param ( [Parameter(Mandatory = $false)] [string]$MsixDisplayName = "", + [Parameter(Mandatory = $false)] + [string]$OutputFileName + [Parameter(Mandatory = $false)] [string]$Description = "", @@ -149,9 +152,6 @@ param ( [Parameter(Mandatory = $false)] [string]$SigningPassword, - - [Parameter(Mandatory = $false)] - [string]$OutputFileName ) # Get the path to msix folder (parent directory of this script) From c297ee725704e3ab44320631d3a3b85593fc65f9 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Thu, 15 May 2025 18:24:28 -0700 Subject: [PATCH 18/39] Added commas back --- msix/CreateMsix.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 9967961ed..eae33f38b 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -142,7 +142,7 @@ param ( [string]$MsixDisplayName = "", [Parameter(Mandatory = $false)] - [string]$OutputFileName + [string]$OutputFileName, [Parameter(Mandatory = $false)] [string]$Description = "", @@ -151,7 +151,7 @@ param ( [string]$SigningCertPath, [Parameter(Mandatory = $false)] - [string]$SigningPassword, + [string]$SigningPassword ) # Get the path to msix folder (parent directory of this script) From 9078a949e52ddac42ad459764ad8f9ec027da493 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Thu, 15 May 2025 19:42:21 -0700 Subject: [PATCH 19/39] Added headers --- msix/scripts/Helpers.ps1 | 12 +++++ msix/scripts/SetupEnv.ps1 | 100 +++++++++++++++++++++----------------- 2 files changed, 68 insertions(+), 44 deletions(-) diff --git a/msix/scripts/Helpers.ps1 b/msix/scripts/Helpers.ps1 index 37e553106..005f2893a 100644 --- a/msix/scripts/Helpers.ps1 +++ b/msix/scripts/Helpers.ps1 @@ -1,3 +1,15 @@ +<# +.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 ValidateZipFileInput { param ( diff --git a/msix/scripts/SetupEnv.ps1 b/msix/scripts/SetupEnv.ps1 index d3903ec9f..a6d1f83ab 100644 --- a/msix/scripts/SetupEnv.ps1 +++ b/msix/scripts/SetupEnv.ps1 @@ -1,45 +1,57 @@ -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 Clean-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 +<# +.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 Clean-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 From d629cb22e5bc63ff76c0b07ba7ff273a10eba90f Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Fri, 16 May 2025 09:51:09 -0700 Subject: [PATCH 20/39] Updated manifest file --- msix/templates/AppXManifestTemplate.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index 2b929acc1..99a204c68 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -76,8 +76,8 @@ Variables to replace: EntryPoint="Windows.FullTrustApplication" desktop4:SupportsMultipleInstances="true" desktop4:Subsystem="console"> - From ec05c00d908fb13118d5e620898e45851520a980 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Fri, 16 May 2025 11:01:12 -0700 Subject: [PATCH 21/39] Cleaned up spelling and grammar --- msix/CreateMsix.ps1 | 24 +++++---- msix/README.md | 72 ++++++++++++++----------- msix/templates/AppXManifestTemplate.xml | 1 - 3 files changed, 54 insertions(+), 43 deletions(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index eae33f38b..7cefb34db 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -15,16 +15,18 @@ 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. + 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. + Optional. Default: Eclipse Adoptium .PARAMETER VendorBranding - Optional. Default: Eclipse Temurin + 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)". @@ -33,25 +35,25 @@ .PARAMETER Description Optional. Example: "Eclipse Temurin Development Kit with Hotspot". - Default: $VendorBranding. + Default: $VendorBranding .PARAMETER ProductMajorVersion - Example: if the version is 17.0.15+6, this is 17. + 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. + 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. + 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. + 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 anything on the right side of your `CN=` field in your .pfx file. + 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 @@ -64,7 +66,8 @@ .PARAMETER OutputFileName Optional. The name of the output file. - If not provided, a default name will be generated based on the VendorBranding and version information. + 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" .EXAMPLE .\CreateMsix.ps1 ` @@ -222,7 +225,6 @@ $content = Get-Content -Path $appxTemplate # Replace all instances of placeholders with the provided values $updatedContent = $content ` -replace "\{VENDOR\}", $Vendor ` - -replace "\{VENDOR_BRANDING\}", $VendorBranding ` -replace "\{MSIX_DISPLAYNAME\}", $MsixDisplayName ` -replace "\{PACKAGE_NAME\}", $PackageName ` -replace "\{DESCRIPTION\}", $Description ` diff --git a/msix/README.md b/msix/README.md index 818f35b3e..80d24e0eb 100644 --- a/msix/README.md +++ b/msix/README.md @@ -1,42 +1,34 @@ +# 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 is placed at `C:\Users\jmartinjaffe\AppData\Local\${Vendor}\WindowsApps`. MSIX is also the required package type for distributing applications through the Microsoft Store. + # 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 `Visual Studio` installation directories. +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` -If you are running the `CreateMsix.ps1` and have all files available, you will need to check which version(s) of `Visual Studio` or `Windows SDK` you have installed. If you want to use a version other than `10.0.22621.0`, you will need to set the following environment variables: +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` of the `Windows Kits` section of your `Visual Studio` or `Windows SDK` installation directory. We currently default to using `10.0.22621.0`, so the 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`). +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, see the `powershell` style header within `msix/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. -IMPORTANT: make sure to set the `-PackageName` since 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`) +For more information on each variable, see the `powershell` style header within `msix/CreateMsix.ps1` -*First Example*: Running with only required inputs. This will produce an MSIX file, but many values (ex: DisplayName) will take the default Eclipse/Temurin value. Note: either `-ZipFilePath` or `-ZipFileUrl` are required inputs, but you cannot specify both. This example builds an Eclipse Temurin msix for jdk `17.0.15+6` -```powershell -.\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" ` -``` +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`) -*Second Option*: Running with all required + optional inputs. Below, you will see the inputs divided into sections: required, optional with a default value (shown below), optional + changes behavior if omitted. This example builds an Eclipse Temurin msix for jdk `21.0.7+6` +**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" ` - -PublisherCN "ExamplePublisher" ` + -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 ` @@ -44,22 +36,40 @@ IMPORTANT: make sure to set the `-PackageName` since this needs to be consistent -Arch "aarch64" ` # Optional inputs: These are the defaults that will be used if not specified -Vendor "Eclipse Adoptium" ` - -VendorBranding "Eclipse Temurin" ` + -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 Temurin" ` # Example: "Eclipse Temurin Development Kit with Hotspot" + -Description "Eclipse Temurin" ` # 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 + -SigningCertPath "C:\path\to\cert.pfx" # Used to sign with signtool.exe, typically .pfx file -SigningPassword "your cert's password" ``` + +**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 -If you would like to create MSIX files manually, there are not that many powershell commands to run. A good amount 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, then you can follow the commands in the sections below after: +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) -Note: This assumes you have a file in your `/pr` (project root) directory called `AppXManifest.xml`. If not, you will need to 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 +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 ` @@ -82,8 +92,8 @@ makeappx.exe pack ` 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 let you install from an unsigned MSIX file, even in developer mode - - ie: the step above is mandatory for testing new `msix` files made locally, even if it is not intended to be published +- 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 ` @@ -97,9 +107,9 @@ signtool.exe sign ` Note: These commands must be run from a terminal with administrator privileges ## Install using MSIX file -- If your `.msix` file was signed with a cert that is trusted by Microsoft, then you should be able to double click it and install via the GUI. -- If it was signed by a cert that is only trusted by the local computer, you will need to run the powershell command below from a terminal with admin privileges -- If your `.msix` file was not signed at all, you will not be able to install from it (even if your machine is in developer mode) +- 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) ```powershell Add-AppPackage -Path C:\path\to\msix\file.msix -AllowUnsigned -verbose ``` @@ -110,7 +120,7 @@ Get info on all packages installed via MSIX: Get-AppPackage -AllUsers | Select Name, PackageFullName ``` -Narrow down info to just packages containing the substring `jdk`: +Narrow down the information to only packages containing the substring `jdk`: ```powershell Get-AppPackage -AllUsers | Select Name, PackageFullName | Select-String -Pattern "jdk" ``` diff --git a/msix/templates/AppXManifestTemplate.xml b/msix/templates/AppXManifestTemplate.xml index 99a204c68..c54fcbf51 100644 --- a/msix/templates/AppXManifestTemplate.xml +++ b/msix/templates/AppXManifestTemplate.xml @@ -2,7 +2,6 @@ - - - - - {MSIX_DISPLAYNAME} - {VENDOR} - {DESCRIPTION} - _msix_logos/duke50.png - disabled - disabled - defer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .jar - - - open - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/msix/templates/AppXManifestTemplate11.xml b/msix/templates/AppXManifestTemplate11.xml new file mode 100644 index 000000000..e03328855 --- /dev/null +++ b/msix/templates/AppXManifestTemplate11.xml @@ -0,0 +1,869 @@ + + + + + + + {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 From 00ebded9d61f91f89e720526ed65c0a79df24870 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Mon, 19 May 2025 15:31:08 -0700 Subject: [PATCH 35/39] Now ensuring input version has corresponding AppXManifest.xml template --- msix/CreateMsix.ps1 | 5 ++++- msix/scripts/Helpers.ps1 | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/msix/CreateMsix.ps1 b/msix/CreateMsix.ps1 index 413c1df98..344ff8fbd 100644 --- a/msix/CreateMsix.ps1 +++ b/msix/CreateMsix.ps1 @@ -181,6 +181,9 @@ if (-not (Test-Path -Path $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 @@ -233,7 +236,7 @@ $unzippedFolder = Join-Path -Path $workspaceFolder -ChildPath (Get-ChildItem -Pa 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.xml" +$appxTemplate = Join-Path -Path $MsixDirPath -ChildPath "templates\AppXManifestTemplate${ProductMajorVersion}.xml" $content = Get-Content -Path $appxTemplate # Replace all instances of placeholders with the provided values diff --git a/msix/scripts/Helpers.ps1 b/msix/scripts/Helpers.ps1 index e11c98020..632c76d8d 100644 --- a/msix/scripts/Helpers.ps1 +++ b/msix/scripts/Helpers.ps1 @@ -11,6 +11,24 @@ #> +function ValidateMajorVersion { + param( + [Parameter(Mandatory=$true)] + [string]$majorVersion + ) + + # Define valid major versions + $validMajorVersions = @('11', '17', '21') + + if ($validVersions -contains $majorVersion) { + Write-Host "The major version ($majorVersion) is valid." + exit 0 + } else { + Write-Host "The major version ($majorVersion) is NOT valid. Valid versions are: $($validVersions -join ', ')." + exit 1 + } +} + function ValidateZipFileInput { param ( [string]$ZipFilePath, From 9dc7f5cafcced6e85e42ee9445b4f571d6a50cb6 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Mon, 19 May 2025 15:35:22 -0700 Subject: [PATCH 36/39] updated Helpers.ps1 --- msix/scripts/Helpers.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/msix/scripts/Helpers.ps1 b/msix/scripts/Helpers.ps1 index 632c76d8d..cea626d79 100644 --- a/msix/scripts/Helpers.ps1 +++ b/msix/scripts/Helpers.ps1 @@ -14,15 +14,14 @@ function ValidateMajorVersion { param( [Parameter(Mandatory=$true)] - [string]$majorVersion + [int]$majorVersion ) # Define valid major versions - $validMajorVersions = @('11', '17', '21') + $validMajorVersions = @(11, 17, 21) - if ($validVersions -contains $majorVersion) { + if ($validMajorVersions -contains $majorVersion) { Write-Host "The major version ($majorVersion) is valid." - exit 0 } else { Write-Host "The major version ($majorVersion) is NOT valid. Valid versions are: $($validVersions -join ', ')." exit 1 From b26c9b6bda08999db1581fa49cb52f0f946890e2 Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 20 May 2025 11:45:32 -0700 Subject: [PATCH 37/39] Updated jdk11 appxmanifest.xml --- msix/templates/AppXManifestTemplate11.xml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/msix/templates/AppXManifestTemplate11.xml b/msix/templates/AppXManifestTemplate11.xml index e03328855..d6a7ed7fe 100644 --- a/msix/templates/AppXManifestTemplate11.xml +++ b/msix/templates/AppXManifestTemplate11.xml @@ -131,26 +131,6 @@ Variables to replace: - - - - - - - - - - - Date: Tue, 20 May 2025 15:26:36 -0700 Subject: [PATCH 38/39] Now using Appx commands in README.md --- msix/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/msix/README.md b/msix/README.md index de36630f5..21daad035 100644 --- a/msix/README.md +++ b/msix/README.md @@ -120,27 +120,27 @@ Note: These commands must be run from a terminal with administrator privileges - 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) ```powershell -Add-AppPackage -Path C:\path\to\msix\file.msix -AllowUnsigned -verbose +Add-AppxPackage -Path C:\path\to\msix\file.msix -AllowUnsigned -verbose ``` ## Check info of installed MSIX Get info on all packages installed via MSIX: ```powershell -Get-AppPackage -AllUsers | Select Name, PackageFullName +Get-AppxPackage -AllUsers | Select Name, PackageFullName ``` Narrow down the information to only packages containing the substring `jdk`: ```powershell -Get-AppPackage -AllUsers | Select Name, PackageFullName | Select-String -Pattern "jdk" +Get-AppxPackage -AllUsers -Name *jdk* | Select-Object Name, PackageFullName ``` Get more detailed information on a specific MSIX package: ```powershell -Get-AppPackage -Name "package-name" +Get-AppxPackage -Name "package-name" ``` ## Uninstall MSIX ```powershell -Remove-AppPackage -AllUsers -package "package-full-name" +Remove-AppxPackage -AllUsers -package "package-full-name" ``` Note: The `package-full-name` must appear as it does in the `PackageFullName` attribute found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file From bbbd252eb285523523c9fa3a5828af82888a9baf Mon Sep 17 00:00:00 2001 From: jmjaffe37 Date: Tue, 20 May 2025 15:42:26 -0700 Subject: [PATCH 39/39] Updated info on the -AllUsers flag --- msix/README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/msix/README.md b/msix/README.md index 21daad035..b0484f583 100644 --- a/msix/README.md +++ b/msix/README.md @@ -118,20 +118,33 @@ 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) +- 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 -AllUsers | Select Name, PackageFullName +Get-AppxPackage | Select Name, PackageFullName ``` Narrow down the information to only packages containing the substring `jdk`: ```powershell -Get-AppxPackage -AllUsers -Name *jdk* | Select-Object Name, PackageFullName +Get-AppxPackage -Name *jdk* | Select-Object Name, PackageFullName ``` Get more detailed information on a specific MSIX package: @@ -141,6 +154,8 @@ Get-AppxPackage -Name "package-name" ## Uninstall MSIX ```powershell -Remove-AppxPackage -AllUsers -package "package-full-name" +Remove-AppxPackage -package "package-full-name" ``` -Note: The `package-full-name` must appear as it does in the `PackageFullName` attribute found via `Get-AppPackage`, including the package_ID at the end \ No newline at end of file +**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