Skip to content

Commit

Permalink
Install SqlServer PS module for BC24 containers (#3405)
Browse files Browse the repository at this point in the history
And remove support for pre 1.0.2.15 generic images (these no longer
exists)
Fixes #3404
Fixes #3406

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk authored Mar 11, 2024
1 parent 621a7b2 commit 2c9fa04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 51 deletions.
59 changes: 10 additions & 49 deletions ContainerHandling/New-NavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ try {
$imageName = $bestImageName
if ($artifactUrl) {
$genericTagVersion = [Version](Get-BcContainerGenericTag -containerOrImageName $imageName)
if ($genericTagVersion -lt [Version]"1.0.2.13") {
if ($genericTagVersion -lt [Version]"1.0.2.15") {
Write-Host "Generic image is version $genericTagVersion - pulling a newer image"
$pullit = $true
}
Expand Down Expand Up @@ -1274,19 +1274,6 @@ try {
Write-Host "Generic Tag of better generic: $genericTagVersion"
}

if ($version.Major -lt 15 -and ($genericTag -eq [Version]"1.0.1.7")) {
Write-Host "Patching start.ps1 due to issue #2130"
$myscripts += @( "https://raw.githubusercontent.com/microsoft/nav-docker/master/generic/Run/start.ps1" )
}
if ($version.Major -ge 22 -and $genericTag -le [System.Version]"1.0.2.13" -and $auth -eq "AAD") {
Write-Host "Patching SetupConfiguration.ps1 due to issue #2874"
$myscripts += @( "https://raw.githubusercontent.com/microsoft/nav-docker/master/generic/Run/210-new/SetupConfiguration.ps1" )
}
if ($version.Major -ge 22 -and $genericTag -le [System.Version]"1.0.2.13") {
Write-Host "Patching prompt.ps1 due to issue #2891"
$myScripts += @( "https://raw.githubusercontent.com/microsoft/nav-docker/master/generic/Run/Prompt.ps1" )
}

if ($hostOsVersion -eq $containerOsVersion) {
if ($isolation -eq "") {
$isolation = "process"
Expand Down Expand Up @@ -1331,10 +1318,6 @@ try {
}
Write-Host "Using $isolation isolation"

if ($isolation -eq "process" -and !$isServerHost -and ($version.Major -lt 15 -or $genericTag -lt [Version]"1.0.2.4")) {
Write-Host -ForegroundColor Yellow "WARNING: Using process isolation on Windows Desktop OS with generic image version prior to 1.0.2.4 or NAV/BC versions prior to 15.0, might require you to use HyperV isolation or disable Windows Defender while creating the container"
}

if ($isolation -eq "process" -and !$isServerHost -and ($os.BuildNumber -eq 22621 -or $os.BuildNumber -eq 22631) -and $useSSL) {
Write-Host -ForegroundColor Red "WARNING: Using SSL when running Windows 11 with process isolation might not work due to a bug in Windows 11. Please use HyperV isolation or disable SSL."
}
Expand Down Expand Up @@ -1728,45 +1711,23 @@ Get-NavServerUser -serverInstance $ServerInstance -tenant default |? LicenseType
. (Join-Path $runPath $MyInvocation.MyCommand.Name)
') | Set-Content -Path "$myfolder\SetupVariables.ps1"
}
if (!(Test-Path -Path "$myfolder\HelperFunctions.ps1")) {
('# Invoke default behavior
. (Join-Path $runPath $MyInvocation.MyCommand.Name)
') | Set-Content -Path "$myfolder\HelperFunctions.ps1"
}

if (($version.Major -ge 22 -and $genericTag -le [System.Version]"1.0.2.13") -or ($filesOnly -and $version.Major -ge 22 -and $genericTag -le [System.Version]"1.0.2.14")) {
if (!(Test-Path -Path "$myfolder\HelperFunctions.ps1")) {
('# Invoke default behavior
. (Join-Path $runPath $MyInvocation.MyCommand.Name)
') | Set-Content -Path "$myfolder\HelperFunctions.ps1"
}
Write-Host "Patching container to install dotnet 6"
Download-File -source "https://download.visualstudio.microsoft.com/download/pr/04389c24-12a9-4e0e-8498-31989f30bb22/141aef28265938153eefad0f2398a73b/dotnet-hosting-6.0.27-win.exe" -destinationFile (Join-Path $myFolder "dotnet6-win.exe")
('
if (Test-Path "c:\run\my\dotnet6-win.exe") { Write-Host "Installing dotnet 6"; start-process -Wait -FilePath "c:\run\my\dotnet6-win.exe" -ArgumentList /quiet; Remove-Item "c:\run\my\dotnet6-win.exe" -Force }
') | Add-Content -Path "$myfolder\HelperFunctions.ps1"
if ($version.Major -ge 24 -and $genericTag -eq [System.Version]"1.0.2.15") {
Download-File -source "https://raw.githubusercontent.com/microsoft/nav-docker/98c0702dbd607580880a3c9248cd76591868447d/generic/Run/Prompt.ps1" -destinationFile (Join-Path $myFolder "Prompt.ps1")
}

if ($version.Major -ge 24 -and $genericTag -le [System.Version]"1.0.2.14") {
if (!(Test-Path -Path "$myfolder\HelperFunctions.ps1")) {
('# Invoke default behavior
. (Join-Path $runPath $MyInvocation.MyCommand.Name)
') | Set-Content -Path "$myfolder\HelperFunctions.ps1"
}
Write-Host "Patching container to install dotnet 8 and PowerShell 7.4.1"
Download-File -source "https://download.visualstudio.microsoft.com/download/pr/98ff0a08-a283-428f-8e54-19841d97154c/8c7d5f9600eadf264f04c82c813b7aab/dotnet-hosting-8.0.2-win.exe" -destinationFile (Join-Path $myFolder "dotnet8-win.exe")
Download-File -source "https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/PowerShell-7.4.1-win-x64.msi" -destinationFile (Join-Path $myFolder "powershell-7.4.1-win-x64.msi")
if ($version.Major -ge 24) {
('
if (Test-Path "c:\run\my\dotnet8-win.exe") { Write-Host "Installing dotnet 8"; start-process -Wait -FilePath "c:\run\my\dotnet8-win.exe" -ArgumentList /quiet; Remove-Item "c:\run\my\dotnet8-win.exe" -Force }
if (Test-Path "c:\run\my\powershell-7.4.1-win-x64.msi") { Write-Host "Installing PowerShell 7.4.1"; start-process -Wait -FilePath "c:\run\my\powershell-7.4.1-win-x64.msi" -ArgumentList /quiet; Remove-Item "c:\run\my\powershell-7.4.1-win-x64.msi" -Force }
if (!(Get-Command "invoke-sqlcmd" -ErrorAction SilentlyContinue)) { Install-package SqlServer -Force -RequiredVersion 21.1.18256 | Out-Null }
') | Add-Content -Path "$myfolder\HelperFunctions.ps1"
}

if ($version.Major -ge 24 -and $genericTag -eq [System.Version]"1.0.2.15") {
Download-File -source "https://raw.githubusercontent.com/microsoft/nav-docker/98c0702dbd607580880a3c9248cd76591868447d/generic/Run/Prompt.ps1" -destinationFile (Join-Path $myFolder "Prompt.ps1")
}

if ($version.Major -ge 15 -and $version.Major -le 18 -and $genericTag -ge [System.Version]"1.0.2.15") {
if (!(Test-Path -Path "$myfolder\HelperFunctions.ps1")) {
('# Invoke default behavior
. (Join-Path $runPath $MyInvocation.MyCommand.Name)
') | Set-Content -Path "$myfolder\HelperFunctions.ps1"
}
Write-Host "Patching container to install ASP.NET Core 1.1"
Download-File -source "https://download.microsoft.com/download/6/F/B/6FB4F9D2-699B-4A40-A674-B7FF41E0E4D2/DotNetCore.1.0.7_1.1.4-WindowsHosting.exe" -destinationFile (Join-Path $myFolder "dotnetcore.exe")
('
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ try {
# Give SYSTEM permission to use the PFX file's private key
$keyName = $importedPfxCertificate.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
$keyPath = "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\$keyName"
Import-Module Microsoft.PowerShell.Security -Force
$acl = [System.IO.FileSystemAclExtensions]::GetAccessControl([System.IO.DirectoryInfo]::new($keyPath), 'Access')
if ($PSVersionTable.PSVersion -ge "6.0.0") {
Import-Module Microsoft.PowerShell.Security -Force
$acl = [System.IO.FileSystemAclExtensions]::GetAccessControl([System.IO.DirectoryInfo]::new($keyPath), 'Access')
}
else {
$acl = (Get-Item $keyPath).GetAccessControl('Access')
}
$permission = 'NT AUTHORITY\SYSTEM',"Full","Allow"
$accessRule = new-object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.AddAccessRule($accessRule)
Expand Down
3 changes: 3 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
6.0.9
Issue 3404 New-BcContainerBcUser fails with 'Invoke-SqlCmd' error when running BC24
Remove support for pre 1.0.2.15 generic images
Issue 3406 Regression - Set-BcContainerKeyVaultAadAppAndCertificate only worked when running pwsh in container

6.0.8
Fix error where Publish-BcNuGetPackageToContainer doesn't work with BC 24
Expand Down

0 comments on commit 2c9fa04

Please sign in to comment.