Skip to content

Commit b3ebc37

Browse files
committed
No VCPKG_INSTALLATION_ROOT; find vcpkg.exe
1 parent 6f14f28 commit b3ebc37

4 files changed

Lines changed: 47 additions & 60 deletions

File tree

‎azure-pipelines.yml‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,10 @@ jobs:
8383
feedsToUse: 'config'
8484
nugetConfigPath: '$(nugetConfig)'
8585

86-
- task: CmdLine@2
87-
displayName: Enable Vcpkg Install
86+
- task: PowerShell@2
87+
displayName: Find and Integrate Vcpkg
8888
inputs:
89-
script: |
90-
$(VCPKG_INSTALLATION_ROOT)\vcpkg.exe integrate install
91-
workingDirectory: '$(VCPKG_INSTALLATION_ROOT)'
89+
filePath: 'templates\Find-AndIntegrate-Vcpkg.ps1'
9290

9391
- task: VSBuild@1
9492
displayName: Build Fuzzing Artifacts
@@ -99,14 +97,6 @@ jobs:
9997
msbuildArgs: '/bl:$(artifactsDir)\msbuild.binlog'
10098
maximumCpuCount: true
10199

102-
- task: CopyFiles@2
103-
displayName: Copy vcpkg logs
104-
inputs:
105-
SourceFolder: $(VCPKG_INSTALLATION_ROOT)\buildtrees
106-
Contents: '**\*.log'
107-
TargetFolder: '$(artifactsDir)\vcpkgLogs'
108-
condition: succeededOrFailed()
109-
110100
- task: CopyFiles@2
111101
displayName: Copy Fuzzing Artifacts for Publishing
112102
inputs:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
Write-Host 'PATH entries:'
4+
$env:PATH -split ';' | ForEach-Object { Write-Host $_ }
5+
6+
$pathMatches = @(Get-Command vcpkg.exe -CommandType Application -All -ErrorAction SilentlyContinue |
7+
Select-Object -ExpandProperty Source)
8+
Write-Host 'vcpkg.exe matches on PATH:'
9+
$pathMatches | ForEach-Object { Write-Host $_ }
10+
11+
$diskMatches = @()
12+
$searchRoots = Get-PSDrive -PSProvider FileSystem |
13+
Where-Object { $_.Root -match '^[A-Za-z]:\\$' -and -not $_.DisplayRoot } |
14+
Select-Object -ExpandProperty Root -Unique
15+
16+
foreach ($root in $searchRoots)
17+
{
18+
Write-Host "Searching $root for vcpkg.exe (inaccessible directories are skipped)..."
19+
$diskMatches += @(Get-ChildItem -LiteralPath $root -Filter vcpkg.exe -File -Recurse -ErrorAction SilentlyContinue |
20+
Select-Object -ExpandProperty FullName)
21+
}
22+
23+
$candidates = @($pathMatches + ($diskMatches | Sort-Object) | Select-Object -Unique)
24+
Write-Host 'All discovered vcpkg.exe paths (PATH matches first):'
25+
$candidates | ForEach-Object { Write-Host $_ }
26+
27+
if ($candidates.Count -eq 0)
28+
{
29+
throw 'No vcpkg.exe found on PATH or local drives.'
30+
}
31+
32+
$vcpkg = $candidates[0]
33+
Write-Host "Running: `"$vcpkg`" integrate install"
34+
& $vcpkg integrate install
35+
if ($LASTEXITCODE -ne 0)
36+
{
37+
throw "vcpkg integrate install failed with exit code $LASTEXITCODE."
38+
}

‎templates/README.md‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ Paths that belong to the agent or to the build output are deliberately **not** r
5353
they do not move with the subtree:
5454

5555
- `$(Build.ArtifactStagingDirectory)`, `$(Pipeline.Workspace)`
56-
- `$(Agent.TempDirectory)`, `$(VCPKG_INSTALLATION_ROOT)`
56+
- `$(Agent.TempDirectory)`
5757
- `$(buildOutDir)`, `$(buildOutDirAnyCpu)`, `$(artifactsDir)`, `$(packageLayoutDir)`
5858

59-
`$(VCPKG_INSTALLATION_ROOT)` is the exception worth calling out: it is correctly *not* rooted, but a
60-
consumer may not use the installation it points at. See `useAgentVcpkg` below.
61-
6259
Nested template references need no help. Azure Pipelines resolves a `- template:` reference inside a
6360
template file relative to *that file*, so the job templates find their siblings at any depth. Only
6461
the entry point has to know where the subtree lives.
@@ -84,8 +81,7 @@ is neither a parameter nor a path in this directory.
8481
**Pipeline variables.** None. `jobs-build.yml` sets what it needs at job scope — `solution`, so it
8582
can be rooted, and `EnableDetectorVcpkg`, so Component Governance detects the vcpkg dependencies.
8683

87-
**A Windows agent** with Visual Studio 2022 and vcpkg, exposing `VCPKG_INSTALLATION_ROOT`. The
88-
Microsoft-hosted `windows-2025` image qualifies. **The `Test` and `BuildPowerShellModule` jobs need
84+
**A Windows agent** with Visual Studio 2022 and vcpkg. **The `Test` and `BuildPowerShellModule` jobs need
8985
more than the `Build` job does — see "Agent requirements" below.**
9086

9187
**Outbound network access.** The test jobs reach several public endpoints, which is worth checking
@@ -194,24 +190,6 @@ does not even build.
194190
/p:UseProdCLSIDs=false
195191
```
196192

