DevCheck: Settings options, configuration dependency paths, Sync'd dependencies (#4707)

New options

-Settings => Load the settings file (if exists) to enable future customization (default=$True)
-SettingsFile=file => Settings file to load (default = ...repo....user\DevCheck-Settings.ps1)
-SaveSettingsFile=file => Save a default settings file (fail if exists; won't overwrite existing files)
-UserSettings => Load the user settings file (if exists) to enable future customization (default=$True)
-UserSettingsFile=file => User Settings file to load (default = ...repo....user\DevCheck-Settings.ps1)
-SaveUserSettingsFile=file => Save a default user settings file (fail if exists; won't overwrite existing files)
Settings file is for a project to customize behavior. User Settings file is per user to mess with.

NOTE: A future update will change the default location for Settings file (pending a change to DevCheck.cmd @kythant is working on)

Change -CheckDependencies and -SyncDependencies to use a customization list of root directories. Use a settings file with custom values for $global:dependency_paths e.g.

$global:dependency_paths = ('fee', 'fie', 'foe\fum')

Also ran -SyncDependencies to correct a couple of stale entries (FrameworkUdk from May(!))
This commit is contained in:
Howard Kapustein 2024-09-12 11:12:37 -07:00 коммит произвёл GitHub
Родитель 59d485265e
Коммит aae37a0580
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 218 добавлений и 13 удалений

Просмотреть файл

@ -5,5 +5,5 @@
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240803.1" targetFramework="native" />
<package id="Microsoft.FrameworkUdk" version="1.7.0-CI-26107.1701.240510-1748.0" targetFramework="native" />
<package id="Microsoft.FrameworkUdk" version="1.7.0-CI-26107.1715.240815-1016.3" targetFramework="native" />
</packages>

Просмотреть файл

@ -53,7 +53,7 @@
Download and use the latest vswhere.exe on the network
.PARAMETER RemoveAll
Remove all.
Remove all
.PARAMETER RemoveTestCert
Remove the Test certificate (i.e. undoc CheckTestCert)
@ -61,6 +61,18 @@
.PARAMETER RemoveTestPfx
Remove the MSIX Test signing certificate (i.e. undoc CheckTestPfx)
.PARAMETER SaveSettingsFile
Save settings file
.PARAMETER SaveUserSettingsFile
Save settings file
.PARAMETER Settings
Load settings file
.PARAMETER SettingsFile
Settings file to load (if present). Relative filenames are resolved to .user directory. Default="DevCheck-Settings.ps1"
.PARAMETER ShowSystemInfo
Display system information
@ -73,6 +85,12 @@
.PARAMETER SyncDependencies
Update dependencies (*proj, packages.config, eng\Version.*.props) to match defined dependencies (eng\Version.*.xml)
.PARAMETER UserSettings
Load settings file
.PARAMETER UserSettingsFile
Settings file to load (if present). Relative filenames are resolved to .user directory.
.PARAMETER Verbose
Display detailed information
@ -117,6 +135,14 @@ Param(
[Switch]$RemoveTestPfx=$false,
[String]$SaveSettingsFile=$null,
[String]$SaveUserSettingsFile=$null,
[Switch]$Settings=$true,
[String]$SettingsFile='DevCheck-Settings.ps1',
[Switch]$ShowSystemInfo=$false,
[Switch]$StartTAEFService=$false,
@ -125,6 +151,10 @@ Param(
[Switch]$SyncDependencies=$false,
[Switch]$UserSettings=$true,
[String]$UserSettingsFile='DevCheck-UserSettings.ps1',
[Switch]$Verbose=$false
)
@ -139,17 +169,174 @@ $global:isadmin = $null
$global:vswhere = ''
$global:vswhere_url = ''
$remove_any = ($RemoveAll -eq $true) -or ($RemoveTestCert -eq $true) -or ($RemoveTestCert -eq $true)
if (($remove_any -eq $false) -And ($CheckTAEFService -eq $false) -And ($StartTAEFService -eq $false) -And
($StopTAEFService -eq $false) -And ($CheckTestCert -eq $false) -And ($CheckTestPfx -eq $false) -And
($CheckVisualStudio -eq $false) -And ($CheckDependencies -eq $false) -And ($SyncDependencies -eq $false) -And
($CheckDeveloperMode -eq $false) -And ($ShowSystemInfo -eq $false))
$global:dependency_paths = ('dev', 'test', 'installer', 'tools')
function Get-SettingsFile
{
$CheckAll = $true
if ([string]::IsNullOrEmpty($SettingsFile))
{
return $null
}
$file = [IO.Path]::GetFullPath($SettingsFile)
if (-not(Test-Path -Path $file -PathType Leaf))
{
$root = Get-ProjectRoot
$userdir = Join-Path $root '.user'
$file = Join-Path $userdir $SettingsFile
if (-not(Test-Path -Path $file -PathType Leaf))
{
return $null
}
}
return $file
}
if ($SyncDependencies -eq $true)
function Get-Settings
{
$CheckDependencies = $true
if ($Settings -eq $false)
{
return $null
}
$settings_file = Get-SettingsFile $true
if ([string]::IsNullOrEmpty($settings_file))
{
return $null
}
$file = [IO.Path]::GetFullPath($settings_file)
if (-not(Test-Path -Path $file -PathType Leaf))
{
$root = Get-ProjectRoot
$userdir = Join-Path $root '.user'
$file = Join-Path $userdir $settings_file
if (-not(Test-Path -Path $file -PathType Leaf))
{
return $null
}
}
Write-Host "Loading settings file $($file)..."
$null = . $file
Write-Host "Loaded settings file $($file)"
return $file
}
function Set-Settings
{
$file = $SaveSettingsFile
if ([string]::IsNullOrEmpty($file))
{
return $null
}
if (Test-Path -Path $file)
{
Write-Host "ERROR: -SaveSettings file exists; will not overwrite $($file)" -ForegroundColor Red -BackgroundColor Black
$ERROR_ALREADY_EXISTS = 183
Exit $ERROR_ALREADY_EXISTS
}
$content = @'
# Copyright (c) Microsoft Corporation and Contributors.
# Licensed under the MIT License.
# DevCheck Settings
# Do not alter contents except in the Customization block
# Everything else is owned by DevCheck and subject to change without warning
$me = (Get-Item $PSScriptRoot ).FullName
Write-Verbose "$me BEGIN Customization"
#-----------------------------------------------------------------------
# BEGIN Customization
#...insert customization here...
# END Customization
#-----------------------------------------------------------------------
$me = (Get-Item $PSScriptRoot ).FullName
Write-Verbose "$me END Customization"
'@
Write-Host "Saving settings file $($file)..."
Set-Content -Path $file -Value $content -Encoding utf8
return $file
}
function Get-UserSettingsFile
{
if ([string]::IsNullOrEmpty($UserSettingsFile))
{
return $null
}
$file = [IO.Path]::GetFullPath($UserSettingsFile)
if (-not(Test-Path -Path $file -PathType Leaf))
{
$root = Get-ProjectRoot
$userdir = Join-Path $root '.user'
$file = Join-Path $userdir $UserSettingsFile
if (-not(Test-Path -Path $file -PathType Leaf))
{
return $null
}
}
return $file
}
function Get-UserSettings
{
if ($UserSettings -eq $false)
{
return $null
}
$settings_file = Get-UserSettingsFile $true
if ([string]::IsNullOrEmpty($settings_file))
{
return $null
}
$file = [IO.Path]::GetFullPath($settings_file)
if (-not(Test-Path -Path $file -PathType Leaf))
{
$root = Get-ProjectRoot
$userdir = Join-Path $root '.user'
$file = Join-Path $userdir $settings_file
if (-not(Test-Path -Path $file -PathType Leaf))
{
return $null
}
}
Write-Host "Loading user settings file $($file)..."
$null = . $file
Write-Host "Loaded user settings file $($file)"
return $file
}
function Set-UserSettings
{
$file = $SaveUserSettingsFile
if ([string]::IsNullOrEmpty($file))
{
return $null
}
if (Test-Path -Path $file)
{
Write-Host "ERROR: -SaveUserSettings file exists; will not overwrite $($file)" -ForegroundColor Red -BackgroundColor Black
$ERROR_ALREADY_EXISTS = 183
Exit $ERROR_ALREADY_EXISTS
}
$content = @'
# DevCheck User Settings
#...insert user customization here...
'@
Write-Host "Saving user settings file $($file)..."
Set-Content -Path $file -Value $content -Encoding utf8
return $file
}
function Write-Verbose
@ -1296,7 +1483,7 @@ function Test-Dependencies
# Scan for references - packages.config
$root = Get-ProjectRoot
$files = 0
ForEach ($subtree in 'dev', 'test', 'installer', 'tools')
ForEach ($subtree in $global:dependency_paths)
{
$path = Join-Path $root $subtree
Write-Host "Scanning packages.config..."
@ -1309,7 +1496,7 @@ function Test-Dependencies
Write-Host "Scanned $($files) packages.config"
$files = 0
ForEach ($subtree in 'dev', 'test', 'installer', 'tools')
ForEach ($subtree in $global:dependency_paths)
{
$path = Join-Path $root $subtree
Write-Host "Scanning *.vcxproj..."
@ -1381,6 +1568,24 @@ function Get-SystemInfo
Write-Host "Powershell : $($PSVersionTable.PSEdition) $($PSVersionTable.PSVersion)"
}
$null = Set-Settings
$null = Set-UserSettings
$null = Get-Settings
$null = Get-UserSettings
$remove_any = ($RemoveAll -eq $true) -or ($RemoveTestCert -eq $true) -or ($RemoveTestCert -eq $true)
if (($remove_any -eq $false) -And ($CheckTAEFService -eq $false) -And ($StartTAEFService -eq $false) -And
($StopTAEFService -eq $false) -And ($CheckTestCert -eq $false) -And ($CheckTestPfx -eq $false) -And
($CheckVisualStudio -eq $false) -And ($CheckDependencies -eq $false) -And ($SyncDependencies -eq $false) -And
($CheckDeveloperMode -eq $false) -And ($ShowSystemInfo -eq $false))
{
$CheckAll = $true
}
if ($SyncDependencies -eq $true)
{
$CheckDependencies = $true
}
Write-Output "Checking developer environment..."
$cpu = Get-CpuArchitecture

Просмотреть файл

@ -6,5 +6,5 @@
<package id="Microsoft.Taef" version="10.94.240624002" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230706.1" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240803.1" targetFramework="native" />
<package id="Microsoft.FrameworkUdk" version="1.7.0-CI-26107.1701.240510-1748.0" targetFramework="native" />
<package id="Microsoft.FrameworkUdk" version="1.7.0-CI-26107.1715.240815-1016.3" targetFramework="native" />
</packages>