Support compilerfolder and online environments (#3607)

When specifying BcAuthContext and Environment to Run-AlPipeline,
Run-AlPipeline would always create a filesonly container, disallowing
running on Linux.
This PR fixes this plus some bugs found as a result of this.

- Replace all occurrences of
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto with
[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR as the Auto
function doesn't always do what's expected under Linux (We do not use
the Auto function in AL-Go)
- Ensure correct casing of Newtonsoft.Json.dll for Linux (also not a
problem in AL-Go)
- Always add extensionId (when specified) to Properties section in test
results xml
- Also added two new overrides (PipelineInitialize and PipelineFinalize)
requested by COSMO Consult.
- If environment is specified as a Web Client URL, and BcAuthContext
contains username/password in Run-AlPipeline, then tests will run
against this environment. PublishBcContainerApp and
ImportTestToolkitToBcContainer needs to be overridden for this to work
with full pipeline.
- Add parameter CompilerFolder to Run-TestsInBcContainer and
Import-TestToolkitToBcContainer for running tests using CompilerFolder
bits from the host
- Including caching of appinfos in CompilerFolder cache (to save time
when caching on GitHub Actions)

Running Build AND Test under Linux (using CompilerFolder), using an
online environment as "Service Tier" can be seen here:

https://github.com/BusinessCentralDemos/bingmaps.pte/actions/runs/10313615507

Build and test here takes approx. 3 minutes.

This functionality is needed by COSMO to enable using their Docker Swarm
for running tests in AL-Go.

COSMO is aware that AL-Go moves away from using BcContainerHelper and
will subsequently have to change their integration when this has
happened.

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
This commit is contained in:
Freddy Kristiansen 2024-08-09 12:18:10 +02:00 коммит произвёл GitHub
Родитель 6e5de383d7
Коммит 480254c917
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
30 изменённых файлов: 329 добавлений и 171 удалений

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

@ -427,7 +427,7 @@ try {
throw "You need to specify credentials when you are not using Windows Authentication" throw "You need to specify credentials when you are not using Windows Authentication"
} }
$pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password))) $pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)))
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes) $base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64" $basicAuthValue = "Basic $base64"

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

@ -76,7 +76,7 @@ try {
throw "You need to specify credentials when you are not using Windows Authentication" throw "You need to specify credentials when you are not using Windows Authentication"
} }
$pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password))) $pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)))
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes) $base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64" $basicAuthValue = "Basic $base64"

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

