From 6499130fe89c5c07f7aa7d2fd8dc753d3f193f70 Mon Sep 17 00:00:00 2001 From: "Leilei Zhang (from Dev Box)" Date: Wed, 5 Nov 2025 11:25:33 +0800 Subject: [PATCH] use DSCModules and remove the installlocation change --- .pipelines/generateDscManifests.ps1 | 6 ++--- .../CustomAction.cpp | 10 +++----- installer/PowerToysSetupVNext/Core.wxs | 20 +++------------ .../PowerToysSetupVNext/DscResources.wxs | 18 ++++++++++--- installer/PowerToysSetupVNext/Product.wxs | 1 - .../generateAllFileComponents.ps1 | 4 +-- .../generateDscResourcesWxs.ps1 | 25 +++++++++++++++---- src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj | 11 ++++---- tools/build/generate-dsc-manifests.ps1 | 6 ++--- 9 files changed, 56 insertions(+), 45 deletions(-) rename installer/{PowerToysSetup => PowerToysSetupVNext}/generateDscResourcesWxs.ps1 (81%) diff --git a/.pipelines/generateDscManifests.ps1 b/.pipelines/generateDscManifests.ps1 index ceb30f4b9a..e0a2f463af 100644 --- a/.pipelines/generateDscManifests.ps1 +++ b/.pipelines/generateDscManifests.ps1 @@ -65,10 +65,10 @@ if (-not (Test-Path $outputDir)) { New-Item -Path $outputDir -ItemType Directory -Force | Out-Null } -# DSC v3 manifests go to DSCv3 subfolder -$dscOutputDir = Join-Path $outputDir 'DSCv3' +# DSC v3 manifests go to DSCModules subfolder +$dscOutputDir = Join-Path $outputDir 'DSCModules' if (-not (Test-Path $dscOutputDir)) { - Write-Host "Creating DSCv3 subfolder at '$dscOutputDir'." + Write-Host "Creating DSCModules subfolder at '$dscOutputDir'." New-Item -Path $dscOutputDir -ItemType Directory -Force | Out-Null } diff --git a/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp b/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp index 2e3e211fe5..0cfc3b1765 100644 --- a/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp +++ b/installer/PowerToysSetupCustomActionsVNext/CustomAction.cpp @@ -1672,16 +1672,14 @@ UINT __stdcall SetBundleInstallLocationCA(MSIHANDLE hInstall) if (_wcsicmp(regUpgradeCode.c_str(), bundleUpgradeCode.c_str()) == 0) { - // Found matching Bundle, set InstallLocation to DSCv3 subfolder for DSC v3 resource discovery - std::wstring dscv3Location = installationFolder + L"DSCv3"; - + // Found matching Bundle, set InstallLocation LONG setResult = RegSetValueExW(productKey, L"InstallLocation", 0, REG_SZ, - reinterpret_cast(dscv3Location.c_str()), - static_cast((dscv3Location.length() + 1) * sizeof(wchar_t))); + reinterpret_cast(installationFolder.c_str()), + static_cast((installationFolder.length() + 1) * sizeof(wchar_t))); if (setResult == ERROR_SUCCESS) { - WcaLog(LOGMSG_STANDARD, "SetBundleInstallLocationCA: InstallLocation set to DSCv3 subfolder successfully"); + WcaLog(LOGMSG_STANDARD, "SetBundleInstallLocationCA: InstallLocation set successfully"); } else { diff --git a/installer/PowerToysSetupVNext/Core.wxs b/installer/PowerToysSetupVNext/Core.wxs index f65ef1cd16..b71bd44c72 100644 --- a/installer/PowerToysSetupVNext/Core.wxs +++ b/installer/PowerToysSetupVNext/Core.wxs @@ -15,8 +15,8 @@ - - + + @@ -24,8 +24,8 @@ - - + + @@ -63,16 +63,6 @@ - - - - - - - - - - @@ -121,7 +111,6 @@ - @@ -138,7 +127,6 @@ - diff --git a/installer/PowerToysSetupVNext/DscResources.wxs b/installer/PowerToysSetupVNext/DscResources.wxs index 4d73cb42a3..bc5722e8c5 100644 --- a/installer/PowerToysSetupVNext/DscResources.wxs +++ b/installer/PowerToysSetupVNext/DscResources.wxs @@ -3,15 +3,25 @@ - + - - - + + + + + + + + + + + + + diff --git a/installer/PowerToysSetupVNext/Product.wxs b/installer/PowerToysSetupVNext/Product.wxs index 03499c3784..556fddc7f4 100644 --- a/installer/PowerToysSetupVNext/Product.wxs +++ b/installer/PowerToysSetupVNext/Product.wxs @@ -279,7 +279,6 @@ - diff --git a/installer/PowerToysSetupVNext/generateAllFileComponents.ps1 b/installer/PowerToysSetupVNext/generateAllFileComponents.ps1 index 9597af1afe..39020b4f04 100644 --- a/installer/PowerToysSetupVNext/generateAllFileComponents.ps1 +++ b/installer/PowerToysSetupVNext/generateAllFileComponents.ps1 @@ -316,6 +316,6 @@ Generate-FileComponents -fileListName "SettingsV2OOBEAssetsFluentIconsFiles" -wx Generate-FileList -fileDepsJson "" -fileListName WorkspacesImagesComponentFiles -wxsFilePath $PSScriptRoot\Workspaces.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\Assets\Workspaces\" Generate-FileComponents -fileListName "WorkspacesImagesComponentFiles" -wxsFilePath $PSScriptRoot\Workspaces.wxs -#DSC Resources - JSON manifest files in DSCv3 subfolder -Generate-FileList -fileDepsJson "" -fileListName DscJsonFiles -wxsFilePath $PSScriptRoot\DscResources.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\DSCv3\" +#DSC Resources - JSON manifest files in DSCModules subfolder +Generate-FileList -fileDepsJson "" -fileListName DscJsonFiles -wxsFilePath $PSScriptRoot\DscResources.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\DSCModules\" Generate-FileComponents -fileListName "DscJsonFiles" -wxsFilePath $PSScriptRoot\DscResources.wxs diff --git a/installer/PowerToysSetup/generateDscResourcesWxs.ps1 b/installer/PowerToysSetupVNext/generateDscResourcesWxs.ps1 similarity index 81% rename from installer/PowerToysSetup/generateDscResourcesWxs.ps1 rename to installer/PowerToysSetupVNext/generateDscResourcesWxs.ps1 index f76fd71953..f518815590 100644 --- a/installer/PowerToysSetup/generateDscResourcesWxs.ps1 +++ b/installer/PowerToysSetupVNext/generateDscResourcesWxs.ps1 @@ -9,21 +9,28 @@ Param( ) $ErrorActionPreference = 'Stop' + $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$buildOutputDir = Join-Path $scriptDir "..\..\$Platform\$Configuration" + +# Find build output directory with DSCModules subfolder +$buildOutputDir = Join-Path $scriptDir "..\..\$Platform\$Configuration\DSCModules" if (-not (Test-Path $buildOutputDir)) { Write-Error "Build output directory not found: '$buildOutputDir'" exit 1 } +# Find all DSC manifest JSON files $dscFiles = Get-ChildItem -Path $buildOutputDir -Filter "microsoft.powertoys.*.settings.dsc.resource.json" -File if (-not $dscFiles) { Write-Warning "No DSC manifest files found in '$buildOutputDir'" + # Create empty component group $wxsContent = @" - + + + @@ -36,27 +43,32 @@ if (-not $dscFiles) { Write-Host "Found $($dscFiles.Count) DSC manifest file(s)" +# Generate WiX fragment $wxsContent = @" - + + + "@ $componentRefs = @() + foreach ($file in $dscFiles) { $componentId = "DscResource_" + ($file.BaseName -replace '[^A-Za-z0-9_]', '_') $fileId = $componentId + "_File" $guid = [System.Guid]::NewGuid().ToString().ToUpper() + $componentRefs += $componentId $wxsContent += @" - + - + "@ } @@ -65,6 +77,7 @@ $wxsContent += @" + "@ @@ -83,5 +96,7 @@ $wxsContent += @" "@ +# Write the WiX file Set-Content -Path $dscWxsFile -Value $wxsContent + Write-Host "Generated DSC resources WiX fragment: '$dscWxsFile'" diff --git a/src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj b/src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj index 0f9386ff69..9dc11a0a8a 100644 --- a/src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj +++ b/src/dsc/v3/PowerToys.DSC/PowerToys.DSC.csproj @@ -40,10 +40,11 @@ - - - - - + + + + + + \ No newline at end of file diff --git a/tools/build/generate-dsc-manifests.ps1 b/tools/build/generate-dsc-manifests.ps1 index 4545e399df..78cc909174 100644 --- a/tools/build/generate-dsc-manifests.ps1 +++ b/tools/build/generate-dsc-manifests.ps1 @@ -93,10 +93,10 @@ if (-not (Test-Path $outputDir)) { New-Item -Path $outputDir -ItemType Directory -Force | Out-Null } -# DSC v3 manifests go to DSCv3 subfolder -$dscOutputDir = Join-Path $outputDir 'DSCv3' +# DSC v3 manifests go to DSCModules subfolder +$dscOutputDir = Join-Path $outputDir 'DSCModules' if (-not (Test-Path $dscOutputDir)) { - Write-Host "Creating DSCv3 subfolder at '$dscOutputDir'." + Write-Host "Creating DSCModules subfolder at '$dscOutputDir'." New-Item -Path $dscOutputDir -ItemType Directory -Force | Out-Null }