197-
## `useAgentVcpkg`
198-
199-
Defaults to `true`, matching the Microsoft-hosted images, where `VCPKG_INSTALLATION_ROOT` points at
200-
a real vcpkg installation that this pipeline integrates and builds the native dependencies with.
201-
202-
Set it to `false` when the consuming repository supplies vcpkg some other way — for example through
203-
an MSBuild SDK that restores the ports itself. `VCPKG_INSTALLATION_ROOT` may well still be defined in
204-
that case, since the agent image sets it, but nothing builds there. Two steps then become
205-
meaningless and are dropped together:
206-
207-
- *Enable Vcpkg Install*, which integrates an installation the build does not use.
208-
- *Copy vcpkg logs*, which reads `$(VCPKG_INSTALLATION_ROOT)\buildtrees` — a directory that will not
209-
exist, failing the job after a successful build.
210-
211-
Dropping the log collection loses no real diagnostics: `Build Solution` writes an MSBuild binary log
212-
to `$(artifactsDir)\msbuild.binlog`, which is published with the rest of the build artifacts and
213-
records the vcpkg invocation and its output.
214-
215193
## `releaseTagJob`
216194

217195
`jobs-build.yml` stamps a build version obtained from a separate job. That job is named by the

‎templates/jobs-build.yml‎

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ parameters:
2424
- name: additionalMSBuildArgs
2525
type: string
2626
default: ''
27-
# Whether the agent's own vcpkg installation, at VCPKG_INSTALLATION_ROOT, is what builds the native
28-
# dependencies. Set to false when a consuming repository supplies vcpkg by other means, such as an
29-
# MSBuild SDK; the integrate step and the port log collection below are then both meaningless,
30-
# because that variable points at an installation this build never uses.
31-
- name: useAgentVcpkg
32-
type: boolean
33-
default: true
3427
# Agent pool for this job. Leave empty to inherit the pipeline's pool, which is what a pipeline
3528
# with a single suitable pool wants. See the "Agent requirements" section of README.md.
3629
- name: pool
@@ -126,13 +119,10 @@ jobs:
126119
feedsToUse: 'config'
127120
nugetConfigPath: '$(nugetConfig)'
128121

129-
- ${{ if parameters.useAgentVcpkg }}:
130-
- task: CmdLine@2
131-
displayName: Enable Vcpkg Install
132-
inputs:
133-
script: |
134-
$(VCPKG_INSTALLATION_ROOT)\vcpkg.exe integrate install
135-
workingDirectory: '$(VCPKG_INSTALLATION_ROOT)'
122+
- task: PowerShell@2
123+
displayName: Find and Integrate Vcpkg
124+
inputs:
125+
filePath: '${{ parameters.sourceRoot }}\templates\Find-AndIntegrate-Vcpkg.ps1'
136126

137127
- ${{ if ne(parameters.releaseTagJob, '') }}:
138128
- task: PowerShell@2
@@ -180,15 +170,6 @@ jobs:
180170
${{ parameters.additionalMSBuildArgs }}'
181171
maximumCpuCount: true
182172

183-
- ${{ if parameters.useAgentVcpkg }}:
184-
- task: CopyFiles@2
185-
displayName: Copy vcpkg logs
186-
inputs:
187-
SourceFolder: $(VCPKG_INSTALLATION_ROOT)\buildtrees
188-
Contents: '**\*.log'
189-
TargetFolder: '$(artifactsDir)\vcpkgLogs'
190-
condition: succeededOrFailed()
191-
192173
- task: CopyFiles@2
193174
displayName: 'Copy specific build artifacts'
194175
inputs:

0 commit comments

Comments
 (0)