-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathinstall-tools.yml
More file actions
169 lines (147 loc) · 6.56 KB
/
Copy pathinstall-tools.yml
File metadata and controls
169 lines (147 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
steps:
- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
version: 8.x
- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
version: 6.x
- task: NuGetToolInstaller@1
displayName: Install Nuget
- task: NuGetAuthenticate@1
- task: PowerShell@2
displayName: Version Check
inputs:
targetType: inline
pwsh: true
script: |
Write-Output $PSVersionTable
- task: NodeTool@0
displayName: Install NodeJs
inputs:
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
inputs:
targetType: filePath
pwsh: true
filePath: $(Build.SourcesDirectory)/tools/Configure-PrivateNpmFeed.ps1
arguments: -SourcesDirectory "$(Build.SourcesDirectory)"
- task: npmAuthenticate@0
displayName: Authenticate to private npm feed
inputs:
workingFile: $(Build.SourcesDirectory)/.npmrc
- task: npmAuthenticate@0
displayName: Authenticate to private npm feed (Rush)
inputs:
workingFile: $(Build.SourcesDirectory)/autorest.powershell/common/config/rush/.npmrc
- task: PowerShell@2
displayName: Apply npm auth config to user profile
inputs:
targetType: inline
pwsh: true
script: |
# Copy authenticated .npmrc to the user home dir so ALL npm subprocesses
# (including autorest's internal npm calls) use the private feed + auth tokens.
$src = "$(Build.SourcesDirectory)/.npmrc"
$dst = Join-Path $env:USERPROFILE ".npmrc"
Copy-Item -Path $src -Destination $dst -Force
Write-Host "Copied npm config to $dst"
- task: Npm@1
displayName: Install AutoRest
inputs:
command: custom
workingDir: $(Build.SourcesDirectory)
customCommand: install --no-package-lock autorest@3.7.2
- task: Npm@1
displayName: Install AutorestCore
inputs:
command: custom
workingDir: $(Build.SourcesDirectory)
customCommand: install --no-package-lock @autorest/core@3.10.4
- task: PowerShell@2
displayName: Pre-populate autorest extension cache
inputs:
targetType: filePath
pwsh: true
filePath: $(Build.SourcesDirectory)/tools/utilities/PrePopulateAutorestCache.ps1
- task: Npm@1
displayName: Install Rush
inputs:
command: custom
workingDir: $(Build.SourcesDirectory)
customCommand: install --no-package-lock @microsoft/rush
- task: PowerShell@2
displayName: Rush Build
inputs:
targetType: inline
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
if ($LASTEXITCODE -ne 0) { throw "rush link failed with exit code $LASTEXITCODE" }
npx --no-install rush rebuild
if ($LASTEXITCODE -ne 0) { throw "rush rebuild failed with exit code $LASTEXITCODE" }