Better path handling for Open-Solution and Build-Analyzers

This commit is contained in:
Brandon Thetford
2024-04-28 12:18:34 -07:00
parent bb5a538f1d
commit 6c9fef58c3
2 changed files with 16 additions and 19 deletions

View File

@@ -55,43 +55,34 @@ Function Build-Analyzers {
return
}
New-Variable -Name solutionRoot -Visibility Public -Value (Resolve-Path ..)
Push-Location $solutionRoot
New-Variable -Name solutionFile -Visibility Public -Value (Resolve-Path ./Terminal.sln)
$mainProjectRoot = Resolve-Path ./Terminal.Gui
$mainProjectFile = Join-Path $mainProjectRoot Terminal.Gui.csproj
$analyzersRoot = Resolve-Path ./Analyzers
$internalAnalyzersProjectRoot = Join-Path $analyzersRoot Terminal.Gui.Analyzers.Internal
$internalAnalyzersProjectFile = Join-Path $internalAnalyzersProjectRoot Terminal.Gui.Analyzers.Internal.csproj
Push-Location $InternalAnalyzersProjectDirectory
if(!$NoClean) {
if(!$Quiet) {
Write-Host Deleting bin and obj folders for Terminal.Gui
}
if(Test-Path $mainProjectRoot/bin) {
Remove-Item -Recurse -Force $mainProjectRoot/bin
Remove-Item -Recurse -Force $mainProjectRoot/obj
}
Remove-Item -Recurse -Force $TerminalGuiProjectDirectory/bin -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force $TerminalGuiProjectDirectory/obj -ErrorAction SilentlyContinue
if(!$Quiet) {
Write-Host Deleting bin and obj folders for Terminal.Gui.InternalAnalyzers
}
if(Test-Path $internalAnalyzersProjectRoot/bin) {
Remove-Item -Recurse -Force $internalAnalyzersProjectRoot/bin
Remove-Item -Recurse -Force $internalAnalyzersProjectRoot/obj
}
Remove-Item -Recurse -Force $InternalAnalyzersProjectDirectory/bin -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force $InternalAnalyzersProjectDirectory/obj -ErrorAction SilentlyContinue
}
if(!$Quiet) {
Write-Host Building analyzers in Debug configuration
}
dotnet build $internalAnalyzersProjectFile --no-incremental --nologo --force --configuration Debug
dotnet build $InternalAnalyzersProjectFilePath --no-incremental --nologo --force --configuration Debug
if(!$Quiet) {
Write-Host Building analyzers in Release configuration
}
dotnet build $internalAnalyzersProjectFile --no-incremental --nologo --force --configuration Release
dotnet build $InternalAnalyzersProjectFilePath --no-incremental --nologo --force --configuration Release
Pop-Location
if(!$AutoLaunch) {
Write-Host -ForegroundColor Green Finished. Restart Visual Studio for changes to take effect.
} else {
@@ -102,4 +93,4 @@ Function Build-Analyzers {
}
return
}
}

View File

@@ -69,6 +69,9 @@ Function Set-PowerShellEnvironment {
New-Variable -Name SolutionFilePath -Value (Join-Path -Resolve $RepositoryRootDirectory "Terminal.sln") -Option ReadOnly -Scope Global -Visibility Public
New-Variable -Name TerminalGuiProjectDirectory -Value (Join-Path -Resolve $RepositoryRootDirectory "Terminal.Gui") -Option ReadOnly -Scope Global -Visibility Public
New-Variable -Name TerminalGuiProjectFilePath -Value (Join-Path -Resolve $TerminalGuiProjectDirectory "Terminal.Gui.csproj") -Option ReadOnly -Scope Global -Visibility Public
New-Variable -Name AnalyzersDirectory -Value (Join-Path -Resolve $RepositoryRootDirectory "Analyzers") -Option ReadOnly -Scope Global -Visibility Public
New-Variable -Name InternalAnalyzersProjectDirectory -Value (Join-Path -Resolve $AnalyzersDirectory "Terminal.Gui.Analyzers.Internal") -Option ReadOnly -Scope Global -Visibility Public
New-Variable -Name InternalAnalyzersProjectFilePath -Value (Join-Path -Resolve $InternalAnalyzersProjectDirectory "Terminal.Gui.Analyzers.Internal.csproj") -Option ReadOnly -Scope Global -Visibility Public
# Set a custom prompt to indicate we're in our modified environment.
# Save the normal one first, though.
@@ -145,6 +148,9 @@ Function Reset-PowerShellEnvironment {
Remove-Variable -Name TerminalGuiProjectDirectory -Scope Global -Force -ErrorAction SilentlyContinue
Remove-Variable -Name TerminalGuiProjectFilePath -Scope Global -Force -ErrorAction SilentlyContinue
Remove-Variable -Name ScriptsDirectory -Scope Global -Force -ErrorAction SilentlyContinue
Remove-Variable -Name AnalyzersDirectory -Scope Global -Force -ErrorAction SilentlyContinue
Remove-Variable -Name InternalAnalyzersProjectDirectory -Scope Global -Force -ErrorAction SilentlyContinue
Remove-Variable -Name InternalAnalyzersProjectFilePath -Scope Global -Force -ErrorAction SilentlyContinue
}
# This ensures the environment is reset when unloading the module.