Skip to content

Commit 0f30e3d

Browse files
committed
.azure-pipelines: enable Projected File System for unit tests
VFS for Git's runtime and several of its unit tests P/Invoke into ProjectedFSLib.dll (e.g. Microsoft.Windows.ProjFS.ProjFSNative .PrjDoesNameContainWildCards via ActiveEnumeration). That DLL is only present on disk when the 'Client-ProjFS' Windows optional feature is enabled. The 1ES win-x86_64-ado1es image used by the new release pipeline does not have that feature enabled, so RunUnitTests.bat fails with: System.DllNotFoundException : Unable to load DLL 'ProjectedFSLib.dll' or one of its dependencies. (0x8007007E) at Microsoft.Windows.ProjFS.ProjFSNative.PrjDoesNameContainWildCards(...) at GVFS.Platform.Windows.ActiveEnumeration.SaveFilter(...) at GVFS.UnitTests.Windows.Virtualization.ActiveEnumerationTests .CannotSetMoreThanOneFilter() Add a small PowerShell helper that enables the feature, and run it as a build prereq. The script is a no-op when the feature is already enabled, so it's safe to keep across image refreshes. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 8721e68 commit 0f30e3d

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

.azure-pipelines/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ extends:
116116
inputs:
117117
filePath: $(Build.SourcesDirectory)\.azure-pipelines\scripts\install-vs-cpp-workload.ps1
118118

119+
- task: PowerShell@2
120+
displayName: 'Enable Projected File System (ProjFS)'
121+
inputs:
122+
filePath: $(Build.SourcesDirectory)\.azure-pipelines\scripts\enable-projfs.ps1
123+
119124
- script: |
120125
$(Build.SourcesDirectory)\scripts\Build.bat ^
121126
$(BuildConfiguration) ^
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<#
2+
.SYNOPSIS
3+
Enable the Windows Projected File System (ProjFS) optional feature.
4+
5+
.DESCRIPTION
6+
VFS for Git -- both the runtime and several unit tests -- P/Invokes
7+
into ProjectedFSLib.dll (e.g. PrjDoesNameContainWildCards). That DLL
8+
is only present on disk when the 'Client-ProjFS' Windows optional
9+
feature is enabled. Hosted CI images do not enable it by default,
10+
so unit tests fail with:
11+
12+
System.DllNotFoundException : Unable to load DLL
13+
'ProjectedFSLib.dll' or one of its dependencies.
14+
15+
This script is a no-op when the feature is already enabled.
16+
#>
17+
18+
#Requires -Version 5
19+
#Requires -RunAsAdministrator
20+
21+
[CmdletBinding()]
22+
param()
23+
24+
$ErrorActionPreference = 'Stop'
25+
26+
$featureName = 'Client-ProjFS'
27+
28+
$feature = Get-WindowsOptionalFeature -Online -FeatureName $featureName -ErrorAction Stop
29+
if ($feature.State -eq 'Enabled') {
30+
Write-Host "INFO: Windows optional feature '$featureName' is already enabled."
31+
exit 0
32+
}
33+
34+
Write-Host "INFO: Enabling Windows optional feature '$featureName'..."
35+
$result = Enable-WindowsOptionalFeature -Online -FeatureName $featureName -NoRestart -ErrorAction Stop
36+
37+
if ($result.RestartNeeded) {
38+
# The pipeline runs unit tests immediately after this script which P/Invoke
39+
# into ProjectedFSLib.dll. If the OS reports a reboot is required to make
40+
# the feature usable, the build agent is in an inconsistent state and the
41+
# tests will fail unpredictably -- so fail fast here instead.
42+
throw "Windows optional feature '$featureName' was enabled but a restart is required to take effect; failing the build."
43+
} else {
44+
Write-Host "INFO: Windows optional feature '$featureName' is now enabled."
45+
}

0 commit comments

Comments
 (0)