@ -182,9 +182,9 @@ try {
$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh $false -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $testCodeunitRange, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $culture, $timezone, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests) $result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh $false -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $testCodeunitRange, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $culture, $timezone, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests)
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) { if (!(Test-Path $newtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Newtonsoft.Json.dll"
} }
$newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName $newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll" $clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"

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

@ -44,7 +44,7 @@ function New-ClientContext {
if ($Credential -eq $null -or $credential -eq [System.Management.Automation.PSCredential]::Empty) { if ($Credential -eq $null -or $credential -eq [System.Management.Automation.PSCredential]::Empty) {
throw "You need to specify credentials (Username and AccessToken) if using AAD authentication" throw "You need to specify credentials (Username and AccessToken) if using AAD authentication"
} }
$accessToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)) $accessToken = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password))
$clientContext = [ClientContext]::new($serviceUrl, $accessToken, $interactionTimeout, $culture, $timezone) $clientContext = [ClientContext]::new($serviceUrl, $accessToken, $interactionTimeout, $culture, $timezone)
} }
else { else {
@ -726,6 +726,13 @@ function Run-Tests {
$JunitTestSuiteProperties = $JUnitDoc.CreateElement("properties") $JunitTestSuiteProperties = $JUnitDoc.CreateElement("properties")
$JUnitTestSuite.AppendChild($JunitTestSuiteProperties) | Out-Null $JUnitTestSuite.AppendChild($JunitTestSuiteProperties) | Out-Null
if ($extensionid) {
$property = $JUnitDoc.CreateElement("property")
$property.SetAttribute("name","extensionid")
$property.SetAttribute("value", $extensionId)
$JunitTestSuiteProperties.AppendChild($property) | Out-Null
}
if ($process) { if ($process) {
$property = $JUnitDoc.CreateElement("property") $property = $JUnitDoc.CreateElement("property")
$property.SetAttribute("name","processinfo.start") $property.SetAttribute("name","processinfo.start")
@ -733,11 +740,6 @@ function Run-Tests {
$JunitTestSuiteProperties.AppendChild($property) | Out-Null $JunitTestSuiteProperties.AppendChild($property) | Out-Null
if ($extensionid) { if ($extensionid) {
$property = $JUnitDoc.CreateElement("property")
$property.SetAttribute("name","extensionid")
$property.SetAttribute("value", $extensionId)
$JunitTestSuiteProperties.AppendChild($property) | Out-Null
$appname = "$(Get-NavAppInfo -ServerInstance $serverInstance | Where-Object { "$($_.AppId)" -eq $extensionId } | ForEach-Object { $_.Name })" $appname = "$(Get-NavAppInfo -ServerInstance $serverInstance | Where-Object { "$($_.AppId)" -eq $extensionId } | ForEach-Object { $_.Name })"
if ($appname) { if ($appname) {
$property = $JUnitDoc.CreateElement("property") $property = $JUnitDoc.CreateElement("property")

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

@ -233,7 +233,7 @@ try {
if (!($credential)) { if (!($credential)) {
throw "You need to specify credentials when you are not using Windows Authentication" throw "You need to specify credentials when you are not using Windows Authentication"
} }
$pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password))) $pair = ("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)))
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes) $base64 = [System.Convert]::ToBase64String($bytes)
$HttpClient.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Basic", $base64); $HttpClient.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Basic", $base64);

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

@ -183,6 +183,10 @@
Information about which product built the app. Will be stamped into the app manifest. Information about which product built the app. Will be stamped into the app manifest.
.Parameter BuildUrl .Parameter BuildUrl
The URL for the build job, which built the app. Will be stamped into the app manifest. The URL for the build job, which built the app. Will be stamped into the app manifest.
.Parameter PipelineInitialize
Override for Pipeline Initialize
.Parameter PipelineFinalize
Override for Pipeline Finalize
.Parameter DockerPull .Parameter DockerPull
Override function parameter for docker pull Override function parameter for docker pull
.Parameter NewBcContainer .Parameter NewBcContainer
@ -193,7 +197,7 @@
Override function parameter for Import-TestToolkitToBcContainer Override function parameter for Import-TestToolkitToBcContainer
.Parameter CompileAppInBcContainer .Parameter CompileAppInBcContainer
Override function parameter for Compile-AppInBcContainer Override function parameter for Compile-AppInBcContainer
.Parameter CompileAppWithBcCompilerFolder .Parameter CompileAppWithBcCompilerFolder
Override function parameter for Compile-AppWithBcCompilerFolder Override function parameter for Compile-AppWithBcCompilerFolder
.Parameter PreCompileApp .Parameter PreCompileApp
Custom script to run before compiling an app. Custom script to run before compiling an app.
@ -363,6 +367,7 @@ Param(
[string] $sourceCommit = '', [string] $sourceCommit = '',
[string] $buildBy = "BcContainerHelper,$BcContainerHelperVersion", [string] $buildBy = "BcContainerHelper,$BcContainerHelperVersion",
[string] $buildUrl = '', [string] $buildUrl = '',
[scriptblock] $PipelineInitialize,
[scriptblock] $DockerPull, [scriptblock] $DockerPull,
[scriptblock] $NewBcContainer, [scriptblock] $NewBcContainer,
[scriptblock] $SetBcContainerKeyVaultAadAppAndCertificate, [scriptblock] $SetBcContainerKeyVaultAadAppAndCertificate,
@ -383,7 +388,8 @@ Param(
[scriptblock] $RemoveBcContainer, [scriptblock] $RemoveBcContainer,
[scriptblock] $GetBestGenericImageName, [scriptblock] $GetBestGenericImageName,
[scriptblock] $GetBcContainerEventLog, [scriptblock] $GetBcContainerEventLog,
[scriptblock] $InstallMissingDependencies [scriptblock] $InstallMissingDependencies,
[scriptblock] $PipelineFinalize
) )
function CheckRelativePath([string] $baseFolder, [string] $sharedFolder, $path, $name) { function CheckRelativePath([string] $baseFolder, [string] $sharedFolder, $path, $name) {
@ -475,6 +481,10 @@ function GetInstalledAppIds {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try { try {
if ($PipelineInitialize) {
Invoke-Command -ScriptBlock $PipelineInitialize
}
$warningsToShow = @() $warningsToShow = @()
if (!$baseFolder -or !(Test-Path $baseFolder -PathType Container)) { if (!$baseFolder -or !(Test-Path $baseFolder -PathType Container)) {
@ -554,13 +564,19 @@ if ($bcAuthContext) {
Write-Host -ForegroundColor Yellow "Uninstalling removed apps from online environments are not supported" Write-Host -ForegroundColor Yellow "Uninstalling removed apps from online environments are not supported"
$uninstallRemovedApps = $false $uninstallRemovedApps = $false
} }
$bcAuthContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext if ($environment -notlike ('https://*')) {
$bcEnvironment = Get-BcEnvironments -bcAuthContext $bcAuthContext | Where-Object { $_.name -eq $environment -and $_.type -eq "Sandbox" } $bcAuthContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext
if (!($bcEnvironment)) { $bcEnvironment = Get-BcEnvironments -bcAuthContext $bcAuthContext | Where-Object { $_.name -eq $environment -and $_.type -eq "Sandbox" }
throw "Environment $environment doesn't exist in the current context or it is not a Sandbox environment." if (!($bcEnvironment)) {
throw "Environment $environment doesn't exist in the current context or it is not a Sandbox environment."
}
$parameters = @{
bcAuthContext = $bcAuthContext
environment = $environment
}
$bcBaseApp = Get-BcPublishedApps @Parameters | Where-Object { $_.Name -eq "Base Application" -and $_.state -eq "installed" }
$artifactUrl = Get-BCArtifactUrl -type Sandbox -country $bcEnvironment.countryCode -version $bcBaseApp.Version -select Closest
} }
$bcBaseApp = Get-BcPublishedApps -bcAuthContext $bcauthcontext -environment $environment | Where-Object { $_.Name -eq "Base Application" -and $_.state -eq "installed" }
$artifactUrl = Get-BCArtifactUrl -type Sandbox -country $bcEnvironment.countryCode -version $bcBaseApp.Version -select Closest
$filesOnly = $true $filesOnly = $true
} }
@ -748,14 +764,16 @@ Write-Host -ForegroundColor Yellow "Custom CodeCops"
if ($customCodeCops) { $customCodeCops | ForEach-Object { Write-Host "- $_" } } else { Write-Host "- None" } if ($customCodeCops) { $customCodeCops | ForEach-Object { Write-Host "- $_" } } else { Write-Host "- None" }
$vsixFile = DetermineVsixFile -vsixFile $vsixFile $vsixFile = DetermineVsixFile -vsixFile $vsixFile
$compilerFolder = '' $compilerFolder = ''
$createContainer = $true
if ($useCompilerFolder) { if ($useCompilerFolder) {
# We are using CompilerFolder, no need for a filesOnly Container # We are using CompilerFolder, no need for a filesOnly Container
# If we are to create a container, it is for publishing and testing # If we are to create a container, it is for publishing and testing
$filesOnly = $false $filesOnly = $false
$updateLaunchJson = '' $updateLaunchJson = ''
$createContainer = !($doNotPublishApps -or ($bcAuthContext -and $environment))
if (!$createContainer) { $containerName = ''}
} }
elseif ($doNotPublishApps) { elseif ($doNotPublishApps) {
# We are not using CompilerFolder, but we are not publishing apps either # We are not using CompilerFolder, but we are not publishing apps either
@ -908,7 +926,7 @@ $signApps = ($codeSignCertPfxFile -ne "")
Measure-Command { Measure-Command {
if ( $artifactUrl -and !$reUseContainer -and !$doNotPublishApps -and !$filesOnly) { if ( $artifactUrl -and !$reUseContainer -and $createContainer) {
if ($gitHubActions) { Write-Host "::group::Pulling generic image" } if ($gitHubActions) { Write-Host "::group::Pulling generic image" }
Measure-Command { Measure-Command {
Write-Host -ForegroundColor Yellow @' Write-Host -ForegroundColor Yellow @'
@ -948,19 +966,36 @@ try {
$testCountry = $_.Trim() $testCountry = $_.Trim()
$testToolkitInstalled = $false $testToolkitInstalled = $false
if ($gitHubActions) { Write-Host "::group::Creating container" } if ($useCompilerFolder) {
Write-Host -ForegroundColor Yellow @' if ($gitHubActions) { Write-Host "::group::Creating CompilerFolder" }
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _____ _ _ _____ _ _ ______ _ _
/ ____| | | (_) | | (_) / ____| | | (_) / ____| (_) | | ____| | | | |
| | _ __ ___ __ _| |_ _ _ __ __ _ ___ ___ _ __ | |_ __ _ _ _ __ ___ _ __ | | _ __ ___ __ _| |_ _ _ __ __ _ | | ___ _ __ ___ _ __ _| | ___ _ __| |__ ___ | | __| | ___ _ __
| | | '__/ _ \/ _` | __| | '_ \ / _` | / __/ _ \| '_ \| __/ _` | | '_ \ / _ \ '__| | | | '__/ _ \/ _` | __| | '_ \ / _` | | | / _ \| '_ ` _ \| '_ \| | |/ _ \ '__| __/ _ \| |/ _` |/ _ \ '__|
| |____| | | __/ (_| | |_| | | | | (_| | | (__ (_) | | | | |_ (_| | | | | | __/ | | |____| | | __/ (_| | |_| | | | | (_| | | |___| (_) | | | | | | |_) | | | __/ | | | | (_) | | (_| | __/ |
\_____|_| \___|\__,_|\__|_|_| |_|\__, | \___\___/|_| |_|\__\__,_|_|_| |_|\___|_| \_____|_| \___|\__,_|\__|_|_| |_|\__, | \_____\___/|_| |_| |_| .__/|_|_|\___|_| |_| \___/|_|\__,_|\___|_|
__/ | | |
|___/ |_|
'@
}
else {
if ($gitHubActions) { Write-Host "::group::Creating container" }
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ _ _
/ ____| | | (_) / ____| | | (_)
| | _ __ ___ __ _| |_ _ _ __ __ _ | | ___ _ __ | |_ __ _ _ _ __ ___ _ __
| | | '__/ _ \/ _` | __| | '_ \ / _` | | | / _ \| '_ \| __/ _` | | '_ \ / _ \ '__|
| |____| | | __/ (_| | |_| | | | | (_| | | |___| (_) | | | | || (_| | | | | | __/ |
\_____|_| \___|\__,_|\__|_|_| |_|\__, | \_____\___/|_| |_|\__\__,_|_|_| |_|\___|_|
__/ | __/ |
|___/ |___/
'@ '@
}
Measure-Command { Measure-Command {
@ -983,7 +1018,7 @@ Measure-Command {
-containerName $containerName -containerName $containerName
Write-Host "CompilerFolder $compilerFolder created" Write-Host "CompilerFolder $compilerFolder created"
} }
if ($filesOnly -or !$doNotPublishApps) { if ($createContainer -and ($filesOnly -or !$doNotPublishApps)) {
# If we are going to build using a filesOnly container or we are going to publish apps, we need a container # If we are going to build using a filesOnly container or we are going to publish apps, we need a container
if (Test-BcContainer -containerName $containerName) { if (Test-BcContainer -containerName $containerName) {
if ($bcAuthContext) { if ($bcAuthContext) {
@ -1035,7 +1070,7 @@ Measure-Command {
} }
Invoke-Command -ScriptBlock $NewBcContainer -ArgumentList $Parameters Invoke-Command -ScriptBlock $NewBcContainer -ArgumentList $Parameters
if (-not $bcAuthContext) { if ($createContainer -and -not $bcAuthContext) {
if ($keyVaultCertPfxFile -and $KeyVaultClientId -and $keyVaultCertPfxPassword) { if ($keyVaultCertPfxFile -and $KeyVaultClientId -and $keyVaultCertPfxPassword) {
$Parameters = @{ $Parameters = @{
"containerName" = $containerName "containerName" = $containerName
@ -1329,6 +1364,7 @@ Measure-Command {
Write-Host -ForegroundColor Yellow "Importing Test Toolkit for additional country $testCountry" Write-Host -ForegroundColor Yellow "Importing Test Toolkit for additional country $testCountry"
$Parameters = @{ $Parameters = @{
"containerName" = $containerName "containerName" = $containerName
"compilerFolder" = $compilerFolder
"includeTestLibrariesOnly" = $installTestLibraries "includeTestLibrariesOnly" = $installTestLibraries
"includeTestFrameworkOnly" = !$installTestLibraries -and ($installTestFramework -or $installPerformanceToolkit) "includeTestFrameworkOnly" = !$installTestLibraries -and ($installTestFramework -or $installPerformanceToolkit)
"includeTestRunnerOnly" = !$installTestLibraries -and !$installTestFramework -and ($installTestRunner -or $installPerformanceToolkit) "includeTestRunnerOnly" = !$installTestLibraries -and !$installTestFramework -and ($installTestRunner -or $installPerformanceToolkit)
@ -1508,6 +1544,7 @@ Measure-Command {
$measureText = ", test apps and importing test toolkit" $measureText = ", test apps and importing test toolkit"
$Parameters = @{ $Parameters = @{
"containerName" = $containerName "containerName" = $containerName
"compilerFolder" = $compilerFolder
"includeTestLibrariesOnly" = $installTestLibraries "includeTestLibrariesOnly" = $installTestLibraries
"includeTestFrameworkOnly" = !$installTestLibraries -and ($installTestFramework -or $installPerformanceToolkit) "includeTestFrameworkOnly" = !$installTestLibraries -and ($installTestFramework -or $installPerformanceToolkit)
"includeTestRunnerOnly" = !$installTestLibraries -and !$installTestFramework -and ($installTestRunner -or $installPerformanceToolkit) "includeTestRunnerOnly" = !$installTestLibraries -and !$installTestFramework -and ($installTestRunner -or $installPerformanceToolkit)
@ -1654,7 +1691,7 @@ Write-Host -ForegroundColor Yellow @'
$Parameters = @{ } $Parameters = @{ }
$CopParameters = @{ } $CopParameters = @{ }
if ($bcAuthContext) { if ($bcAuthContext -and !$useCompilerFolder) {
$Parameters += @{ $Parameters += @{
"bcAuthContext" = $bcAuthContext "bcAuthContext" = $bcAuthContext
"environment" = $environment "environment" = $environment
@ -2433,6 +2470,7 @@ $testAppIds.Keys | ForEach-Object {
} }
$Parameters = @{ $Parameters = @{
"containerName" = $containerName "containerName" = $containerName
"compilerFolder" = $compilerFolder
"tenant" = $tenant "tenant" = $tenant
"credential" = $credential "credential" = $credential
"companyName" = $companyName "companyName" = $companyName
@ -2461,6 +2499,7 @@ $testAppIds.Keys | ForEach-Object {
$Parameters += @{ $Parameters += @{
"bcAuthContext" = $bcAuthContext "bcAuthContext" = $bcAuthContext
"environment" = $environment "environment" = $environment
"ConnectFromHost" = !$createContainer
} }
} }
@ -2615,7 +2654,11 @@ finally {
$progressPreference = $prevProgressPreference $progressPreference = $prevProgressPreference
} }
if (!$keepContainer) { if ($useCompilerFolder -and $compilerFolder) {
Remove-BcCompilerFolder -compilerFolder $compilerFolder
}
if ($createContainer -and !$keepContainer) {
if ($gitHubActions) { Write-Host "::group::Removing container" } if ($gitHubActions) { Write-Host "::group::Removing container" }
if (!($err)) { if (!($err)) {
Write-Host -ForegroundColor Yellow @' Write-Host -ForegroundColor Yellow @'
@ -2631,9 +2674,6 @@ Write-Host -ForegroundColor Yellow @'
} }
Measure-Command { Measure-Command {
if ($useCompilerFolder -and $compilerFolder) {
Remove-BcCompilerFolder -compilerFolder $compilerFolder
}
if (!$doNotPublishApps) { if (!$doNotPublishApps) {
if (!$filesOnly -and $containerEventLogFile) { if (!$filesOnly -and $containerEventLogFile) {
try { try {
@ -2667,6 +2707,10 @@ if ($err) {
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nAL Pipeline finished in $([int]$_.TotalSeconds) seconds" } } | ForEach-Object { Write-Host -ForegroundColor Yellow "`nAL Pipeline finished in $([int]$_.TotalSeconds) seconds" }
if ($PipelineFinalize) {
Invoke-Command -ScriptBlock $PipelineFinalize
}
} }
catch { catch {
TrackException -telemetryScope $telemetryScope -errorRecord $_ TrackException -telemetryScope $telemetryScope -errorRecord $_

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

@ -135,15 +135,15 @@ try {
} }
if ($connectFromHost) { if ($connectFromHost) {
$newtonSoftDllPath = Join-Path $PsTestToolFolder "NewtonSoft.json.dll" $newtonSoftDllPath = Join-Path $PsTestToolFolder "Newtonsoft.Json.dll"
$clientDllPath = Join-Path $PsTestToolFolder "Microsoft.Dynamics.Framework.UI.Client.dll" $clientDllPath = Join-Path $PsTestToolFolder "Microsoft.Dynamics.Framework.UI.Client.dll"
Invoke-ScriptInBcContainer -containerName $containerName { Param([string] $myNewtonSoftDllPath, [string] $myClientDllPath) Invoke-ScriptInBcContainer -containerName $containerName { Param([string] $myNewtonSoftDllPath, [string] $myClientDllPath)
if (!(Test-Path $myNewtonSoftDllPath)) { if (!(Test-Path $myNewtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) { if (!(Test-Path $newtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Newtonsoft.Json.dll"
} }
$newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName $newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName
Copy-Item -Path $newtonSoftDllPath -Destination $myNewtonSoftDllPath Copy-Item -Path $newtonSoftDllPath -Destination $myNewtonSoftDllPath
@ -202,9 +202,9 @@ try {
$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh $false -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [timespan] $interactionTimeout, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl) $result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh $false -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [timespan] $interactionTimeout, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl)
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) { if (!(Test-Path $newtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Newtonsoft.Json.dll"
} }
$newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName $newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll" $clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"

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

@ -87,6 +87,7 @@
function Run-TestsInBcContainer { function Run-TestsInBcContainer {
Param ( Param (
[string] $containerName = $bcContainerHelperConfig.defaultContainerName, [string] $containerName = $bcContainerHelperConfig.defaultContainerName,
[string] $compilerFolder = '',
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string] $tenant = "default", [string] $tenant = "default",
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
@ -141,23 +142,60 @@ function Run-TestsInBcContainer {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try { try {
$customConfig = Get-BcContainerServerConfiguration -ContainerName $containerName if ($containerName) {
$navversion = Get-BcContainerNavversion -containerOrImageName $containerName Write-Host "Using Container"
$version = [System.Version]($navversion.split('-')[0]) $customConfig = Get-BcContainerServerConfiguration -ContainerName $containerName
$navversion = Get-BcContainerNavversion -containerOrImageName $containerName
$version = [System.Version]($navversion.split('-')[0])
$PsTestToolFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\PsTestTool"
}
elseif ($compilerFolder) {
Write-Host "Using CompilerFolder"
$customConfig = $null
$symbolsFolder = Join-Path $compilerFolder "symbols"
$baseAppInfo = Get-AppJsonFromAppFile -appFile (Get-ChildItem -Path $symbolsFolder -Filter 'Microsoft_Base Application_*.*.*.*.app').FullName
$version = [Version]$baseAppInfo.version
$PsTestToolFolder = Join-Path ([System.IO.Path]::GetTempPath()) "$([Guid]::NewGuid().ToString())"
New-Item $PsTestToolFolder -ItemType Directory | Out-Null
$testDlls = Join-Path $compilerFolder "dlls/Test Assemblies/*.dll"
Copy-Item $testDlls -Destination $PsTestToolFolder -Force
Copy-Item -Path (Join-Path $PSScriptRoot "PsTestFunctions.ps1") -Destination $PsTestToolFolder -Force
Copy-Item -Path (Join-Path $PSScriptRoot "ClientContext.ps1") -Destination $PsTestToolFolder -Force
}
else {
throw "You must specify either containerName or compilerFolder"
}
if ($bcAuthContext -and $environment) { if ($bcAuthContext -and $environment) {
$response = Invoke-RestMethod -Method Get -Uri "$($bcContainerHelperConfig.baseUrl.TrimEnd('/'))/$($bcAuthContext.tenantID)/$environment/deployment/url" if ($environment -like 'https://*') {
if($response.status -ne 'Ready') { $useUrl = $environment
throw "environment not ready, status is $($response.status)" if ($bcAuthContext.ContainsKey('Username') -and $bcAuthContext.ContainsKey('Password')) {
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList $bcAuthContext.Username, $bcAuthContext.Password
$clientServicesCredentialType = "NavUserPassword"
}
if ($bcAuthContext.ContainsKey('ClientServicesCredentialType')) {
$clientServicesCredentialType = $bcAuthContext.ClientServicesCredentialType
}
$testPage = 130455
} }
$useUrl = $response.data.Split('?')[0] else {
$tenant = ($response.data.Split('?')[1]).Split('=')[1] $response = Invoke-RestMethod -Method Get -Uri "$($bcContainerHelperConfig.baseUrl.TrimEnd('/'))/$($bcAuthContext.tenantID)/$environment/deployment/url"
if($response.status -ne 'Ready') {
if ($testPage) { throw "environment not ready, status is $($response.status)"
throw "You cannot specify testPage when running tests in an Online tenant" }
$useUrl = $response.data
if ($testPage) {
throw "You cannot specify testPage when running tests in an Online tenant"
}
$testPage = 130455
} }
$testPage = 130455 $uri = [Uri]::new($useUrl)
$useUrl = $useUrl.Split('?')[0]
$dict = [System.Web.HttpUtility]::ParseQueryString($uri.Query)
if ($dict['tenant']) { $tenant = $dict['tenant'] }
if ($dict['testpage']) { $testpage = [int]$dict['testpage'] }
} }
else { else {
$clientServicesCredentialType = $customConfig.ClientServicesCredentialType $clientServicesCredentialType = $customConfig.ClientServicesCredentialType
@ -220,13 +258,12 @@ try {
} -argumentList $interactionTimeout.ToString() } -argumentList $interactionTimeout.ToString()
} }
if ($bcAuthContext) { if ($bcAuthContext -and ($environment -notlike 'https://*')) {
$bcAuthContext = Renew-BcAuthContext $bcAuthContext $bcAuthContext = Renew-BcAuthContext $bcAuthContext
$accessToken = $bcAuthContext.accessToken $accessToken = $bcAuthContext.accessToken
$credential = New-Object pscredential -ArgumentList $bcAuthContext.upn, (ConvertTo-SecureString -String $accessToken -AsPlainText -Force) $credential = New-Object pscredential -ArgumentList $bcAuthContext.upn, (ConvertTo-SecureString -String $accessToken -AsPlainText -Force)
} }
$PsTestToolFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\PsTestTool"
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1" $PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1" $ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"
$fobfile = Join-Path $PsTestToolFolder "PSTestToolPage.fob" $fobfile = Join-Path $PsTestToolFolder "PSTestToolPage.fob"
@ -273,24 +310,30 @@ try {
try try
{ {
if ($connectFromHost) { if ($connectFromHost) {
$newtonSoftDllPath = Join-Path $PsTestToolFolder "NewtonSoft.json.dll" if ($PSVersionTable.PSVersion.Major -lt 7) {
throw "Using ConnectFromHost requires PowerShell 7"
}
$newtonSoftDllPath = Join-Path $PsTestToolFolder "Newtonsoft.Json.dll"
$clientDllPath = Join-Path $PsTestToolFolder "Microsoft.Dynamics.Framework.UI.Client.dll" $clientDllPath = Join-Path $PsTestToolFolder "Microsoft.Dynamics.Framework.UI.Client.dll"
if ($containerName) {
Invoke-ScriptInBcContainer -containerName $containerName { Param([string] $myNewtonSoftDllPath, [string] $myClientDllPath) if (!((Test-Path $newtonSoftDllPath) -and (Test-Path $clientDllPath))) {
Invoke-ScriptInBcContainer -containerName $containerName { Param([string] $myNewtonSoftDllPath, [string] $myClientDllPath)
if (!(Test-Path $myNewtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\NewtonSoft.json.dll" if (!(Test-Path $myNewtonSoftDllPath)) {
if (!(Test-Path $newtonSoftDllPath)) { $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll" if (!(Test-Path $newtonSoftDllPath)) {
} $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Newtonsoft.Json.dll"
$newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName }
Copy-Item -Path $newtonSoftDllPath -Destination $myNewtonSoftDllPath $newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName
Copy-Item -Path $newtonSoftDllPath -Destination $myNewtonSoftDllPath
}
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"
if (!(Test-Path $myClientDllPath)) {
Copy-Item -Path $clientDllPath -Destination $myClientDllPath
}
} -argumentList $newtonSoftDllPath, $clientDllPath
} }
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll" }
if (!(Test-Path $myClientDllPath)) {
Copy-Item -Path $clientDllPath -Destination $myClientDllPath
}
} -argumentList $newtonSoftDllPath, $clientDllPath
if ($useUrl) { if ($useUrl) {
$publicWebBaseUrl = $useUrl.TrimEnd('/') $publicWebBaseUrl = $useUrl.TrimEnd('/')
@ -384,11 +427,11 @@ try {
} }
} }
$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh $false -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testCodeunitRange, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [string] $JUnitResultFileName, [bool] $AppendToJUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [string] $GitHubActions, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $testRunnerCodeunitId, $disabledtests, $renewClientContextBetweenTests) $result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh $false -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [System.Management.Automation.PSCredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testCodeunitRange, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [string] $JUnitResultFileName, [bool] $AppendToJUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [string] $GitHubActions, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $testRunnerCodeunitId, $disabledtests, $renewClientContextBetweenTests)
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) { if (!(Test-Path $newtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Newtonsoft.Json.dll"
} }
$newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName $newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll" $clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"

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

@ -151,7 +151,7 @@ try {
} }
Write-Host "Signing $appFile" Write-Host "Signing $appFile"
$unsecurepassword = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pfxPassword))) $unsecurepassword = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pfxPassword)))
$attempt = 1 $attempt = 1
$maxAttempts = 5 $maxAttempts = 5
do { do {

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

@ -244,14 +244,14 @@ try {
Download-File -sourceUrl "https://go.microsoft.com/fwlink/?LinkID=844461" -destinationFile (Join-Path $dotnetCoreFolder "DotNetCore.1.0.4_1.1.1-WindowsHosting.exe") -timeout $timeout Download-File -sourceUrl "https://go.microsoft.com/fwlink/?LinkID=844461" -destinationFile (Join-Path $dotnetCoreFolder "DotNetCore.1.0.4_1.1.1-WindowsHosting.exe") -timeout $timeout
} }
} }
# Patch potential wrong version of NewtonSoft.json.DLL # Patch potential wrong version of Newtonsoft.Json.dll
$newtonSoftDllPath = Join-Path $platformArtifactPath 'ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Newtonsoft.json.dll' $newtonSoftDllPath = Join-Path $platformArtifactPath 'ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Newtonsoft.Json.dll'
if (Test-Path $newtonSoftDllPath) { if (Test-Path $newtonSoftDllPath) {
'Applications\testframework\TestRunner\Internal\Newtonsoft.json.dll','Test Assemblies\Newtonsoft.json.dll' | ForEach-Object { 'Applications\testframework\TestRunner\Internal\Newtonsoft.Json.dll','Test Assemblies\Newtonsoft.Json.dll' | ForEach-Object {
$dstFile = Join-Path $platformArtifactPath $_ $dstFile = Join-Path $platformArtifactPath $_
$file = Get-item -Path $dstFile -ErrorAction SilentlyContinue $file = Get-item -Path $dstFile -ErrorAction SilentlyContinue
if ($file -and $file.Length -eq 686000) { if ($file -and $file.Length -eq 686000) {
Write-Host "INFO: Patching wrong version of NewtonSoft.json.DLL in $dstFile" Write-Host "INFO: Patching wrong version of Newtonsoft.Json.dll in $dstFile"
Copy-Item -Path $newtonSoftDllPath -Destination $dstFile -Force Copy-Item -Path $newtonSoftDllPath -Destination $dstFile -Force
} }
} }

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

@ -82,7 +82,7 @@ try {
} }
else { else {
if ($AadAdminCredential) { if ($AadAdminCredential) {
$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($AadAdminCredential.Password)) $password = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($AadAdminCredential.Password))
if ($password.Length -gt 100) { if ($password.Length -gt 100) {
$account = Connect-AzureAD -AadAccessToken $password -AccountId $AadAdminCredential.UserName $account = Connect-AzureAD -AadAccessToken $password -AccountId $AadAdminCredential.UserName
} }

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

@ -62,7 +62,7 @@ try {
} }
else { else {
if ($AadAdminCredential) { if ($AadAdminCredential) {
$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($AadAdminCredential.Password)) $password = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($AadAdminCredential.Password))
if ($password.Length -gt 100) { if ($password.Length -gt 100) {
$account = Connect-AzureAD -AadAccessToken $password -AccountId $AadAdminCredential.UserName $account = Connect-AzureAD -AadAccessToken $password -AccountId $AadAdminCredential.UserName
} }

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

@ -193,7 +193,7 @@ try {
$params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer } $params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
Write-Host "Remove Network Service User from $DatabaseName" Write-Host "Remove Network Service User from $DatabaseName"
@ -219,7 +219,7 @@ try {
$params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer } $params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
Write-Host "Remove Windows Users from $DatabaseName" Write-Host "Remove Windows Users from $DatabaseName"
@ -249,7 +249,7 @@ try {
$params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer } $params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
Write-Host "Remove Application Roles from $DatabaseName" Write-Host "Remove Application Roles from $DatabaseName"
@ -280,7 +280,7 @@ try {
Write-Host "Checking Entitlements" Write-Host "Checking Entitlements"
$params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer } $params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
'Membership Entitlement', 'Entitlement Set', 'Entitlement' | % { 'Membership Entitlement', 'Entitlement Set', 'Entitlement' | % {
@ -303,7 +303,7 @@ try {
$params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer } $params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
Write-Host "Remove data from System Tables database $DatabaseName" Write-Host "Remove data from System Tables database $DatabaseName"
@ -336,7 +336,7 @@ try {
$params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer } $params = @{ 'ErrorAction' = 'Ignore'; 'ServerInstance' = $databaseServer }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
if (!($KeepUserData)) { if (!($KeepUserData)) {
@ -416,7 +416,7 @@ try {
if ($sqlCredential) { if ($sqlCredential) {
$arguments += @( $arguments += @(
('/SourceUser:"'+$sqlCredential.UserName+'"'), ('/SourceUser:"'+$sqlCredential.UserName+'"'),
('/SourcePassword:"'+([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password)))+'"') ('/SourcePassword:"'+([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password)))+'"')
) )
} }
@ -447,7 +447,7 @@ try {
if ($sqlCredential) { if ($sqlCredential) {
$arguments += @( $arguments += @(
('/SourceUser:"'+$sqlCredential.UserName+'"'), ('/SourceUser:"'+$sqlCredential.UserName+'"'),
('/SourcePassword:"'+([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password)))+'"') ('/SourcePassword:"'+([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password)))+'"')
) )
} }

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

@ -14,12 +14,12 @@ function Get-PlainText() {
[parameter(ValueFromPipeline, Mandatory = $true)] [parameter(ValueFromPipeline, Mandatory = $true)]
[System.Security.SecureString] $SecureString [System.Security.SecureString] $SecureString
) )
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString); $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
try { try {
return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr); return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
} }
finally { finally {
[Runtime.InteropServices.Marshal]::FreeBSTR($bstr); [Runtime.InteropServices.Marshal]::FreeBSTR($bstr)
} }
} }
Export-ModuleMember -Function Get-PlainText Export-ModuleMember -Function Get-PlainText

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

@ -128,7 +128,12 @@ try {
Remove-Item -Path (Join-Path $dllsPath 'Service\SideServices') -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path (Join-Path $dllsPath 'Service\SideServices') -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path (Join-Path $dllsPath 'OpenXML') -ItemType Directory | Out-Null New-Item -Path (Join-Path $dllsPath 'OpenXML') -ItemType Directory | Out-Null
Copy-Item -Path (Join-Path $dllsPath 'Service\DocumentFormat.OpenXml.dll') -Destination (Join-Path $dllsPath 'OpenXML') -Force -ErrorAction SilentlyContinue Copy-Item -Path (Join-Path $dllsPath 'Service\DocumentFormat.OpenXml.dll') -Destination (Join-Path $dllsPath 'OpenXML') -Force -ErrorAction SilentlyContinue
$mockAssembliesFolder = Join-Path $platformArtifactPath "Test Assemblies\Mock Assemblies" -Resolve $testAssembliesFolder = Join-Path $platformArtifactPath "Test Assemblies" -Resolve
$testAssembliesDestination = Join-Path $dllsPath "Test Assemblies"
New-Item -Path $testAssembliesDestination -ItemType Directory | Out-Null
Copy-Item -Path (Join-Path $testAssembliesFolder 'Newtonsoft.Json.dll') -Destination $testAssembliesDestination -Force
Copy-Item -Path (Join-Path $testAssembliesFolder 'Microsoft.Dynamics.Framework.UI.Client.dll') -Destination $testAssembliesDestination -Force
$mockAssembliesFolder = Join-Path $testAssembliesFolder "Mock Assemblies" -Resolve
Copy-Item -Path $mockAssembliesFolder -Filter '*.dll' -Destination $dllsPath -Recurse Copy-Item -Path $mockAssembliesFolder -Filter '*.dll' -Destination $dllsPath -Recurse
$extensionsFolder = Join-Path $appArtifactPath 'Extensions' $extensionsFolder = Join-Path $appArtifactPath 'Extensions'
if (Test-Path $extensionsFolder -PathType Container) { if (Test-Path $extensionsFolder -PathType Container) {
@ -225,7 +230,6 @@ try {
$alcExePath = Join-Path $containerCompilerPath 'extension/bin/linux/alc' $alcExePath = Join-Path $containerCompilerPath 'extension/bin/linux/alc'
if (Test-Path $alcExePath) { if (Test-Path $alcExePath) {
# Set execute permissions on alc # Set execute permissions on alc
Write-Host "Setting execute permissions on alc"
& /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath" & /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath"
} }
else { else {
@ -253,11 +257,13 @@ try {
} }
} }
$symbolsPath = Join-Path $compilerFolder 'symbols' Write-Host "Enumerating Apps in $symbolsPath"
Write-Host "Enumerating Apps in CompilerFolder $symbolsPath"
$compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app') | Select-Object -ExpandProperty FullName) $compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app') | Select-Object -ExpandProperty FullName)
GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'cache_AppInfo.json') | Out-Null GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'cache_AppInfo.json') | Out-Null
if ($cacheFolder) {
Write-Host "Copying symbols cache"
Copy-Item -Path (Join-Path $symbolsPath 'cache_AppInfo.json') -Destination (Join-Path $compilerFolder 'symbols') -Force
}
$compilerFolder $compilerFolder
} }
catch { catch {

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

@ -1595,7 +1595,7 @@ if (!$restartingInstance) {
winrm create winrm/config/Listener?Address=*+Transport=HTTPS (''@{Hostname="dontcare"; CertificateThumbprint="'' + $cert.Thumbprint + ''"}'') winrm create winrm/config/Listener?Address=*+Transport=HTTPS (''@{Hostname="dontcare"; CertificateThumbprint="'' + $cert.Thumbprint + ''"}'')
winrm set winrm/config/service/Auth ''@{Basic="true"}'' winrm set winrm/config/service/Auth ''@{Basic="true"}''
Write-Host "Creating Container user $username" Write-Host "Creating Container user $username"
New-LocalUser -AccountNeverExpires -PasswordNeverExpires -FullName $username -Name '+$bcContainerHelperConfig.WinRmCredentials.UserName+' -Password (ConvertTo-SecureString -string "'+([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($bcContainerHelperConfig.WinRmCredentials.Password)))+'" -AsPlainText -force) | Out-Null New-LocalUser -AccountNeverExpires -PasswordNeverExpires -FullName $username -Name '+$bcContainerHelperConfig.WinRmCredentials.UserName+' -Password (ConvertTo-SecureString -string "'+([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($bcContainerHelperConfig.WinRmCredentials.Password)))+'" -AsPlainText -force) | Out-Null
Add-LocalGroupMember -Group administrators -Member '+$bcContainerHelperConfig.WinRmCredentials.UserName+' Add-LocalGroupMember -Group administrators -Member '+$bcContainerHelperConfig.WinRmCredentials.UserName+'
} }
') | Add-Content -Path "$myfolder\AdditionalSetup.ps1" ') | Add-Content -Path "$myfolder\AdditionalSetup.ps1"
@ -2018,7 +2018,7 @@ if (-not `$restartingInstance) {
) )
if ("$databaseServer" -ne "" -and $bcContainerHelperConfig.useSharedEncryptionKeys -and !$encryptionKeyExists) { if ("$databaseServer" -ne "" -and $bcContainerHelperConfig.useSharedEncryptionKeys -and !$encryptionKeyExists) {
$sharedEncryptionKeyFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "EncryptionKeys\$(-join [security.cryptography.sha256managed]::new().ComputeHash([Text.Encoding]::Utf8.GetBytes(([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))))).ForEach{$_.ToString("X2")})\DynamicsNAV-v$($version.Major).key" $sharedEncryptionKeyFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "EncryptionKeys\$(-join [security.cryptography.sha256managed]::new().ComputeHash([Text.Encoding]::Utf8.GetBytes(([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))))).ForEach{$_.ToString("X2")})\DynamicsNAV-v$($version.Major).key"
if (Test-Path $sharedEncryptionKeyFile) { if (Test-Path $sharedEncryptionKeyFile) {
Write-Host "Using Shared Encryption Key file" Write-Host "Using Shared Encryption Key file"
Copy-Item -Path $sharedEncryptionKeyFile -Destination $containerEncryptionKeyFile Copy-Item -Path $sharedEncryptionKeyFile -Destination $containerEncryptionKeyFile

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

@ -36,7 +36,7 @@ function Get-BcContainerImageLabels {
} elseif ($registryCredential) { } elseif ($registryCredential) {
$credentials = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($registryCredential.UserName + ":" + [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($registryCredential.Password)))) $credentials = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($registryCredential.UserName + ":" + [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($registryCredential.Password))))
$authorization = "Basic $credentials" $authorization = "Basic $credentials"
} elseif ("$registry" -eq "bcinsider.azurecr.io" -or "$registry" -eq "bcprivate.azurecr.io") { } elseif ("$registry" -eq "bcinsider.azurecr.io" -or "$registry" -eq "bcprivate.azurecr.io") {

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

@ -33,7 +33,7 @@ function Get-BcContainerImageTags {
} elseif ($registryCredential) { } elseif ($registryCredential) {
$credentials = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($registryCredential.UserName + ":" + [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($registryCredential.Password)))) $credentials = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($registryCredential.UserName + ":" + [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($registryCredential.Password))))
$authorization = "Basic $credentials" $authorization = "Basic $credentials"
if ($pageSize -eq -1) { if ($pageSize -eq -1) {
$pageSize = 1000 $pageSize = 1000

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

@ -355,59 +355,97 @@ function Expand-7zipArchive {
function GetTestToolkitApps { function GetTestToolkitApps {
Param( Param(
[string] $containerName, [string] $containerName,
[string] $compilerFolder,
[switch] $includeTestLibrariesOnly, [switch] $includeTestLibrariesOnly,
[switch] $includeTestFrameworkOnly, [switch] $includeTestFrameworkOnly,
[switch] $includeTestRunnerOnly, [switch] $includeTestRunnerOnly,
[switch] $includePerformanceToolkit [switch] $includePerformanceToolkit
) )
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($includeTestLibrariesOnly, $includeTestFrameworkOnly, $includeTestRunnerOnly, $includePerformanceToolkit) if ($compilerFolder) {
$symbolsFolder = Join-Path $compilerFolder "symbols"
$version = [Version](Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\Microsoft.Dynamics.Nav.Server.exe").VersionInfo.FileVersion
# Add Test Framework # Add Test Framework
$apps = @() $apps = @()
if (($version -ge [Version]"19.0.0.0") -and (Test-Path 'C:\Applications\TestFramework\TestLibraries\permissions mock')) { $baseAppInfo = Get-AppJsonFromAppFile -appFile (Get-ChildItem -Path $symbolsFolder -Filter 'Microsoft_Base Application_*.*.*.*.app').FullName
$apps += @(get-childitem -Path "C:\Applications\TestFramework\TestLibraries\permissions mock\*.*" -recurse -filter "*.app") $version = [Version]$baseAppInfo.version
if ($version -ge [Version]"19.0.0.0") {
$apps += @('Microsoft_Permissions Mock')
} }
$apps += @(get-childitem -Path "C:\Applications\TestFramework\TestRunner\*.*" -recurse -filter "*.app") $apps += @('Microsoft_Test Runner')
if (!$includeTestRunnerOnly) { if (!$includeTestRunnerOnly) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\TestLibraries\*.*" -recurse -filter "*.app") $apps += @('Microsoft_Any', 'Microsoft_Library Assert', 'Microsoft_Library Variable Storage')
if (!$includeTestFrameworkOnly) { if (!$includeTestFrameworkOnly) {
# Add Test Libraries # Add Test Libraries
$apps += "Microsoft_System Application Test Library.app", "Microsoft_Business Foundation Test Libraries.app", "Microsoft_Tests-TestLibraries.app" | ForEach-Object { $apps += @('Microsoft_System Application Test Library', 'Microsoft_Business Foundation Test Libraries', 'Microsoft_Tests-TestLibraries')
@(get-childitem -Path "C:\Applications\*.*" -recurse -filter $_)
}
if (!$includeTestLibrariesOnly) { if (!$includeTestLibrariesOnly) {
# Add Tests # Add Tests
if ($version -ge [Version]"18.0.0.0") { if ($version -ge [Version]"18.0.0.0") {
$apps += "Microsoft_System Application Test.app", "Microsoft_Business Foundation Tests.app" | ForEach-Object { $apps += @('Microsoft_System Application Test', 'Microsoft_Business Foundation Tests', 'Microsoft_Tests-*')
@(get-childitem -Path "C:\Applications\*.*" -recurse -filter $_)
}
} }
$apps += @(get-childitem -Path "C:\Applications\*.*" -recurse -filter "Microsoft_Tests-*.app") | Where-Object { $_ -notlike "*\Microsoft_Tests-TestLibraries.app" -and ($version.Major -ge 17 -or ($_ -notlike "*\Microsoft_Tests-Marketing.app")) -and $_ -notlike "*\Microsoft_Tests-SINGLESERVER.app" }
} }
} }
} }
if ($includePerformanceToolkit) { if ($includePerformanceToolkit) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\PerformanceToolkit\*.*" -recurse -filter "*Toolkit.app") $apps += @('Microsoft_Performance Toolkit')
if (!$includeTestFrameworkOnly) { if (!$includeTestFrameworkOnly) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\PerformanceToolkit\*.*" -recurse -filter "*.app" -exclude "*Toolkit.app") $apps += @('Microsoft_Performance Toolkit *')
} }
} }
$appFiles = @()
$apps | ForEach-Object { $apps | ForEach-Object {
$appFile = Get-ChildItem -path "c:\applications.*\*.*" -recurse -filter ($_.Name).Replace(".app", "_*.app") $appFiles += @(get-childitem -Path $symbolsFolder -Filter "$($_)_*.*.*.*.app" | Where-Object {($version.Major -ge 17 -or ($_.Name -notlike 'Microsoft_Tests-Marketing_*.*.*.*.app')) -and $_.Name -notlike "Microsoft_Tests-SINGLESERVER_*.*.*.*.app"} | ForEach-Object { $_.FullName })
if (!($appFile)) {
$appFile = $_
}
$appFile.FullName
} }
} -argumentList $includeTestLibrariesOnly, $includeTestFrameworkOnly, $includeTestRunnerOnly, $includePerformanceToolkit $appFiles | Select-Object -Unique
}
else {
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($includeTestLibrariesOnly, $includeTestFrameworkOnly, $includeTestRunnerOnly, $includePerformanceToolkit)
$version = [Version](Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\Microsoft.Dynamics.Nav.Server.exe").VersionInfo.FileVersion
# Add Test Framework
$apps = @()
if (($version -ge [Version]"19.0.0.0") -and (Test-Path 'C:\Applications\TestFramework\TestLibraries\permissions mock')) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\TestLibraries\permissions mock\*.*" -recurse -filter "*.app")
}
$apps += @(get-childitem -Path "C:\Applications\TestFramework\TestRunner\*.*" -recurse -filter "*.app")
if (!$includeTestRunnerOnly) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\TestLibraries\*.*" -recurse -filter "*.app")
if (!$includeTestFrameworkOnly) {
# Add Test Libraries
$apps += "Microsoft_System Application Test Library.app", "Microsoft_Business Foundation Test Libraries.app", "Microsoft_Tests-TestLibraries.app" | ForEach-Object {
@(get-childitem -Path "C:\Applications\*.*" -recurse -filter $_)
}
if (!$includeTestLibrariesOnly) {
# Add Tests
if ($version -ge [Version]"18.0.0.0") {
$apps += "Microsoft_System Application Test.app", "Microsoft_Business Foundation Tests.app" | ForEach-Object {
@(get-childitem -Path "C:\Applications\*.*" -recurse -filter $_)
}
}
$apps += @(get-childitem -Path "C:\Applications\*.*" -recurse -filter "Microsoft_Tests-*.app") | Where-Object { $_ -notlike "*\Microsoft_Tests-TestLibraries.app" -and ($version.Major -ge 17 -or ($_ -notlike "*\Microsoft_Tests-Marketing.app")) -and $_ -notlike "*\Microsoft_Tests-SINGLESERVER.app" }
}
}
}
if ($includePerformanceToolkit) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\PerformanceToolkit\*.*" -recurse -filter "*Toolkit.app")
if (!$includeTestFrameworkOnly) {
$apps += @(get-childitem -Path "C:\Applications\TestFramework\PerformanceToolkit\*.*" -recurse -filter "*.app" -exclude "*Toolkit.app")
}
}
$apps | ForEach-Object {
$appFile = Get-ChildItem -path "c:\applications.*\*.*" -recurse -filter ($_.Name).Replace(".app", "_*.app")
if (!($appFile)) {
$appFile = $_
}
$appFile.FullName
}
} -argumentList $includeTestLibrariesOnly, $includeTestFrameworkOnly, $includeTestRunnerOnly, $includePerformanceToolkit
}
} }
function GetExtendedErrorMessage { function GetExtendedErrorMessage {
@ -853,7 +891,7 @@ Function CreatePsTestToolFolder {
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1" $PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1" $ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"
$newtonSoftDllPath = Join-Path $PsTestToolFolder "NewtonSoft.json.dll" $newtonSoftDllPath = Join-Path $PsTestToolFolder "Newtonsoft.Json.dll"
$clientDllPath = Join-Path $PsTestToolFolder "Microsoft.Dynamics.Framework.UI.Client.dll" $clientDllPath = Join-Path $PsTestToolFolder "Microsoft.Dynamics.Framework.UI.Client.dll"
if (!(Test-Path -Path $PsTestToolFolder -PathType Container)) { if (!(Test-Path -Path $PsTestToolFolder -PathType Container)) {
@ -864,9 +902,9 @@ Function CreatePsTestToolFolder {
Invoke-ScriptInBcContainer -containerName $containerName { Param([string] $myNewtonSoftDllPath, [string] $myClientDllPath) Invoke-ScriptInBcContainer -containerName $containerName { Param([string] $myNewtonSoftDllPath, [string] $myClientDllPath)
if (!(Test-Path $myNewtonSoftDllPath)) { if (!(Test-Path $myNewtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) { if (!(Test-Path $newtonSoftDllPath)) {
$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll" $newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Newtonsoft.Json.dll"
} }
$newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName $newtonSoftDllPath = (Get-Item $newtonSoftDllPath).FullName
Copy-Item -Path $newtonSoftDllPath -Destination $myNewtonSoftDllPath Copy-Item -Path $newtonSoftDllPath -Destination $myNewtonSoftDllPath
@ -1001,6 +1039,7 @@ function GetAppInfo {
[string] $cacheAppInfoPath = '' [string] $cacheAppInfoPath = ''
) )
Push-Location
$appInfoCache = $null $appInfoCache = $null
$cacheUpdated = $false $cacheUpdated = $false
if ($cacheAppInfoPath) { if ($cacheAppInfoPath) {
@ -1010,13 +1049,13 @@ function GetAppInfo {
else { else {
$appInfoCache = @{} $appInfoCache = @{}
} }
Set-Location (Split-Path $cacheAppInfoPath -parent)
} }
Write-Host "::group::Getting .app info $cacheAppInfoPath" Write-Host "::group::Getting .app info $cacheAppInfoPath"
$binPath = Join-Path $compilerFolder 'compiler/extension/bin' $binPath = Join-Path $compilerFolder 'compiler/extension/bin'
if ($isLinux) { if ($isLinux) {
$alcPath = Join-Path $binPath 'linux' $alcPath = Join-Path $binPath 'linux'
$alToolExe = Join-Path $alcPath 'altool' $alToolExe = Join-Path $alcPath 'altool'
Write-Host "Setting execute permissions on altool"
& /usr/bin/env sudo pwsh -command "& chmod +x $alToolExe" & /usr/bin/env sudo pwsh -command "& chmod +x $alToolExe"
} }
else { else {
@ -1039,8 +1078,9 @@ function GetAppInfo {
try { try {
foreach($path in $appFiles) { foreach($path in $appFiles) {
Write-Host -NoNewline "- $([System.IO.Path]::GetFileName($path))" Write-Host -NoNewline "- $([System.IO.Path]::GetFileName($path))"
if ($appInfoCache -and $appInfoCache.PSObject.Properties.Name -eq $path) { $relativePath = Resolve-Path -Path $path -Relative
$appInfo = $appInfoCache."$path" if ($appInfoCache -and $appInfoCache.PSObject.Properties.Name -eq $relativePath) {
$appInfo = $appInfoCache."$relativePath"
Write-Host " (cached)" Write-Host " (cached)"
} }
else { else {
@ -1087,7 +1127,7 @@ function GetAppInfo {
Write-Host " (succeeded using codeanalysis)" Write-Host " (succeeded using codeanalysis)"
} }
if ($cacheAppInfoPath) { if ($cacheAppInfoPath) {
$appInfoCache | Add-Member -MemberType NoteProperty -Name $path -Value $appInfo $appInfoCache | Add-Member -MemberType NoteProperty -Name $relativePath -Value $appInfo
$cacheUpdated = $true $cacheUpdated = $true
} }
} }
@ -1124,6 +1164,7 @@ function GetAppInfo {
if ($packageStream) { if ($packageStream) {
$packageStream.Dispose() $packageStream.Dispose()
} }
Pop-Location
} }
Write-Host "::endgroup::" Write-Host "::endgroup::"
} }
@ -1234,7 +1275,6 @@ function RunAlTool {
$path = DownloadLatestAlLanguageExtension -allowPrerelease:$usePrereleaseAlTool $path = DownloadLatestAlLanguageExtension -allowPrerelease:$usePrereleaseAlTool
if ($isLinux) { if ($isLinux) {
$alToolExe = Join-Path $path 'extension/bin/linux/altool' $alToolExe = Join-Path $path 'extension/bin/linux/altool'
Write-Host "Setting execute permissions on altool"
& /usr/bin/env sudo pwsh -command "& chmod +x $alToolExe" & /usr/bin/env sudo pwsh -command "& chmod +x $alToolExe"
} }
else { else {

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

@ -861,7 +861,7 @@ In this example, it gets the .mdf and .ldf files from the latest cumulative upda
$databaseCredential = New-Object System.Management.Automation.PSCredential -argumentList "sa", (ConvertTo-SecureString -String "P@ssword1" -AsPlainText -Force) $databaseCredential = New-Object System.Management.Automation.PSCredential -argumentList "sa", (ConvertTo-SecureString -String "P@ssword1" -AsPlainText -Force)
$databaseName = "CRONUS" $databaseName = "CRONUS"
$attach_dbs = (ConvertTo-Json -Compress -Depth 99 @(@{"dbName" = "$databaseName"; "dbFiles" = @("c:\temp\${databaseName}.mdf", "c:\temp\${databaseName}.ldf") })).replace('"',"'") $attach_dbs = (ConvertTo-Json -Compress -Depth 99 @(@{"dbName" = "$databaseName"; "dbFiles" = @("c:\temp\${databaseName}.mdf", "c:\temp\${databaseName}.ldf") })).replace('"',"'")
$dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password)) $dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))
$dbserverid = docker run -d -e sa_password="$dbPassword" -e ACCEPT_EULA=Y -v "${hostFolder}:C:/temp" -e attach_dbs="$attach_dbs" microsoft/mssql-server-windows-developer $dbserverid = docker run -d -e sa_password="$dbPassword" -e ACCEPT_EULA=Y -v "${hostFolder}:C:/temp" -e attach_dbs="$attach_dbs" microsoft/mssql-server-windows-developer
$databaseServer = $dbserverid.SubString(0,12) $databaseServer = $dbserverid.SubString(0,12)
$databaseInstance = "" $databaseInstance = ""
@ -877,7 +877,7 @@ The following script sample, will create a new SQL Server container and restore
$hostFolder = "c:\temp\navdbfiles" $hostFolder = "c:\temp\navdbfiles"
$databaseCredential = New-Object System.Management.Automation.PSCredential -argumentList "sa", (ConvertTo-SecureString -String "P@ssword1" -AsPlainText -Force) $databaseCredential = New-Object System.Management.Automation.PSCredential -argumentList "sa", (ConvertTo-SecureString -String "P@ssword1" -AsPlainText -Force)
$dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password)) $dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))
$dbserverid = docker run -d -e sa_password="$dbPassword" -e ACCEPT_EULA=Y -v "${hostFolder}:C:/temp" microsoft/mssql-server-windows-express $dbserverid = docker run -d -e sa_password="$dbPassword" -e ACCEPT_EULA=Y -v "${hostFolder}:C:/temp" microsoft/mssql-server-windows-express
$databaseServer = $dbserverid.SubString(0,12) $databaseServer = $dbserverid.SubString(0,12)
$databaseInstance = "" $databaseInstance = ""
@ -903,7 +903,7 @@ Then you will have the variables $databaseServer, $databaseInstance, $databaseNa
If you have created your external database through other means, please set these variables in PowerShell. Please try the following script to see whether a docker container can connect to your database: If you have created your external database through other means, please set these variables in PowerShell. Please try the following script to see whether a docker container can connect to your database:
$dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password)) $dbPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))
$databaseServerInstance = @{ $true = "$databaseServer\$databaseInstance"; $false = "$databaseServer"}["$databaseInstance" -ne ""] $databaseServerInstance = @{ $true = "$databaseServer\$databaseInstance"; $false = "$databaseServer"}["$databaseInstance" -ne ""]
docker run -it --name sqlconnectiontest microsoft/mssql-server-windows-developer powershell -command "Invoke-Sqlcmd -ServerInstance '$databaseServerInstance' -Username '$($databaseCredential.Username)' -Password '$dbPassword' -Database '$databaseName' -Query 'SELECT COUNT(*) FROM [dbo].[User]'" docker run -it --name sqlconnectiontest microsoft/mssql-server-windows-developer powershell -command "Invoke-Sqlcmd -ServerInstance '$databaseServerInstance' -Username '$($databaseCredential.Username)' -Password '$dbPassword' -Database '$databaseName' -Query 'SELECT COUNT(*) FROM [dbo].[User]'"

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

@ -59,7 +59,7 @@ try {
$params = @{} $params = @{}
if ($sqlCredential) { if ($sqlCredential) {
$params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
Compile-NAVApplicationObject @params -Filter $filter ` Compile-NAVApplicationObject @params -Filter $filter `
-DatabaseName $databaseName ` -DatabaseName $databaseName `

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

@ -107,7 +107,7 @@ try {
$params = @{ 'ExportTxtSkipUnlicensed' = $true } $params = @{ 'ExportTxtSkipUnlicensed' = $true }
if ($sqlCredential) { if ($sqlCredential) {
$params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params += @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
if ($exportTo.Contains('(new syntax)')) { if ($exportTo.Contains('(new syntax)')) {
$params += @{ 'ExportToNewSyntax' = $true } $params += @{ 'ExportToNewSyntax' = $true }

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

@ -57,7 +57,7 @@ try {
$params = @{} $params = @{}
if ($sqlCredential) { if ($sqlCredential) {
$params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
if ($suppressBuildSearchIndex) { if ($suppressBuildSearchIndex) {
$params += @{ "suppressBuildSearchIndex" = $suppressBuildSearchIndex } $params += @{ "suppressBuildSearchIndex" = $suppressBuildSearchIndex }

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

@ -49,6 +49,7 @@
function Import-TestToolkitToBcContainer { function Import-TestToolkitToBcContainer {
Param ( Param (
[string] $containerName = $bcContainerHelperConfig.defaultContainerName, [string] $containerName = $bcContainerHelperConfig.defaultContainerName,
[string] $compilerFolder = '',
[PSCredential] $sqlCredential = $null, [PSCredential] $sqlCredential = $null,
[PSCredential] $credential = $null, [PSCredential] $credential = $null,
[switch] $includeTestLibrariesOnly, [switch] $includeTestLibrariesOnly,
@ -89,34 +90,49 @@ try {
} }
} }
$inspect = docker inspect $containerName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") {
throw "Container $containerName is not a Business Central container"
}
[System.Version]$version = $inspect.Config.Labels.version
$country = $inspect.Config.Labels.country
$isBcSandbox = $inspect.Config.Env | Where-Object { $_ -eq "IsBcSandbox=Y" }
$customConfig = Get-BcContainerServerConfiguration -ContainerName $containerName
if ($bcAuthContext -and $environment) { if ($bcAuthContext -and $environment) {
$appFiles = GetTestToolkitApps -containerName $containerName -compilerFolder $compilerFolder -includeTestRunnerOnly:$includeTestRunnerOnly -includeTestFrameworkOnly:$includeTestFrameworkOnly -includeTestLibrariesOnly:$includeTestLibrariesOnly -includePerformanceToolkit:$includePerformanceToolkit
$appFiles = GetTestToolkitApps -containerName $containerName -includeTestRunnerOnly:$includeTestRunnerOnly -includeTestFrameworkOnly:$includeTestFrameworkOnly -includeTestLibrariesOnly:$includeTestLibrariesOnly -includePerformanceToolkit:$includePerformanceToolkit $installedApps = Get-BcPublishedApps -bcAuthContext $bcauthcontext -environment $environment | Where-Object { $_.state -eq "installed" }
$appFiles | ForEach-Object { $appFiles | ForEach-Object {
$appInfo = Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($appFile) if ($compilerFolder) {
Get-NAVAppInfo -Path $appFile $appInfo = Get-AppJsonFromAppFile -appFile $_
} -argumentList $_ | Where-Object { $_ -isnot [System.String] } $appVersion = [Version]$appInfo.Version
$appId = $appInfo.Id
}
else {
$appInfo = Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($appFile)
Get-NAVAppInfo -Path $appFile
} -argumentList $_ | Where-Object { $_ -isnot [System.String] }
$appVersion = $appInfo.Version
$appId = $appInfo.AppId
}
$targetVersion = "" $targetVersion = ""
if ($appInfo.Version.Major -eq 18 -and $appInfo.Version.Minor -eq 0) { if ($appVersion.Major -eq 18 -and $appVersion.Minor -eq 0) {
$targetVersion = "18.0.23013.23913" $targetVersion = "18.0.23013.23913"
} }
Install-BcAppFromAppSource -bcAuthContext $bcauthcontext -environment $environment -appId $appInfo.AppId -appVersion $targetVersion -acceptIsvEula -installOrUpdateNeededDependencies $installedApp = $installedApps | Where-Object { $_.id -eq $appId -and (($targetVersion -eq "") -or ([Version]($_.version) -ge [Version]$targetVersion)) }
if ($installedApp) {
Write-Host "Skipping app '$($installedApp.name)' as it is already installed"
}
else {
Install-BcAppFromAppSource -bcAuthContext $bcauthcontext -environment $environment -appId $appId -appVersion $targetVersion -acceptIsvEula -installOrUpdateNeededDependencies
}
} }
Write-Host -ForegroundColor Green "TestToolkit successfully published" Write-Host -ForegroundColor Green "TestToolkit successfully published"
} }
else { else {
$inspect = docker inspect $containerName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -eq 0 -or $inspect.Config.Labels.maintainer -ne "Dynamics SMB") {
throw "Container $containerName is not a Business Central container"
}
[System.Version]$version = $inspect.Config.Labels.version
$country = $inspect.Config.Labels.country
$isBcSandbox = $inspect.Config.Env | Where-Object { $_ -eq "IsBcSandbox=Y" }
$customConfig = Get-BcContainerServerConfiguration -ContainerName $containerName
$doNotUpdateSymbols = $doNotUpdateSymbols -or (!(([bool]($customConfig.PSobject.Properties.name -eq "EnableSymbolLoadingAtServerStartup")) -and $customConfig.EnableSymbolLoadingAtServerStartup -eq "True")) $doNotUpdateSymbols = $doNotUpdateSymbols -or (!(([bool]($customConfig.PSobject.Properties.name -eq "EnableSymbolLoadingAtServerStartup")) -and $customConfig.EnableSymbolLoadingAtServerStartup -eq "True"))
$generateSymbols = $false $generateSymbols = $false
@ -124,8 +140,7 @@ try {
$generateSymbols = $true $generateSymbols = $true
$doNotUpdateSymbols = $true $doNotUpdateSymbols = $true
} }
if ($version.Major -ge 15) { if ($version.Major -ge 15) {
if ($version -lt [Version]("15.0.35528.0")) { if ($version -lt [Version]("15.0.35528.0")) {
throw "Container $containerName (platform version $version) doesn't support the Test Toolkit yet, you need a laster version" throw "Container $containerName (platform version $version) doesn't support the Test Toolkit yet, you need a laster version"
@ -246,7 +261,7 @@ try {
$params = @{} $params = @{}
if ($sqlCredential) { if ($sqlCredential) {
$params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) } $params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
} }
if ($testToolkitCountry) { if ($testToolkitCountry) {
$fileFilter = "*.$testToolkitCountry.fob" $fileFilter = "*.$testToolkitCountry.fob"

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

@ -42,7 +42,7 @@ function Publish-BuildOutputToStorage {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try { try {
if ($StorageConnectionString -is [SecureString]) { $StorageConnectionString = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($StorageConnectionString)) } if ($StorageConnectionString -is [SecureString]) { $StorageConnectionString = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($StorageConnectionString)) }
if ($StorageConnectionString -isnot [string]) { throw "StorageConnectionString needs to be a SecureString or a String" } if ($StorageConnectionString -isnot [string]) { throw "StorageConnectionString needs to be a SecureString or a String" }
$projectName = $projectName.ToLowerInvariant() $projectName = $projectName.ToLowerInvariant()
$appVersion = $appVersion.ToLowerInvariant() $appVersion = $appVersion.ToLowerInvariant()

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

@ -2,6 +2,14 @@
Add trustServerCertificate is the parameter exists in various functions that might be running on the host Add trustServerCertificate is the parameter exists in various functions that might be running on the host
Issue #3594 Run-AlCops says unknown platform version Issue #3594 Run-AlCops says unknown platform version
Add information about apps excluded due to not being referenced during Publish-BcContainerApp Add information about apps excluded due to not being referenced during Publish-BcContainerApp
Run-AlPipeline to support CompilerFolder and online environments for building and testing
Added 2 new overrides in Run-AlPipeline: PipelineInitialize and PipelineFinalize
Add parameter CompilerFolder to Run-TestsInBcContainer and Import-TestToolkitToBcContainer for running tests using CompilerFolder bits from the host
Replace all occurrences of [System.Runtime.InteropServices.Marshal]::PtrToStringAuto with [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR as the Auto function doesn't always do what's expected under Linux
Ensure correct casing of Newtonsoft.Json.dll for Linux
Always add extensionId (when specified) to Properties section in test results xml
If environment is specified as a Web Client URL, and BcAuthContext contains username/password in Run-AlPipeline, then tests will run against this environment. PublishBcContainerApp and ImportTestToolkitToBcContainer needs to be overridden for this to work with full pipeline.
Including caching of appinfos in CompilerFolder cache (to save time when caching on GitHub Actions)
6.0.19 6.0.19
Issue #3560 Backup-BcContainerDatabases fails - password must be marked as read only bug Issue #3560 Backup-BcContainerDatabases fails - password must be marked as read only bug
@ -438,7 +446,7 @@ Use a PowerShell Job to run bcpt tests to be able to remove files afterwards
Allow Get-BcContainerAppInfo to be used without explicitely specifying -containerName $containerName, allowing just $containerName Allow Get-BcContainerAppInfo to be used without explicitely specifying -containerName $containerName, allowing just $containerName
Add new function Set-BcContainerServerConfiguration to directly configure settings of the Business Central Server instance (without needing Invoke-ScriptInBcContainer) Add new function Set-BcContainerServerConfiguration to directly configure settings of the Business Central Server instance (without needing Invoke-ScriptInBcContainer)
Add new function Restart-BcContainerServiceTier to restart only the service tier after configuration changes (often necessary) Add new function Restart-BcContainerServiceTier to restart only the service tier after configuration changes (often necessary)
Patch wrong version of Newtonsoft.json.dll in current insider builds (until this is fixed in the platform) Patch wrong version of Newtonsoft.Json.dll in current insider builds (until this is fixed in the platform)
3.0.8 3.0.8
Add new function Get-ALGoAuthContext to get AL-Go for GitHub compatible auth context from bcAuthContext obtained from New-BcAuthContext Add new function Get-ALGoAuthContext to get AL-Go for GitHub compatible auth context from bcAuthContext obtained from New-BcAuthContext

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

@ -60,7 +60,7 @@ try {
} }
if ($PsCmdlet.ParameterSetName -eq "CC") { if ($PsCmdlet.ParameterSetName -eq "CC") {
if ($clientId -is [SecureString]) { $clientID = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($clientID)) } if ($clientId -is [SecureString]) { $clientID = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($clientID)) }
if ($clientId -isnot [String]) { throw "ClientID needs to be a SecureString or a String" } if ($clientId -isnot [String]) { throw "ClientID needs to be a SecureString or a String" }
if ($clientSecret -is [String]) { $clientSecret = ConvertTo-SecureString -String $clientSecret -AsPlainText -Force } if ($clientSecret -is [String]) { $clientSecret = ConvertTo-SecureString -String $clientSecret -AsPlainText -Force }
if ($clientSecret -isnot [SecureString]) { throw "ClientSecret needs to be a SecureString or a String" } if ($clientSecret -isnot [SecureString]) { throw "ClientSecret needs to be a SecureString or a String" }

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

@ -37,7 +37,7 @@ try {
$ProcessArguments += "Command=generatesymbolreference, Database=""$databaseName"", ServerName=""$databaseServer""" $ProcessArguments += "Command=generatesymbolreference, Database=""$databaseName"", ServerName=""$databaseServer"""
if ($sqlCredential) { if ($sqlCredential) {
Write-Host "Adding SQL-Server credentials for authentication" Write-Host "Adding SQL-Server credentials for authentication"
$ProcessArguments += ", ntauthentication=0, username=""$($sqlCredential.UserName)"", password=""$([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password)))""" $ProcessArguments += ", ntauthentication=0, username=""$($sqlCredential.UserName)"", password=""$([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password)))"""
} }
Write-Host "Creating application symbols in $containerName" Write-Host "Creating application symbols in $containerName"

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

@ -101,7 +101,7 @@ try {
$sqlparams += @{ $sqlparams += @{
"ServerInstance" = $databaseServerInstance "ServerInstance" = $databaseServerInstance
"Username" = $databaseCredential.Username "Username" = $databaseCredential.Username
"Password" = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password)) "Password" = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))
} }
} }
} }

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

@ -121,7 +121,7 @@ try {
$parameters = @{ $parameters = @{
"name" = "CreateTestUsers$select" "name" = "CreateTestUsers$select"
"value" = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password))) "value" = ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)))
} }
Invoke-BcContainerApi -containerName $containerName -tenant $tenant -credential $credential -APIPublisher "Microsoft" -APIGroup "Setup" -APIVersion "beta" -CompanyId $companyId -Method "POST" -Query "testUsers" -body $parameters | Out-Null Invoke-BcContainerApi -containerName $containerName -tenant $tenant -credential $credential -APIPublisher "Microsoft" -APIGroup "Setup" -APIVersion "beta" -CompanyId $companyId -Method "POST" -Query "testUsers" -body $parameters | Out-Null