Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion .azure-pipelines/common-templates/install-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,71 @@ steps:
- task: NodeTool@0
displayName: Install NodeJs
inputs:
versionSpec: 18.x
versionSpec: 20.x

- task: PowerShell@2
displayName: Enable Win32 long paths for Node.js
inputs:
targetType: inline
pwsh: true
script: |
# 1. Enable long paths at the OS level
reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
if ($LASTEXITCODE -ne 0) { Write-Warning "Failed to set LongPathsEnabled registry key (may require admin)" }

# 2. Patch node.exe manifest to declare longPathAware
$nodePath = (Get-Command node).Source
Write-Host "Node.js path: $nodePath"
Write-Host "Node.js version: $(node --version)"

$manifestContent = @"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
</assembly>
"@

$manifestPath = Join-Path ([System.IO.Path]::GetTempPath()) "node-longpath.manifest"
$manifestContent | Set-Content -Path $manifestPath -Encoding UTF8

# Find mt.exe from Windows SDK
$mtCandidates = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin" -Recurse -Filter "mt.exe" -ErrorAction SilentlyContinue |
Where-Object { $_.DirectoryName -match 'x64' } |
Sort-Object { $_.DirectoryName } -Descending

if ($mtCandidates) {
$mtPath = $mtCandidates[0].FullName
Write-Host "Using mt.exe: $mtPath"
& $mtPath -manifest $manifestPath -outputresource:"$nodePath;#1" -nologo
if ($LASTEXITCODE -eq 0) {
Write-Host "Successfully patched node.exe manifest for long path support"
} else {
Write-Warning "mt.exe failed with exit code $LASTEXITCODE - trying external manifest approach"
Copy-Item $manifestPath -Destination "$nodePath.manifest" -Force
Write-Host "Placed external manifest at $nodePath.manifest"
# Enable external manifest preference
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide" /v PreferExternalManifest /t REG_DWORD /d 1 /f
}
} else {
Write-Warning "mt.exe not found - using external manifest approach"
Copy-Item $manifestPath -Destination "$nodePath.manifest" -Force
Write-Host "Placed external manifest at $nodePath.manifest"
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide" /v PreferExternalManifest /t REG_DWORD /d 1 /f
}

# 3. Verify: try creating a file with a long name
$testDir = Join-Path ([System.IO.Path]::GetTempPath()) "longpath-test"
New-Item -ItemType Directory -Path $testDir -Force | Out-Null
$longName = "A" * 250 + ".txt"
$testPath = Join-Path $testDir $longName
Write-Host "Testing long path creation (total length: $($testPath.Length) chars)..."
$result = node -e "const fs = require('fs'); try { fs.writeFileSync('$($testPath -replace '\\','\\\\')','test'); console.log('SUCCESS: Long path write works'); fs.unlinkSync('$($testPath -replace '\\','\\\\')'); } catch(e) { console.error('FAILED:', e.message); process.exit(1); }"
Write-Host $result
Remove-Item $testDir -Recurse -Force -ErrorAction SilentlyContinue

- task: PowerShell@2
displayName: Configure private npm feed
Expand Down Expand Up @@ -96,6 +160,7 @@ steps:
pwsh: true
workingDirectory: "autorest.powershell"
script: |
$env:RUSH_ALLOW_UNSUPPORTED_NODEJS = '1'
npx --no-install rush install
if ($LASTEXITCODE -ne 0) { throw "rush install failed with exit code $LASTEXITCODE" }
npx --no-install rush link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
targetType: inline
pwsh: true
script: |
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -EnableSigning:$${{ parameters.Sign }} -Build -ExcludeExampleTemplates -ExcludeNotesSection -ModuleToGenerate ${{ parameters.ModuleName }} -ApiVersion ${{ parameters.ModuleVersion }}
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -EnableSigning:$${{ parameters.Sign }} -Build -ExcludeExampleTemplates -ExcludeNotesSection -ModuleToGenerate ${{ parameters.ModuleName }} -ApiVersion ${{ parameters.ModuleVersion }} -AllowUnsupportedNode
- template: ../common-templates/guardian-analyzer.yml

- task: PowerShell@2
Expand All @@ -36,7 +36,7 @@ steps:
targetType: inline
pwsh: true
script: |
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test -ModuleToGenerate ${{ parameters.ModuleName }} -ApiVersion ${{ parameters.ModuleVersion }}
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test -ModuleToGenerate ${{ parameters.ModuleName }} -ApiVersion ${{ parameters.ModuleVersion }} -AllowUnsupportedNode

- task: PowerShell@2
displayName: Find Duplicate Commands
Expand Down
6 changes: 3 additions & 3 deletions .azure-pipelines/generation-templates/workload-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
targetType: inline
pwsh: true
script: |
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -EnableSigning:$${{ parameters.Sign }} -Build -ExcludeExampleTemplates -ExcludeNotesSection
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -EnableSigning:$${{ parameters.Sign }} -Build -ExcludeExampleTemplates -ExcludeNotesSection -AllowUnsupportedNode

- template: ../common-templates/guardian-analyzer.yml

Expand All @@ -30,7 +30,7 @@ steps:
targetType: inline
pwsh: true
script: |
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test -AllowUnsupportedNode

- task: PowerShell@2
displayName: Find Duplicate Commands
Expand Down Expand Up @@ -93,4 +93,4 @@ steps:
targetType: inline
pwsh: true
script: |
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory)
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) -AllowUnsupportedNode
Loading
Loading