Skip to content

Commit

Permalink
updated logic and added check for git longpath setting (Azure#88)
Browse files Browse the repository at this point in the history
Co-authored-by: Lyon Till <[email protected]>
  • Loading branch information
daltondhcp and ljtill authored Jul 15, 2020
1 parent c2698db commit 1377c0a
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions src/private/Test-AzOpsRuntime.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<#
.SYNOPSIS
The cmdlet verifies that required registry settings are enabled to support long paths in Windows execution environments
The cmdlet verifies that required registry and git settings are enabled to support long paths in Windows execution environments
.DESCRIPTION
The cmdlet verifies that required registry settings are enabled to support long paths in Windows execution environments
The cmdlet verifies that required registry and git settings are enabled to support long paths in Windows execution environments
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#enable-long-paths-in-windows-10-version-1607-and-later
https://aka.ms/es/quickstart
.EXAMPLE
C:\PS> Test-AzOpsRuntime
.INPUTS
Expand All @@ -15,13 +16,36 @@ function Test-AzOpsRuntime {
[CmdletBinding()]
param (
)
# Only check for registry value in Windows Execution Environments
if ($PSVersionTable.Platform -eq "Win32NT") {
$RegistryValue = Get-ItemPropertyValue -Path HKLM:SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled
if ($RegistryValue -ne 1) {
Write-AzOpsLog -Level Error -Topic "Test-AzOpsRuntime" -Message "Registry value (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled) is not set to 1 to support paths over 256 characters in Windows.
Change value as per https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#enable-long-paths-in-windows-10-version-1607-and-later, reboot and try again."
}

begin {
Write-AzOpsLog -Level Debug -Topic "Test-AzOpsRuntime" -Message ("Initiating function " + $MyInvocation.MyCommand + " begin")

}
process {
Write-AzOpsLog -Level Debug -Topic "Test-AzOpsRuntime" -Message ("Initiating function " + $MyInvocation.MyCommand + " process")
# Only validate in Windows Execution Environments
if ($PSVersionTable.Platform -eq "Win32NT") {
Write-AzOpsLog -Level Verbose -Topic "Test-AzOpsRuntime" -Message "Validating Windows environment for LongPath support"
$RuntimeErrors = @()
# Validate required registry entry
$RegistryValue = Get-ItemPropertyValue -Path HKLM:SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled
if ($RegistryValue -ne 1) {
$RuntimeErrors += 'RegistryValueMissing: Registry value (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled) is not set to 1 to support paths over 256 characters in Windows.'
}
# Validate git configuration
$LongPathGitSetting = Start-AzOpsNativeExecution { git config --system -l } | Select-String 'core.longpaths=true'
if ([string]::IsNullOrEmpty($LongPathGitSetting)) {
$RuntimeErrors += 'GitConfigMissing: git config --system core.longpaths is not set to true and is required to support over 256 characters in Git.'
}
# Return error messages with instructions if settings are missing
if ($RuntimeErrors) {
$RunTimeErrors += 'Follow instructions for "Enabling long paths on Windows" on https://aka.ms/es/quickstart.'
Write-AzOpsLog -Level Error -Topic "Test-AzOpsRuntime" -Message ($RuntimeErrors -join "`r")
}
}
}
end {
Write-AzOpsLog -Level Debug -Topic "Test-AzOpsRuntime" -Message ("Initiating function " + $MyInvocation.MyCommand + " end")
}

}

0 comments on commit 1377c0a

Please sign in to comment.