forked from emscripten-core/emsdk
-
Notifications
You must be signed in to change notification settings - Fork 34
Add catalog signing for .js files for VS signing compliance #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
akoeplinger
merged 4 commits into
dotnet:main
from
jesuszarate:dev/jezarat/catalog-sign-js-files
Mar 31, 2026
+117
−1
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bff6a3e
Add catalog signing for .js files for VS signing compliance
jesuszarate 106fed2
Error when makecat.exe is not found in CI/official builds
akoeplinger 44b61d3
Only log catalog message when file was actually produced
akoeplinger 32b8b3b
Use switch parameter for ErrorIfMakecatNotFound, pass conditionally
akoeplinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Generates a catalog definition file (.cdf) and catalog file (.cat) for all .js files | ||
| in the specified root directory. Used for VS signing compliance - the .js files are | ||
| customer-modifiable and cannot be directly Authenticode-signed. | ||
|
|
||
| .PARAMETER RootPath | ||
| Root directory to search for .js files recursively. | ||
|
|
||
| .PARAMETER CatOutputPath | ||
| Full path for the output .cat file. | ||
| #> | ||
| param( | ||
| [Parameter(Mandatory)][string]$RootPath, | ||
| [Parameter(Mandatory)][string]$CatOutputPath, | ||
| [string]$WindowsSdkDir = '', | ||
| [switch]$ErrorIfMakecatNotFound | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| $cdfPath = [System.IO.Path]::ChangeExtension($CatOutputPath, '.cdf') | ||
|
|
||
| $files = Get-ChildItem -Path $RootPath -Recurse -Filter '*.js' -File | ||
| if ($files.Count -eq 0) { | ||
| Write-Warning "No .js files found under $RootPath - skipping catalog generation." | ||
| exit 0 | ||
| } | ||
|
|
||
| $cdf = @() | ||
| $cdf += '[CatalogHeader]' | ||
| $cdf += "Name=$CatOutputPath" | ||
| $cdf += 'CatalogVersion=2' | ||
| $cdf += 'HashAlgorithms=SHA256' | ||
| $cdf += '' | ||
| $cdf += '[CatalogFiles]' | ||
|
|
||
| $i = 0 | ||
| foreach ($f in $files) { | ||
| $label = "js_${i}_" + ($f.Name -replace '[^\w\.-]', '_') | ||
| $cdf += "<hash>$label=$($f.FullName)" | ||
| $i++ | ||
| } | ||
|
|
||
| $cdf | Set-Content -Path $cdfPath -Encoding ASCII | ||
| Write-Host "Generated CDF with $($files.Count) .js files at $cdfPath" | ||
|
|
||
| $catDir = [System.IO.Path]::GetDirectoryName($CatOutputPath) | ||
| if (-not (Test-Path $catDir)) { | ||
| New-Item -ItemType Directory -Path $catDir -Force | Out-Null | ||
| } | ||
|
|
||
| # Find makecat.exe - it ships with the Windows SDK and may not be on PATH. | ||
| # Prefer WindowsSdkDir if passed from MSBuild (not available in this repo's build | ||
| # context since it uses Microsoft.Build.Traversal, but may be set in other builds). | ||
| $makecat = $null | ||
| if ($WindowsSdkDir -and (Test-Path $WindowsSdkDir)) { | ||
| $makecat = Get-ChildItem -Path (Join-Path $WindowsSdkDir 'bin') -Recurse -Filter 'makecat.exe' -File | | ||
| Where-Object { $_.DirectoryName -match 'x64' } | | ||
| Sort-Object DirectoryName -Descending | | ||
| Select-Object -First 1 | ||
| } | ||
|
|
||
| if (-not $makecat) { | ||
| $makecat = Get-Command makecat.exe -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| if (-not $makecat) { | ||
| # Fallback: search common Windows SDK locations | ||
| $sdkRoot = "${env:ProgramFiles(x86)}\Windows Kits\10\bin" | ||
| if (Test-Path $sdkRoot) { | ||
| $makecat = Get-ChildItem -Path $sdkRoot -Recurse -Filter 'makecat.exe' -File | | ||
|
jesuszarate marked this conversation as resolved.
|
||
| Where-Object { $_.DirectoryName -match 'x64' } | | ||
| Sort-Object DirectoryName -Descending | | ||
| Select-Object -First 1 | ||
| } | ||
| } | ||
|
|
||
| if (-not $makecat) { | ||
| if ($ErrorIfMakecatNotFound) { | ||
| throw "makecat.exe not found. Catalog signing requires the Windows SDK which must be available in CI builds." | ||
| } | ||
| Write-Warning "makecat.exe not found - skipping catalog generation. Catalog signing requires the Windows SDK." | ||
| exit 0 | ||
| } | ||
|
|
||
| $makecatPath = if ($makecat -is [System.Management.Automation.CommandInfo]) { $makecat.Source } else { $makecat.FullName } | ||
| Write-Host "Using makecat.exe at: $makecatPath" | ||
|
|
||
| & $makecatPath $cdfPath | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "makecat.exe failed with exit code $LASTEXITCODE" | ||
| } | ||
|
|
||
| Write-Host "Generated catalog file: $CatOutputPath" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akoeplinger Are there any cases where this would need to run on non-Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of any given this is specifically for VS