Skip to content

Commit

Permalink
Fixes #3302 (#3303)
Browse files Browse the repository at this point in the history
Issue warning and errors if settings in the settings file doesn't exist
or are of a wrong type
Change setting, which was of a wrong type

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk committed Jan 23, 2024
1 parent 3fd8089 commit 4521fb8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
28 changes: 22 additions & 6 deletions BC.HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function Get-ContainerHelperConfig {
"useVolumes" = $false
"useVolumeForMyFolder" = $false
"use7zipIfAvailable" = $true
"defaultNewContainerParameters" = @{ }
"defaultNewContainerParameters" = [PSCustomObject]@{
}
"hostHelperFolder" = ""
"containerHelperFolder" = $programDataFolder
"defaultContainerName" = "bcserver"
Expand Down Expand Up @@ -99,7 +100,7 @@ function Get-ContainerHelperConfig {
"RenewClientContextBetweenTests" = $false
"DebugMode" = $false
"DoNotUseCdnForArtifacts" = $false
"MinimumDotNetRuntimeVersion" = [System.Version]"6.0.16"
"MinimumDotNetRuntimeVersionStr" = "6.0.16"
"MinimumDotNetRuntimeVersionUrl" = 'https://download.visualstudio.microsoft.com/download/pr/ca13c6f1-3107-4cf8-991c-f70edc1c1139/a9f90579d827514af05c3463bed63c22/dotnet-sdk-6.0.408-win-x64.zip'
"AlpacaSettings" = [PSCustomObject]@{
"BaseUrl" = "https://cosmo-alpaca-enterprise.westeurope.cloudapp.azure.com"
Expand Down Expand Up @@ -128,15 +129,30 @@ function Get-ContainerHelperConfig {
try {
$savedConfig = Get-Content $configFile | ConvertFrom-Json
if ("$savedConfig") {
$keys = $bcContainerHelperConfig.Keys | % { $_ }
$keys = $bcContainerHelperConfig.Keys | ForEach-Object { $_ }
$keys | ForEach-Object {
if ($savedConfig.PSObject.Properties.Name -eq "$_") {
if (!$silent) {
Write-Host "Setting $_ = $($savedConfig."$_")"
if ($bcContainerHelperConfig."$_" -and $savedConfig."$_" -and $bcContainerHelperConfig."$_".GetType() -ne $savedConfig."$_".GetType()) {
Write-Host -ForegroundColor Red "Ignoring config setting $_ as the type in the config file is different than in the default configuration"
}
else {
if ((ConvertTo-Json -InputObject $bcContainerHelperConfig."$_" -Compress) -eq (ConvertTo-Json -InputObject $savedConfig."$_" -Compress)) {
if (!$silent) {
Write-Host "Ignoring unchanged config setting $_"
}
}
else {
if (!$silent) {
Write-Host "Setting $_ = $($savedConfig."$_")"
}
$bcContainerHelperConfig."$_" = $savedConfig."$_"
}
}
$bcContainerHelperConfig."$_" = $savedConfig."$_"
}
}
$savedConfig.PSObject.Properties.Name | Where-Object { $keys -notcontains $_ } | ForEach-Object {
Write-Host -ForegroundColor Yellow "Ignoring unknown config setting $_"
}
}
}
catch {
Expand Down
2 changes: 1 addition & 1 deletion CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ try {
$probingPaths = @((Join-Path $dllsPath "OpenXML")) + $probingPaths
}
elseif ($platformversion.Major -ge 22) {
if ($dotNetRuntimeVersionInstalled -ge $bcContainerHelperConfig.MinimumDotNetRuntimeVersion) {
if ($dotNetRuntimeVersionInstalled -ge [System.Version]$bcContainerHelperConfig.MinimumDotNetRuntimeVersionStr) {
$probingPaths = @((Join-Path $dllsPath "OpenXML"), "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\$dotNetRuntimeVersionInstalled", "C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\$dotNetRuntimeVersionInstalled") + $probingPaths
}
else {
Expand Down
4 changes: 2 additions & 2 deletions CompilerFolderHandling/New-BcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ try {
}

$dotNetSharedFolder = Join-Path $dllsPath 'shared'
if ($version -ge "22.0.0.0" -and (!(Test-Path $dotNetSharedFolder)) -and ($dotNetRuntimeVersionInstalled -lt $bcContainerHelperConfig.MinimumDotNetRuntimeVersion)) {
if ($version -ge "22.0.0.0" -and (!(Test-Path $dotNetSharedFolder)) -and ($dotNetRuntimeVersionInstalled -lt [System.Version]$bcContainerHelperConfig.MinimumDotNetRuntimeVersionStr)) {
if ("$dotNetRuntimeVersionInstalled" -eq "0.0.0") {
Write-Host "dotnet runtime version is not installed/cannot be used"
}
else {
Write-Host "dotnet runtime version $dotNetRuntimeVersionInstalled is installed, but minimum required version is $($bcContainerHelperConfig.MinimumDotNetRuntimeVersion)"
Write-Host "dotnet runtime version $dotNetRuntimeVersionInstalled is installed, but minimum required version is $($bcContainerHelperConfig.MinimumDotNetRuntimeVersionStr)"
}
Write-Host "Downloading minimum required dotnet version from $($bcContainerHelperConfig.MinimumDotNetRuntimeVersionUrl)"
$dotnetFolder = Join-Path $compilerFolder 'dotnet'
Expand Down

0 comments on commit 4521fb8

Please sign in to comment.