This commit is contained in:
freddydk 2022-11-30 16:15:38 +01:00
Родитель 883b49854a
Коммит 0ffebd0736
98 изменённых файлов: 814 добавлений и 476 удалений

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

@ -13,22 +13,17 @@
[ValidateSet('public','private')]
$accessControl,
[Parameter(Mandatory=$true)]
[string] $country,
$apps = @(),
[int] $versioningStrategy = 16,
[switch] $updateDependencies,
[switch] $generateDependencyArtifact,
[string] $repoVersion = "",
[HashTable] $addRepoSettings = @{},
[HashTable] $addProjectSettings = @{},
$readme = "# $repo",
$gitHubRunner = "windows-latest",
[string] $keyVaultName,
[switch] $useOrgSecrets,
[string[]] $additionalCountries = @(),
[HashTable] $secrets = @{},
[switch] $additionalCountriesAlways,
[string] $nextMajorSchedule,
[string] $nextMinorSchedule,
[string] $currentschedule,
[HashTable] $secrets
[switch] $openFolder,
[switch] $openVSCode,
[switch] $openBrowser
)
# Well known AppIds
@ -183,12 +178,12 @@
throw "Specified folder already exists"
}
if ($repoVersion) {
if ($addRepoSettings.ContainsKey('repoVersion')) {
try {
$version = [Version]"$repoVersion.0.0"
$version = [Version]"$($addRepoSettings.repoVersion).0.0"
}
catch {
throw "repoVersion is not correctly formatted, needs to be major.minor"
throw "addRepoSettings.repoVersion is not correctly formatted, needs to be major.minor"
}
}
else {
@ -241,14 +236,16 @@
$workspaceFile = Join-Path $folder "$repo.code-workspace"
$workspace = Get-Content $workspaceFile -Encoding UTF8 | ConvertFrom-Json
Write-Host "Updating settings"
if ($gitHubRunner -and $gitHubRunner -ne "Windows-Latest") {
SetSetting -settings $repoSettings -name "GitHubRunner" -value $gitHubRunner
if (-not $addProjectSettings.ContainsKey('VersioningStrategy')) {
$addProjectSettings.VersioningStrategy = 16
}
SetSetting -settings $projectSettings -name "Country" -value $country
if ($additionalCountriesAlways) {
SetSetting -settings $projectSettings -name "AdditionalCountries" -value $additionalCountries
[string[]] $additionalCountries = @()
if ($addProjectSettings.ContainsKey('AdditionalCountries')) {
$additionalCountries = [string[]] $addProjectSettings.AdditionalCountries
if (!$additionalCountriesAlways) {
$addProjectSettings.AdditionalCountries = @()
}
}
if ($apps) {
@ -350,10 +347,10 @@
}
}
if (($VersioningStrategy -band 16) -eq 16) {
if (-not ($repoVersion)) {
$repoVersion = "$($maxVersionNumber.Major).$($maxVersionNumber.Minor+1)"
$version = [Version]"$repoVersion.0.0"
if (($addProjectSettings.VersioningStrategy -band 16) -eq 16) {
if (-not $addRepoSettings.ContainsKey('repoVersion')) {
$addRepoSettings.repoVersion = "$($maxVersionNumber.Major).$($maxVersionNumber.Minor+1)"
$version = [Version]"$($addRepoSettings.repoVersion).0.0"
}
$projectSettings.AppFolders+$projectSettings.TestFolders | ForEach-Object {
$appJsonFile = Join-Path $folder "$_\app.json"
@ -367,15 +364,23 @@
}
}
else {
$repoVersion = "1.0"
if (($versioningStrategy -band 15) -eq 0) {
$addRepoSettings.repoVersion = "1.0"
if (($addProjectSettings.VersioningStrategy -band 15) -eq 0) {
SetSetting -settings $repoSettings -name "RunNumberOffset" -value $maxBuildNo
}
}
SetSetting -settings $repoSettings -name "RepoVersion" -value $repoVersion
SetSetting -settings $repoSettings -name "UpdateDependencies" -value $updateDependencies.IsPresent
SetSetting -settings $repoSettings -name "GenerateDependencyArtifact" -value $generateDependencyArtifact.IsPresent
Write-Host "Updating Repo Settings"
$addRepoSettings.Keys | ForEach-Object {
Write-Host "- $_ = $($addRepoSettings."$_")"
SetSetting -settings $repoSettings -name $_ -value $addRepoSettings."$_"
}
Write-Host "Updating Project Settings"
$addProjectSettings.Keys | ForEach-Object {
Write-Host "- $_ = $($addProjectSettings."$_")"
SetSetting -settings $projectSettings -name $_ -value $addProjectSettings."$_"
}
$orgSecrets = @(invoke-gh -returnValue secret list --org $Org -ErrorAction SilentlyContinue)
@ -428,21 +433,23 @@
'NextMajor','NextMinor','Current' | ForEach-Object {
$name = "$($_)Schedule"
$value = (Get-Variable $name).Value
$workflowFile = ".github\workflows\$_.yaml"
$srcContent = (Get-Content -Path $workflowFile -Encoding UTF8 -Raw).Replace("`r", "").TrimEnd("`n").Replace("`n", "`r`n")
if ($value) {
SetSetting -settings $repoSettings -name $name -value $value
$srcPattern = "on:`r`n workflow_dispatch:`r`n"
$replacePattern = "on:`r`n schedule:`r`n - cron: '$($value)'`r`n workflow_dispatch:`r`n"
$srcContent = $srcContent.Replace($srcPattern, $replacePattern)
Set-Content -Path $workflowFile -Encoding UTF8 -Value $srcContent
}
if (!$additionalCountriesAlways) {
$workflowSettingsFile = Join-Path $folder ".github\$($srcContent.Split("`r")[0].Substring(6)).settings.json"
$workflowSettings = Get-Content $workflowSettingsFile -Encoding UTF8 | ConvertFrom-Json
SetSetting -settings $workflowSettings -name "AdditionalCountries" -value $additionalCountries
$workflowSettings | ConvertTo-Json -Depth 99 | Set-Content -Path $workflowSettingsFile -Encoding UTF8
if ($addRepoSettings.ContainsKey($name)) {
$value = $repoSettings."$name"
$workflowFile = ".github\workflows\$_.yaml"
$srcContent = (Get-Content -Path $workflowFile -Encoding UTF8 -Raw).Replace("`r", "").TrimEnd("`n").Replace("`n", "`r`n")
if ($value) {
SetSetting -settings $repoSettings -name $name -value $value
$srcPattern = "on:`r`n workflow_dispatch:`r`n"
$replacePattern = "on:`r`n schedule:`r`n - cron: '$($value)'`r`n workflow_dispatch:`r`n"
$srcContent = $srcContent.Replace($srcPattern, $replacePattern)
Set-Content -Path $workflowFile -Encoding UTF8 -Value $srcContent
}
if (!$additionalCountriesAlways -and $additionalCountries) {
$workflowSettingsFile = Join-Path $folder ".github\$($srcContent.Split("`r")[0].Substring(6).Trim("'").Trim(' ')).settings.json"
$workflowSettings = Get-Content $workflowSettingsFile -Encoding UTF8 | ConvertFrom-Json
SetSetting -settings $workflowSettings -name "AdditionalCountries" -value $additionalCountries
$workflowSettings | ConvertTo-Json -Depth 99 | Set-Content -Path $workflowSettingsFile -Encoding UTF8
}
}
}
@ -459,6 +466,19 @@
invoke-git -silent commit --allow-empty -m "initial commit"
invoke-git -silent push
$tmpFolder
Write-Host "https://github.com/$repository"
if ($openBrowser) {
Start-Process "https://github.com/$repository"
}
if ($openVSCode) {
code "$tmpFolder\$repo\$repo.code-workspace"
}
elseif ($openFolder) {
Start-Process "$tmpFolder\$repo"
}
else {
$tmpFolder
}
}
Export-ModuleMember -Function New-ALGoRepo

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

@ -107,7 +107,7 @@ try {
$ip = Get-BcContainerIpAddress -containerName $containerName
if ($ip) {
$url = "${protocol}${ip}:$($customConfig.ODataServicesPort)/$($customConfig.ServerInstance)/api"
$url = "$($protocol)$($ip):$($customConfig.ODataServicesPort)/$($customConfig.ServerInstance)/api"
}
else {
$url = $customconfig.PublicODataBaseUrl.Replace("/OData","/api")

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

@ -57,7 +57,7 @@ try {
throw "Container $containerName does not support the function Clean-BcContainerDatabase"
}
$myFolder = Join-Path $ExtensionsFolder "$containerName\my"
$myFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\my"
$licenseFile = @(Get-Item "$myFolder\license.*")
if ($licenseFile.Count -eq 0) {
throw "Container must be started with a developer license to perform this operation."
@ -80,7 +80,7 @@ try {
}
if ($platformversion.Major -lt 15) {
$SystemSymbolsFile = Join-Path $ExtensionsFolder "$containerName\system.app"
$SystemSymbolsFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\system.app"
$systemSymbols = Get-BcContainerAppInfo -containerName $containerName -symbolsOnly | Where-Object { $_.Name -eq "System" }
Get-BcContainerApp -containerName $containerName -appName $SystemSymbols.Name -publisher $SystemSymbols.Publisher -appVersion $SystemSymbols.Version -appFile $SystemSymbolsFile -credential $credential
$SystemApplicationFile = ""

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

@ -663,7 +663,7 @@ try {
if ($CopyAppToSymbolsFolder) {
Copy-Item -Path $appFile -Destination $appSymbolsFolder -ErrorAction SilentlyContinue
if (Test-Path -Path (Join-Path -Path $appSymbolsFolder -ChildPath $appName)) {
Write-Host "${appName} copied to ${appSymbolsFolder}"
Write-Host "$($appName) copied to $($appSymbolsFolder)"
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param($appSymbolsFolder, $appName)
$appFile = Join-Path -Path $appSymbolsFolder -ChildPath $appName
while (-not (Test-Path -Path $appFile)) { Start-Sleep -Seconds 1 }

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

@ -63,8 +63,8 @@ try {
$navversion = Get-BcContainerNavversion -containerOrImageName $containerName
$ver = [System.Version]($navversion.split('-')[0])
$alFolder = Join-Path $ExtensionsFolder "Original-$navversion-al"
$dotnetAssembliesFolder = Join-Path $ExtensionsFolder "$containerName\.netPackages"
$alFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion-al"
$dotnetAssembliesFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\.netPackages"
if (($useBaseLine -and !(Test-Path $alFolder -PathType Container)) -or !(Test-Path $dotnetAssembliesFolder -PathType Container)) {
throw "Container $containerName was not started with -includeAL (or -doNotExportObjectsAsText was specified)"
@ -90,9 +90,9 @@ try {
}
elseif ($ver.Major -ge 15) {
$id = [Guid]::NewGuid().Guid
$appFile = Join-Path $ExtensionsFolder "BaseApp-$id.app"
$appFolder = Join-Path $ExtensionsFolder "BaseApp-$id"
$myAlFolder = Join-Path $ExtensionsFolder "al-$id"
$appFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\BaseApp-$id.app"
$appFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\BaseApp-$id"
$myAlFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\al-$id"
try {
$appName = "Base Application"
if ($ver -lt [Version]("15.0.35659.0")) {

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

@ -40,8 +40,8 @@ try {
}
}
if ("$appFolder" -eq "$hostHelperFolder" -or "$appFolder" -eq "$hostHelperFolder\") {
throw "The folder specified in ObjectsFolder will be erased, you cannot specify $hostHelperFolder"
if ("$appFolder" -eq "($bcContainerHelperConfig.hostHelperFolder)" -or "$appFolder" -eq "$($bcContainerHelperConfig.hostHelperFolder)\") {
throw "The folder specified in ObjectsFolder will be erased, you cannot specify $($bcContainerHelperConfig.hostHelperFolder)"
}
if (!(Test-Path $appFileName)) {

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

@ -28,7 +28,7 @@ function Get-BcContainerApp {
[Parameter(Mandatory=$false)]
[string] $Tenant = "default",
[Parameter(Mandatory=$false)]
[string] $appFile = (Join-Path $extensionsFolder "$containerName\$appName.app"),
[string] $appFile = (Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\$appName.app"),
[Parameter(Mandatory=$false)]
[PSCredential] $credential = $null
)

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

@ -33,7 +33,7 @@ function Get-BcContainerAppRuntimePackage {
[Parameter(Mandatory=$false)]
[Boolean] $IncludeSourceInPackageFile,
[Parameter(Mandatory=$false)]
[string] $appFile = (Join-Path $extensionsFolder ("$containerName\$appName.app" -replace '[~#%&*{}|:<>?/|"]', '_'))
[string] $appFile = (Join-Path $bcContainerHelperConfig.hostHelperFolder ("Extensions\$containerName\$appName.app" -replace '[~#%&*{}|:<>?/|"]', '_'))
)
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
@ -44,8 +44,8 @@ try {
throw "The app filename ($appFile)needs to be in a folder, which is shared with the container $containerName"
}
$showMyCodeExists = ($PSBoundParameters.ContainsKey(showMyCode))
$IncludeSourceInPackageFileExists = ($PSBoundParameters.ContainsKey(IncludeSourceInPackageFile))
$showMyCodeExists = ($PSBoundParameters.ContainsKey('showMyCode'))
$IncludeSourceInPackageFileExists = ($PSBoundParameters.ContainsKey('IncludeSourceInPackageFile'))
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param($appName, $publisher, $appVersion, $tenant, $appFile, $showMyCodeExists, $showMyCode, $IncludeSourceInPackageFileExists, $IncludeSourceInPackageFile)

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

@ -90,7 +90,7 @@ try {
}
}
$PsTestToolFolder = Join-Path $extensionsFolder "$containerName\PsTestTool"
$PsTestToolFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\PsTestTool"
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"
$fobfile = Join-Path $PsTestToolFolder "PSTestToolPage.fob"

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

@ -107,7 +107,7 @@ try {
$installedApps = @()
if ($containerName) {
$customconfig = Get-BcContainerServerConfiguration -ContainerName $containerName
$appFolder = Join-Path $extensionsFolder "$containerName\$([guid]::NewGuid().ToString())"
$appFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\$([guid]::NewGuid().ToString())"
if ($appFile -is [string] -and $appFile.Startswith(':')) {
New-Item $appFolder -ItemType Directory | Out-Null
$destFile = Join-Path $appFolder ([System.IO.Path]::GetFileName($appFile.SubString(1)).Replace('*','').Replace('?',''))

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

@ -111,7 +111,7 @@ try {
} -argumentList $containerAppDotNetPackagesFolder
$containerFolder = Join-Path $ExtensionsFolder $containerName
$containerFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName"
$appsFolder = Join-Path $containerFolder "Extensions"
if (!(Test-Path $appsFolder)) {
New-Item -Path $appsFolder -ItemType Directory | Out-Null

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

@ -51,7 +51,7 @@ function Run-AlCops {
$affixes,
$supportedCountries,
[string] $obsoleteTagMinAllowedMajorMinor = "",
$appPackagesFolder = (Join-Path $hosthelperfolder ([Guid]::NewGuid().ToString())),
$appPackagesFolder = (Join-Path $bcContainerHelperConfig.hostHelperFolder ([Guid]::NewGuid().ToString())),
[switch] $enableAppSourceCop,
[switch] $enableCodeCop,
[switch] $enableUICop,
@ -85,7 +85,7 @@ try {
throw "You cannot run AppSourceCop and PerTenantExtensionCop at the same time"
}
$appsFolder = Join-Path $hosthelperfolder ([Guid]::NewGuid().ToString())
$appsFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder ([Guid]::NewGuid().ToString())
New-Item -Path $appsFolder -ItemType Directory | Out-Null
$apps = Sort-AppFilesByDependencies -containerName $containerName -appFiles @(CopyAppFilesToFolder -appFiles $apps -folder $appsFolder) -WarningAction SilentlyContinue
@ -145,7 +145,7 @@ try {
$appFile = $_
$appFileName = [System.IO.Path]::GetFileName($appFile)
$tmpFolder = Join-Path $hosthelperfolder ([Guid]::NewGuid().ToString())
$tmpFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder ([Guid]::NewGuid().ToString())
try {
$length = $global:_validationResult.Length
if (!$skipVerification) {

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

@ -348,7 +348,7 @@ $version = [System.Version]::new($currentArtifactUrl.Split('/')[4])
$currentVersion = "$($version.Major).$($version.Minor)"
$validateVersion = "17.0"
$tmpAppsFolder = Join-Path $hosthelperfolder ([Guid]::NewGuid().ToString())
$tmpAppsFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder ([Guid]::NewGuid().ToString())
@(CopyAppFilesToFolder -appFiles @($installApps+$apps) -folder $tmpAppsFolder) | % {
$appFile = $_
$version = GetApplicationDependency -appFile $appFile -minVersion $validateVersion
@ -420,7 +420,7 @@ if ($artifactUrl) {
$prevProgressPreference = $progressPreference
$progressPreference = 'SilentlyContinue'
$appPackagesFolder = Join-Path $hosthelperfolder ([Guid]::NewGuid().ToString())
$appPackagesFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder ([Guid]::NewGuid().ToString())
New-Item $appPackagesFolder -ItemType Directory | Out-Null
try {

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

@ -57,7 +57,7 @@ try {
if (-not (Get-BcContainerAppInfo -containerName $containerName | Where-Object { $_.appId -eq $appJson.id })) {
Write-Host "Adding BCPTLogEntryAPI.app to extend existing Performance Toolkit with BCPTLogEntry API page"
Write-Host "Using Object Id $($bcContainerHelperConfig.ObjectIdForInternalUse) (set `$bcContainerHelperConfig.ObjectIdForInternalUse to change)"
$appExtFolder = Join-Path $hosthelperfolder "Extensions\$containerName\$([GUID]::NewGuid().ToString())"
$appExtFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\$([GUID]::NewGuid().ToString())"
New-Item $appExtFolder -ItemType Directory | Out-Null
$appJson.idRanges[0].from = $bcContainerHelperConfig.ObjectIdForInternalUse
$appJson.idRanges[0].to = $bcContainerHelperConfig.ObjectIdForInternalUse
@ -152,7 +152,7 @@ try {
-ServiceUrl $serviceUrl `
-Environment OnPrem `
-TestRunnerPage ([int]$testPage) | Out-Null
} -ArgumentList (Join-Path $hosthelperfolder "extensions\$containerName\my\TestRunner"), $params, $suiteCode, $serviceUrl, $testPage | Wait-Job
} -ArgumentList (Join-Path $bcContainerHelperConfig.hostHelperFolder "extensions\$containerName\my\TestRunner"), $params, $suiteCode, $serviceUrl, $testPage | Wait-Job
if ($job.State -ne "Completed") {
Write-Host "Running performance test failed"

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

@ -124,7 +124,7 @@ try {
$credential = New-Object pscredential -ArgumentList $bcAuthContext.upn, (ConvertTo-SecureString -String $accessToken -AsPlainText -Force)
}
$PsTestToolFolder = Join-Path $extensionsFolder "$containerName\PsConnectionTestTool"
$PsTestToolFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\PsConnectionTestTool"
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"

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

@ -217,7 +217,7 @@ try {
$credential = New-Object pscredential -ArgumentList $bcAuthContext.upn, (ConvertTo-SecureString -String $accessToken -AsPlainText -Force)
}
$PsTestToolFolder = Join-Path $extensionsFolder "$containerName\PsTestTool"
$PsTestToolFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\PsTestTool"
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"
$fobfile = Join-Path $PsTestToolFolder "PSTestToolPage.fob"

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

@ -44,8 +44,7 @@ try {
throw "The app ($appFile)needs to be in a folder, which is shared with the container $containerName"
}
$ExtensionsFolder = Join-Path $hosthelperfolder "Extensions"
$sharedPfxFile = Join-Path $ExtensionsFolder "$containerName\my\$([GUID]::NewGuid().ToString()).pfx"
$sharedPfxFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\my\$([GUID]::NewGuid().ToString()).pfx"
$removeSharedPfxFile = $true
if ($pfxFile -like "https://*" -or $pfxFile -like "http://*") {
Write-Host "Downloading certificate file to container"

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

@ -33,7 +33,7 @@ try {
$sharedFolder = ""
if ($containerName) {
$sharedFolder = Join-Path $extensionsFolder "$containerName\$([Guid]::NewGuid().ToString())"
$sharedFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\$([Guid]::NewGuid().ToString())"
New-Item $sharedFolder -ItemType Directory | Out-Null
}
try {

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

@ -37,7 +37,7 @@ $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -paramet
try {
if ($basePath -eq "") {
$basePath = $bcartifactsCacheFolder
$basePath = $bcContainerHelperConfig.bcartifactsCacheFolder
}
if (-not (Test-Path $basePath)) {

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

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

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

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

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

@ -37,7 +37,7 @@ function New-LetsEncryptCertificate {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try {
$stateDir = Join-Path $hostHelperFolder "acmeState"
$stateDir = Join-Path $bcContainerHelperConfig.hostHelperFolder "acmeState"
Write-Host "Importing ACME-PS module (need 1.1.0-beta or higher)"
Import-Module ACME-PS

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

@ -33,7 +33,7 @@ try {
Write-Host "Importing ACME-PS module (need 1.1.0-beta or higher)"
Import-Module ACME-PS
$stateDir = Join-Path $hostHelperFolder "acmeState"
$stateDir = Join-Path $bcContainerHelperConfig.hostHelperFolder "acmeState"
if (Test-Path $certificatePfxFilename) {
Write-Host "Removing existing certificate"
Remove-Item -Path $certificatePfxFilename -Force

14
BC.ALGoHelper.module.json Normal file
Просмотреть файл

@ -0,0 +1,14 @@
{
"GUID": "fa5f4d08-53be-4ca0-bf16-26da89afa20f",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"HelperFunctions.ps1",
"AL-Go\\*"
]
}

20
BC.ALGoHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,20 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper', 'BC.CommonHelper', 'BC.AuthHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# AL-Go for GitHub functions
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAuthContext.ps1")
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAppSourceContext.ps1")
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoStorageContext.ps1")
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoNuGetContext.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepo.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepoWizard.ps1")

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

@ -0,0 +1,14 @@
{
"GUID": "325e1f63-e3d3-43d5-954d-2ac74f59bc7d",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"HelperFunctions.ps1",
"AppSource\\*"
]
}

20
BC.AppSourceHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,20 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper', 'BC.CommonHelper', 'BC.AuthHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# AppSource specific functions
. (Join-Path $PSScriptRoot "AppSource\Invoke-IngestionAPI.ps1")
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceProduct.ps1")
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceSubmission.ps1")
. (Join-Path $PSScriptRoot "AppSource\New-AppSourceSubmission.ps1")
. (Join-Path $PSScriptRoot "AppSource\Promote-AppSourceSubmission.ps1")
. (Join-Path $PSScriptRoot "AppSource\Cancel-AppSourceSubmission.ps1")

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

@ -0,0 +1,13 @@
{
"GUID": "2262fadf-b661-4818-aec8-4502802bbf42",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"Artifacts\\*"
]
}

17
BC.ArtifactsHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,17 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper', 'BC.CommonHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# Common functions
. (Join-Path $PSScriptRoot "Artifacts\Download-Artifacts.ps1")
. (Join-Path $PSScriptRoot "Artifacts\Get-BcArtifactUrl.ps1")
. (Join-Path $PSScriptRoot "Artifacts\Get-NavArtifactUrl.ps1")

14
BC.AuthHelper.module.json Normal file
Просмотреть файл

@ -0,0 +1,14 @@
{
"GUID": "037c5ebf-d617-4884-9048-2e9be44e7630",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"HelperFunctions.ps1",
"Auth\\*"
]
}

16
BC.AuthHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,16 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper', 'BC.CommonHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# BC SaaS specific functions
. (Join-Path $PSScriptRoot "Auth\New-BcAuthContext.ps1")
. (Join-Path $PSScriptRoot "Auth\Renew-BcAuthContext.ps1")

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

@ -0,0 +1,13 @@
{
"GUID": "2262fadf-b661-4818-aec8-4502802bbf42",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"Common\\*"
]
}

22
BC.CommonHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,22 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# Common functions
. (Join-Path $PSScriptRoot "Common\Download-File.ps1")
. (Join-Path $PSScriptRoot "Common\New-DesktopShortcut.ps1")
. (Join-Path $PSScriptRoot "Common\Remove-DesktopShortcut.ps1")
. (Join-Path $PSScriptRoot "Common\ConvertTo-HashTable.ps1")
. (Join-Path $PSScriptRoot "Common\Get-PlainText.ps1")
. (Join-Path $PSScriptRoot "Common\Invoke-gh.ps1")
. (Join-Path $PSScriptRoot "Common\Invoke-git.ps1")
. (Join-Path $PSScriptRoot "Common\ConvertTo-OrderedDictionary.ps1")

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

@ -0,0 +1,12 @@
{
"GUID": "25a65b43-3a76-4782-8515-06de2d4bae21",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1"
]
}

164
BC.ConfigurationHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,164 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name
function Get-ContainerHelperConfig {
if (!((Get-Variable -scope Script bcContainerHelperConfig -ErrorAction SilentlyContinue) -and $bcContainerHelperConfig)) {
Set-Variable -scope Script -Name bcContainerHelperConfig -Value @{
"bcartifactsCacheFolder" = ""
"genericImageName" = 'mcr.microsoft.com/businesscentral:{0}'
"genericImageNameFilesOnly" = 'mcr.microsoft.com/businesscentral:{0}-filesonly'
"usePsSession" = $isAdministrator # -and ("$ENV:GITHUB_ACTIONS" -ne "true") -and ("$ENV:TF_BUILD" -ne "true")
"addTryCatchToScriptBlock" = $true
"killPsSessionProcess" = $false
"useVolumes" = $false
"useVolumeForMyFolder" = $false
"use7zipIfAvailable" = $true
"defaultNewContainerParameters" = @{ }
"hostHelperFolder" = ""
"containerHelperFolder" = "C:\ProgramData\BcContainerHelper"
"defaultContainerName" = "bcserver"
"digestAlgorithm" = "SHA256"
"timeStampServer" = "http://timestamp.digicert.com"
"sandboxContainersAreMultitenantByDefault" = $true
"useSharedEncryptionKeys" = $true
"DOCKER_SCAN_SUGGEST" = $false
"psSessionTimeout" = 0
"baseUrl" = "https://businesscentral.dynamics.com"
"apiBaseUrl" = "https://api.businesscentral.dynamics.com"
"mapCountryCode" = [PSCustomObject]@{
"ae" = "w1"
"ar" = "w1"
"bd" = "w1"
"dz" = "w1"
"cl" = "w1"
"pr" = "w1"
"eg" = "w1"
"fo" = "dk"
"gl" = "dk"
"id" = "w1"
"ke" = "w1"
"lb" = "w1"
"lk" = "w1"
"lu" = "w1"
"ma" = "w1"
"mm" = "w1"
"mt" = "w1"
"my" = "w1"
"ng" = "w1"
"qa" = "w1"
"sa" = "w1"
"sg" = "w1"
"tn" = "w1"
"ua" = "w1"
"za" = "w1"
"ao" = "w1"
"bh" = "w1"
"ba" = "w1"
"bw" = "w1"
"cr" = "br"
"cy" = "w1"
"do" = "br"
"ec" = "br"
"sv" = "br"
"gt" = "br"
"hn" = "br"
"jm" = "w1"
"mv" = "w1"
"mu" = "w1"
"ni" = "br"
"pa" = "br"
"py" = "br"
"tt" = "br"
"uy" = "br"
"zw" = "w1"
}
"mapNetworkSettings" = [PSCustomObject]@{
}
"AddHostDnsServersToNatContainers" = $false
"TraefikUseDnsNameAsHostName" = $false
"TreatWarningsAsErrors" = @()
"PartnerTelemetryConnectionString" = ""
"MicrosoftTelemetryConnectionString" = "InstrumentationKey=5b44407e-9750-4a07-abe9-30c3b853821b;IngestionEndpoint=https://southcentralus-0.in.applicationinsights.azure.com/"
"SendExtendedTelemetryToMicrosoft" = $false
"TraefikImage" = "tobiasfenster/traefik-for-windows:v1.7.34"
"ObjectIdForInternalUse" = 88123
"WinRmCredentials" = $null
"WarningPreference" = "SilentlyContinue"
"UseNewFormatForGetBcContainerAppInfo" = $false
"NoOfSecondsToSleepAfterPublishBcContainerApp" = 1
"RenewClientContextBetweenTests" = $false
}
if ($isInsider) {
$bcContainerHelperConfig.genericImageName = 'mcr.microsoft.com/businesscentral:{0}-dev'
$bcContainerHelperConfig.genericImageNameFilesOnly = 'mcr.microsoft.com/businesscentral:{0}-filesonly-dev'
}
if ($bcContainerHelperConfigFile -notcontains "C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json") {
$bcContainerHelperConfigFile = @("C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json")+$bcContainerHelperConfigFile
}
$bcContainerHelperConfigFile | ForEach-Object {
$configFile = $_
if (Test-Path $configFile) {
try {
$savedConfig = Get-Content $configFile | ConvertFrom-Json
if ("$savedConfig") {
$keys = $bcContainerHelperConfig.Keys | % { $_ }
$keys | ForEach-Object {
if ($savedConfig.PSObject.Properties.Name -eq "$_") {
if (!$silent) {
Write-Host "Setting $_ = $($savedConfig."$_")"
}
$bcContainerHelperConfig."$_" = $savedConfig."$_"
}
}
}
}
catch {
throw "Error reading configuration file $configFile, cannot import module."
}
}
}
if ($isInsideContainer) {
$bcContainerHelperConfig.usePsSession = $true
try {
$myinspect = docker inspect $(hostname) | ConvertFrom-Json
$bcContainerHelperConfig.WinRmCredentials = New-Object PSCredential -ArgumentList 'WinRmUser', (ConvertTo-SecureString -string "P@ss$($myinspect.Id.SubString(48))" -AsPlainText -Force)
}
catch {}
}
if ($bcContainerHelperConfig.UseVolumes) {
if ($bcContainerHelperConfig.bcartifactsCacheFolder -eq "") {
$bcContainerHelperConfig.bcartifactsCacheFolder = "bcartifacts.cache"
}
if ($bcContainerHelperConfig.hostHelperFolder -eq "") {
$bcContainerHelperConfig.hostHelperFolder = "hostHelperFolder"
}
$bcContainerHelperConfig.useVolumeForMyFolder = $false
}
else {
if ($bcContainerHelperConfig.bcartifactsCacheFolder -eq "") {
$bcContainerHelperConfig.bcartifactsCacheFolder = "c:\bcartifacts.cache"
}
if ($bcContainerHelperConfig.hostHelperFolder -eq "") {
$bcContainerHelperConfig.hostHelperFolder = "C:\ProgramData\BcContainerHelper"
}
}
Export-ModuleMember -Variable bcContainerHelperConfig
}
return $bcContainerHelperConfig
}
Get-ContainerHelperConfig | Out-Null
# There can be no functions exposed from the configuration module

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

@ -0,0 +1,14 @@
{
"GUID": "5ef27830-ae76-422f-8439-db8db89e9ece",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"HelperFunctions.ps1",
"NuGet\\*"
]
}

18
BC.NuGetHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,18 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper', 'BC.CommonHelper', 'BC.AuthHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# AppSource specific functions
. (Join-Path $PSScriptRoot "NuGet\New-BcNuGetPackage.ps1")
. (Join-Path $PSScriptRoot "NuGet\Get-BcNuGetPackage.ps1")
. (Join-Path $PSScriptRoot "NuGet\Push-BcNuGetPackage.ps1")
. (Join-Path $PSScriptRoot "NuGet\Publish-BcNuGetPackageToContainer.ps1")

14
BC.SaasHelper.module.json Normal file
Просмотреть файл

@ -0,0 +1,14 @@
{
"GUID": "e7f1ba7d-b7f1-4c7d-ad19-d24491fbbd19",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"HelperFunctions.ps1",
"SaaS\\*"
]
}

26
BC.SaasHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,26 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper', 'BC.TelemetryHelper', 'BC.CommonHelper', 'BC.AuthHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
# AppSource specific functions
. (Join-Path $PSScriptRoot "SaaS\Get-BcEnvironments.ps1")
. (Join-Path $PSScriptRoot "SaaS\Get-BcPublishedApps.ps1")
. (Join-Path $PSScriptRoot "SaaS\Get-BcInstalledExtensions.ps1")
. (Join-Path $PSScriptRoot "SaaS\Install-BcAppFromAppSource")
. (Join-Path $PSScriptRoot "SaaS\Publish-PerTenantExtensionApps.ps1")
. (Join-Path $PSScriptRoot "SaaS\New-BcEnvironment.ps1")
. (Join-Path $PSScriptRoot "SaaS\Remove-BcEnvironment.ps1")
. (Join-Path $PSScriptRoot "SaaS\Set-BcEnvironmentApplicationInsightsKey.ps1")
. (Join-Path $PSScriptRoot "SaaS\Get-BcDatabaseExportHistory.ps1")
. (Join-Path $PSScriptRoot "SaaS\New-BcDatabaseExport.ps1")
. (Join-Path $PSScriptRoot "SaaS\Get-BcScheduledUpgrade.ps1")
. (Join-Path $PSScriptRoot "SaaS\Reschedule-BcUpgrade.ps1")

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

@ -0,0 +1,14 @@
{
"GUID": "51c0ef5c-b0c1-4289-b3f5-4da94bd99f5b",
"Author": "Freddy Kristiansen",
"CompanyName": "Microsoft",
"CompatiblePSEditions": [
"Core",
"Desktop"
],
"files": [
"InitializeModule.ps1",
"HelperFunctions.ps1",
"TelemetryHelper.ps1"
]
}

45
BC.TelemetryHelper.psm1 Normal file
Просмотреть файл

@ -0,0 +1,45 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @()
)
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name `
-moduleDependencies @( 'BC.ConfigurationHelper' )
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
$telemetry = @{
"Assembly" = $null
"PartnerClient" = $null
"MicrosoftClient" = $null
"CorrelationId" = ""
"TopId" = ""
"Debug" = $false
}
try {
if (($bcContainerHelperConfig.MicrosoftTelemetryConnectionString) -and !$Silent) {
Write-Host -ForegroundColor Green 'BC.TelemetryHelper emits usage statistics telemetry to Microsoft'
}
$dllPath = "C:\ProgramData\BcContainerHelper\Microsoft.ApplicationInsights.2.15.0.44797.dll"
if (-not (Test-Path $dllPath)) {
Copy-Item (Join-Path $PSScriptRoot "Microsoft.ApplicationInsights.dll") -Destination $dllPath
}
$telemetry.Assembly = [System.Reflection.Assembly]::LoadFrom($dllPath)
} catch {
if (!$Silent) {
Write-Host -ForegroundColor Yellow "Unable to load ApplicationInsights.dll"
}
}
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
. (Join-Path $PSScriptRoot "TelemetryHelper.ps1")
# Telemetry functions
Export-ModuleMember -Function RegisterTelemetryScope
Export-ModuleMember -Function InitTelemetryScope
Export-ModuleMember -Function AddTelemetryProperty
Export-ModuleMember -Function TrackTrace
Export-ModuleMember -Function TrackException

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

@ -33,7 +33,7 @@ function Backup-BcContainerDatabases {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try {
$containerFolder = Join-Path $ExtensionsFolder $containerName
$containerFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName"
if ("$bakFolder" -eq "") {
$bakFolder = $containerFolder
}
@ -45,7 +45,7 @@ try {
else {
$folderPrefix = "onprem"
}
$bakFolder = Join-Path $containerHelperFolder "$folderPrefix-$NavVersion-bakFolders\$bakFolder"
$bakFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "$folderPrefix-$NavVersion-bakFolders\$bakFolder"
}
$containerBakFolder = Get-BcContainerPath -containerName $containerName -path $bakFolder -throw

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

@ -58,7 +58,7 @@ try {
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential
$containerFolder = Join-Path $ExtensionsFolder $containerName
$containerFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName"
if ("$bacpacFolder" -eq "") {
$bacpacFolder = $containerFolder
}

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

@ -47,7 +47,7 @@ try {
}
$successFileName = ""
if ($async) {
$successFileName = Join-Path $hosthelperfolder "$($databasePrefix)databasescreated.txt"
$successFileName = Join-Path $bcContainerHelperConfig.hostHelperFolder "$($databasePrefix)databasescreated.txt"
if (Test-Path $successFileName) { Remove-Item $successFileName -Force }
}
Write-Host "Starting Database Restore job from $($artifactUrl.split('?')[0])"

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

@ -53,7 +53,7 @@ try {
throw "You need to specify bakFile when you specify databaseName"
}
else {
$containerFolder = Join-Path $ExtensionsFolder $containerName
$containerFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName"
if ("$bakFolder" -eq "") {
$bakFolder = $containerFolder
}
@ -65,7 +65,7 @@ try {
else {
$folderPrefix = "onprem"
}
$bakFolder = Join-Path $containerHelperFolder "$folderPrefix-$NavVersion-bakFolders\$bakFolder"
$bakFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "$folderPrefix-$NavVersion-bakFolders\$bakFolder"
}
$containerBakFolder = Get-BcContainerPath -containerName $containerName -path $bakFolder -throw
}

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

@ -7,8 +7,9 @@
Get-ChildItem -Path $PSScriptRoot -Recurse | % { Unblock-File -Path $_.FullName }
Get-Module | Where-Object { $_.name -like 'bc.*' } | Remove-Module
Remove-Module NavContainerHelper -ErrorAction Ignore
Remove-Module BcContainerHelper -ErrorAction Ignore
$modulePath = Join-Path $PSScriptRoot "BcContainerHelper.psm1"
Import-Module $modulePath -DisableNameChecking -ArgumentList $Silent, $ExportTelemetryFunctions, $bcContainerHelperConfigFile, $useVolumes

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

@ -92,7 +92,7 @@ FunctionsToExport = 'Add-FontsToBcContainer', 'Add-GitToAlProjectFolder',
'Get-BcContainerApiCompanyId', 'Get-BcContainerApp',
'Get-BcContainerAppInfo', 'Get-BcContainerAppRuntimePackage',
'Convert-BcAppsToRuntimePackages', 'Get-PlainText',
'ConvertTo-HashTable', 'ConvertTo-OrderedDictionary', 'ConvertTo-GitHubGoCredentials',
'ConvertTo-HashTable', 'ConvertTo-OrderedDictionary',
'Get-BcContainerArtifactUrl', 'Get-BcContainerBcUser',
'Get-BcContainerCountry', 'Get-BcContainerDebugInfo',
'Get-BcContainerEula', 'Get-BcContainerEventLog',

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

@ -7,185 +7,25 @@ param(
[switch] $useVolumes
)
Set-StrictMode -Version 2.0
. (Join-Path $PSScriptRoot "InitializeModule.ps1") `
-Silent:$Silent `
-bcContainerHelperConfigFile $bcContainerHelperConfigFile `
-moduleName $MyInvocation.MyCommand.Name
$verbosePreference = "SilentlyContinue"
$warningPreference = 'Continue'
$errorActionPreference = 'Stop'
if ([intptr]::Size -eq 4) {
throw "ContainerHelper cannot run in Windows PowerShell (x86), need 64bit mode"
Import-Module (Join-Path $PSScriptRoot 'BC.ConfigurationHelper.psm1') -DisableNameChecking -Global -ArgumentList $silent,$bcContainerHelperConfigFile
if ($ExportTelemetryFunctions) {
Import-Module (Join-Path $PSScriptRoot 'BC.TelemetryHelper.psm1') -DisableNameChecking -Global -ArgumentList $silent,$bcContainerHelperConfigFile -Global
}
else {
Import-Module (Join-Path $PSScriptRoot 'BC.TelemetryHelper.psm1') -DisableNameChecking -Global -ArgumentList $silent,$bcContainerHelperConfigFile
}
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$isAdministrator = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$isInsideContainer = ((whoami) -eq "user manager\containeradministrator")
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
try {
$myUsername = $currentPrincipal.Identity.Name
} catch {
$myUsername = (whoami)
if ($useVolumes -or $isInsideContainer) {
$bcContainerHelperConfig.UseVolumes = $true
}
$BcContainerHelperVersion = Get-Content (Join-Path $PSScriptRoot "Version.txt")
if (!$silent) {
Write-Host "BcContainerHelper version $BcContainerHelperVersion"
}
$isInsider = $BcContainerHelperVersion -like "*-dev" -or $BcContainerHelperVersion -like "*-preview*"
function Get-ContainerHelperConfig {
if (!((Get-Variable -scope Script bcContainerHelperConfig -ErrorAction SilentlyContinue) -and $bcContainerHelperConfig)) {
Set-Variable -scope Script -Name bcContainerHelperConfig -Value @{
"bcartifactsCacheFolder" = ""
"genericImageName" = 'mcr.microsoft.com/businesscentral:{0}'
"genericImageNameFilesOnly" = 'mcr.microsoft.com/businesscentral:{0}-filesonly'
"usePsSession" = $isAdministrator # -and ("$ENV:GITHUB_ACTIONS" -ne "true") -and ("$ENV:TF_BUILD" -ne "true")
"addTryCatchToScriptBlock" = $true
"killPsSessionProcess" = $false
"useVolumes" = $useVolumes -or $isInsideContainer
"useVolumeForMyFolder" = $false
"use7zipIfAvailable" = $true
"defaultNewContainerParameters" = @{ }
"hostHelperFolder" = ""
"containerHelperFolder" = "C:\ProgramData\BcContainerHelper"
"defaultContainerName" = "bcserver"
"digestAlgorithm" = "SHA256"
"timeStampServer" = "http://timestamp.digicert.com"
"sandboxContainersAreMultitenantByDefault" = $true
"useSharedEncryptionKeys" = $true
"DOCKER_SCAN_SUGGEST" = $false
"psSessionTimeout" = 0
"baseUrl" = "https://businesscentral.dynamics.com"
"apiBaseUrl" = "https://api.businesscentral.dynamics.com"
"mapCountryCode" = [PSCustomObject]@{
"ae" = "w1"
"ar" = "w1"
"bd" = "w1"
"dz" = "w1"
"cl" = "w1"
"pr" = "w1"
"eg" = "w1"
"fo" = "dk"
"gl" = "dk"
"id" = "w1"
"ke" = "w1"
"lb" = "w1"
"lk" = "w1"
"lu" = "w1"
"ma" = "w1"
"mm" = "w1"
"mt" = "w1"
"my" = "w1"
"ng" = "w1"
"qa" = "w1"
"sa" = "w1"
"sg" = "w1"
"tn" = "w1"
"ua" = "w1"
"za" = "w1"
"ao" = "w1"
"bh" = "w1"
"ba" = "w1"
"bw" = "w1"
"cr" = "br"
"cy" = "w1"
"do" = "br"
"ec" = "br"
"sv" = "br"
"gt" = "br"
"hn" = "br"
"jm" = "w1"
"mv" = "w1"
"mu" = "w1"
"ni" = "br"
"pa" = "br"
"py" = "br"
"tt" = "br"
"uy" = "br"
"zw" = "w1"
}
"mapNetworkSettings" = [PSCustomObject]@{
}
"AddHostDnsServersToNatContainers" = $false
"TraefikUseDnsNameAsHostName" = $false
"TreatWarningsAsErrors" = @()
"PartnerTelemetryConnectionString" = ""
"MicrosoftTelemetryConnectionString" = "InstrumentationKey=5b44407e-9750-4a07-abe9-30c3b853821b;IngestionEndpoint=https://southcentralus-0.in.applicationinsights.azure.com/"
"SendExtendedTelemetryToMicrosoft" = $false
"TraefikImage" = "tobiasfenster/traefik-for-windows:v1.7.34"
"ObjectIdForInternalUse" = 88123
"WinRmCredentials" = $null
"WarningPreference" = "SilentlyContinue"
"UseNewFormatForGetBcContainerAppInfo" = $false
"NoOfSecondsToSleepAfterPublishBcContainerApp" = 1
"RenewClientContextBetweenTests" = $false
}
if ($isInsider) {
$bcContainerHelperConfig.genericImageName = 'mcr.microsoft.com/businesscentral:{0}-dev'
$bcContainerHelperConfig.genericImageNameFilesOnly = 'mcr.microsoft.com/businesscentral:{0}-filesonly-dev'
}
if ($bcContainerHelperConfigFile -notcontains "C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json") {
$bcContainerHelperConfigFile = @("C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json")+$bcContainerHelperConfigFile
}
$bcContainerHelperConfigFile | ForEach-Object {
$configFile = $_
if (Test-Path $configFile) {
try {
$savedConfig = Get-Content $configFile | ConvertFrom-Json
if ("$savedConfig") {
$keys = $bcContainerHelperConfig.Keys | % { $_ }
$keys | ForEach-Object {
if ($savedConfig.PSObject.Properties.Name -eq "$_") {
if (!$silent) {
Write-Host "Setting $_ = $($savedConfig."$_")"
}
$bcContainerHelperConfig."$_" = $savedConfig."$_"
}
}
}
}
catch {
throw "Error reading configuration file $configFile, cannot import module."
}
}
}
if ($isInsideContainer) {
$bcContainerHelperConfig.usePsSession = $true
try {
$myinspect = docker inspect $(hostname) | ConvertFrom-Json
$bcContainerHelperConfig.WinRmCredentials = New-Object PSCredential -ArgumentList 'WinRmUser', (ConvertTo-SecureString -string "P@ss$($myinspect.Id.SubString(48))" -AsPlainText -Force)
}
catch {}
}
if ($bcContainerHelperConfig.UseVolumes) {
if ($bcContainerHelperConfig.bcartifactsCacheFolder -eq "") {
$bcContainerHelperConfig.bcartifactsCacheFolder = "bcartifacts.cache"
}
if ($bcContainerHelperConfig.hostHelperFolder -eq "") {
$bcContainerHelperConfig.hostHelperFolder = "hostHelperFolder"
}
$bcContainerHelperConfig.useVolumeForMyFolder = $false
}
else {
if ($bcContainerHelperConfig.bcartifactsCacheFolder -eq "") {
$bcContainerHelperConfig.bcartifactsCacheFolder = "c:\bcartifacts.cache"
}
if ($bcContainerHelperConfig.hostHelperFolder -eq "") {
$bcContainerHelperConfig.hostHelperFolder = "C:\ProgramData\BcContainerHelper"
}
}
Export-ModuleMember -Variable bcContainerHelperConfig
}
return $bcContainerHelperConfig
}
Get-ContainerHelperConfig | Out-Null
$hypervState = ""
function Get-HypervState {
if ($isAdministrator -and $hypervState -eq "") {
@ -200,35 +40,6 @@ function Get-HypervState {
return $script:hypervState
}
$Source = @"
using System.Net;
public class TimeoutWebClient : WebClient
{
int theTimeout;
public TimeoutWebClient(int timeout)
{
theTimeout = timeout;
}
protected override WebRequest GetWebRequest(System.Uri address)
{
WebRequest request = base.GetWebRequest(address);
if (request != null)
{
request.Timeout = theTimeout;
}
return request;
}
}
"@;
try {
Add-Type -TypeDefinition $Source -Language CSharp -WarningAction SilentlyContinue | Out-Null
}
catch {}
function VolumeOrPath {
Param(
[string] $path
@ -247,67 +58,41 @@ function VolumeOrPath {
}
}
$bcartifactsCacheFolder = VolumeOrPath $bcContainerHelperConfig.bcartifactsCacheFolder
$hostHelperFolder = VolumeOrPath $bcContainerHelperConfig.HostHelperFolder
$extensionsFolder = Join-Path $hostHelperFolder "Extensions"
$containerHelperFolder = $bcContainerHelperConfig.ContainerHelperFolder
$bcContainerHelperConfig.bcartifactsCacheFolder = VolumeOrPath $bcContainerHelperConfig.bcartifactsCacheFolder
$bcContainerHelperConfig.hostHelperFolder = VolumeOrPath $bcContainerHelperConfig.HostHelperFolder
$ENV:DOCKER_SCAN_SUGGEST = "$($bcContainerHelperConfig.DOCKER_SCAN_SUGGEST)".ToLowerInvariant()
$sessions = @{}
$extensionsFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions"
if (!(Test-Path -Path $extensionsFolder -PathType Container)) {
if (!(Test-Path -Path $hostHelperFolder -PathType Container)) {
New-Item -Path $hostHelperFolder -ItemType Container -Force | Out-Null
if (!(Test-Path -Path $bcContainerHelperConfig.hostHelperFolder -PathType Container)) {
New-Item -Path $bcContainerHelperConfig.hostHelperFolder -ItemType Container -Force | Out-Null
}
New-Item -Path $extensionsFolder -ItemType Container -Force | Out-Null
if (!$isAdministrator) {
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($myUsername,'FullControl', 3, 'InheritOnly', 'Allow')
$acl = [System.IO.Directory]::GetAccessControl($hostHelperFolder)
$acl = [System.IO.Directory]::GetAccessControl($bcContainerHelperConfig.hostHelperFolder)
$acl.AddAccessRule($rule)
[System.IO.Directory]::SetAccessControl($hostHelperFolder,$acl)
[System.IO.Directory]::SetAccessControl($bcContainerHelperConfig.hostHelperFolder,$acl)
}
}
$telemetry = @{
"Assembly" = $null
"PartnerClient" = $null
"MicrosoftClient" = $null
"CorrelationId" = ""
"TopId" = ""
"Debug" = $false
}
try {
if (($bcContainerHelperConfig.MicrosoftTelemetryConnectionString) -and !$Silent) {
Write-Host -ForegroundColor Green 'BcContainerHelper emits usage statistics telemetry to Microsoft'
}
$dllPath = "C:\ProgramData\BcContainerHelper\Microsoft.ApplicationInsights.2.15.0.44797.dll"
if (-not (Test-Path $dllPath)) {
Copy-Item (Join-Path $PSScriptRoot "Microsoft.ApplicationInsights.dll") -Destination $dllPath
}
$telemetry.Assembly = [System.Reflection.Assembly]::LoadFrom($dllPath)
} catch {
if (!$Silent) {
Write-Host -ForegroundColor Yellow "Unable to load ApplicationInsights.dll"
}
}
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
. (Join-Path $PSScriptRoot "TelemetryHelper.ps1")
if ($ExportTelemetryFunctions) {
Export-ModuleMember -Function RegisterTelemetryScope
Export-ModuleMember -Function InitTelemetryScope
Export-ModuleMember -Function AddTelemetryProperty
Export-ModuleMember -Function TrackTrace
Export-ModuleMember -Function TrackException
}
. (Join-Path $PSScriptRoot "Check-BcContainerHelperPermissions.ps1")
if (!$silent) {
Check-BcContainerHelperPermissions -Silent
}
Import-Module (Join-Path $PSScriptRoot 'BC.CommonHelper.psm1') -DisableNameChecking -Global
Import-Module (Join-Path $PSScriptRoot 'BC.ArtifactsHelper.psm1') -DisableNameChecking -Global
Import-Module (Join-Path $PSScriptRoot 'BC.AuthHelper.psm1') -DisableNameChecking -Global
Import-Module (Join-Path $PSScriptRoot 'BC.AppSourceHelper.psm1') -DisableNameChecking -Global
Import-Module (Join-Path $PSScriptRoot 'BC.ALGoHelper.psm1') -DisableNameChecking -Global
Import-Module (Join-Path $PSScriptRoot 'BC.SaasHelper.psm1') -DisableNameChecking -Global
Import-Module (Join-Path $PSScriptRoot 'BC.NuGetHelper.psm1') -DisableNameChecking -Global
# Container Info functions
. (Join-Path $PSScriptRoot "ContainerInfo\Get-NavContainerNavVersion.ps1")
. (Join-Path $PSScriptRoot "ContainerInfo\Get-NavContainerPlatformVersion.ps1")
@ -377,10 +162,10 @@ if (!$silent) {
. (Join-Path $PSScriptRoot "ObjectHandling\Invoke-NavContainerCodeunit.ps1")
# AL-Go for GitHub functions
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAuthContext.ps1")
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAppSourceContext.ps1")
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoStorageContext.ps1")
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoNuGetContext.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAuthContext.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAppSourceContext.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoStorageContext.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoNuGetContext.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepo.ps1")
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepoWizard.ps1")
@ -440,34 +225,34 @@ if (!$silent) {
. (Join-Path $PSScriptRoot "AzureAD\Create-AadUsersInNavContainer.ps1")
# AppSource specific functions
. (Join-Path $PSScriptRoot "AppSource\Invoke-IngestionAPI.ps1")
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceProduct.ps1")
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceSubmission.ps1")
. (Join-Path $PSScriptRoot "AppSource\New-AppSourceSubmission.ps1")
. (Join-Path $PSScriptRoot "AppSource\Promote-AppSourceSubmission.ps1")
. (Join-Path $PSScriptRoot "AppSource\Cancel-AppSourceSubmission.ps1")
#. (Join-Path $PSScriptRoot "AppSource\Invoke-IngestionAPI.ps1")
#. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceProduct.ps1")
#. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceSubmission.ps1")
#. (Join-Path $PSScriptRoot "AppSource\New-AppSourceSubmission.ps1")
#. (Join-Path $PSScriptRoot "AppSource\Promote-AppSourceSubmission.ps1")
#. (Join-Path $PSScriptRoot "AppSource\Cancel-AppSourceSubmission.ps1")
# Nuget specific functions
. (Join-Path $PSScriptRoot "NuGet\New-BcNuGetPackage.ps1")
. (Join-Path $PSScriptRoot "NuGet\Get-BcNuGetPackage.ps1")
. (Join-Path $PSScriptRoot "NuGet\Push-BcNuGetPackage.ps1")
. (Join-Path $PSScriptRoot "NuGet\Publish-BcNuGetPackageToContainer.ps1")
#. (Join-Path $PSScriptRoot "NuGet\New-BcNuGetPackage.ps1")
#. (Join-Path $PSScriptRoot "NuGet\Get-BcNuGetPackage.ps1")
#. (Join-Path $PSScriptRoot "NuGet\Push-BcNuGetPackage.ps1")
#. (Join-Path $PSScriptRoot "NuGet\Publish-BcNuGetPackageToContainer.ps1")
# BC SaaS specific functions
. (Join-Path $PSScriptRoot "BcSaaS\New-BcAuthContext.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Renew-BcAuthContext.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Get-BcEnvironments.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Get-BcPublishedApps.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Get-BcInstalledExtensions.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Install-BcAppFromAppSource")
. (Join-Path $PSScriptRoot "BcSaaS\Publish-PerTenantExtensionApps.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\New-BcEnvironment.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Remove-BcEnvironment.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Set-BcEnvironmentApplicationInsightsKey.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Get-BcDatabaseExportHistory.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\New-BcDatabaseExport.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Get-BcScheduledUpgrade.ps1")
. (Join-Path $PSScriptRoot "BcSaaS\Reschedule-BcUpgrade.ps1")
#. (Join-Path $PSScriptRoot "SaaS\New-BcAuthContext.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Renew-BcAuthContext.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Get-BcEnvironments.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Get-BcPublishedApps.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Get-BcInstalledExtensions.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Install-BcAppFromAppSource")
#. (Join-Path $PSScriptRoot "SaaS\Publish-PerTenantExtensionApps.ps1")
#. (Join-Path $PSScriptRoot "SaaS\New-BcEnvironment.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Remove-BcEnvironment.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Set-BcEnvironmentApplicationInsightsKey.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Get-BcDatabaseExportHistory.ps1")
#. (Join-Path $PSScriptRoot "SaaS\New-BcDatabaseExport.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Get-BcScheduledUpgrade.ps1")
#. (Join-Path $PSScriptRoot "SaaS\Reschedule-BcUpgrade.ps1")
# Azure VM specific functions
. (Join-Path $PSScriptRoot "AzureVM\Replace-NavServerContainer.ps1")
@ -475,13 +260,7 @@ if (!$silent) {
. (Join-Path $PSScriptRoot "AzureVM\Renew-LetsEncryptCertificate.ps1")
# Misc functions
. (Join-Path $PSScriptRoot "Misc\New-DesktopShortcut.ps1")
. (Join-Path $PSScriptRoot "Misc\Remove-DesktopShortcut.ps1")
. (Join-Path $PSScriptRoot "Misc\Write-NavContainerHelperWelcomeText.ps1")
. (Join-Path $PSScriptRoot "Misc\Download-File.ps1")
. (Join-Path $PSScriptRoot "Misc\Download-Artifacts.ps1")
. (Join-Path $PSScriptRoot "Misc\Get-BcArtifactUrl.ps1")
. (Join-Path $PSScriptRoot "Misc\Get-NavArtifactUrl.ps1")
. (Join-Path $PSScriptRoot "Misc\Get-LocaleFromCountry.ps1")
. (Join-Path $PSScriptRoot "Misc\Get-NavVersionFromVersionInfo.ps1")
. (Join-Path $PSScriptRoot "Misc\Copy-FileFromNavContainer.ps1")
@ -490,12 +269,19 @@ if (!$silent) {
. (Join-Path $PSScriptRoot "Misc\Set-BcContainerFeatureKeys.ps1")
. (Join-Path $PSScriptRoot "Misc\Import-PfxCertificateToNavContainer.ps1")
. (Join-Path $PSScriptRoot "Misc\Import-CertificateToNavContainer.ps1")
. (Join-Path $PSScriptRoot "Misc\Get-PlainText.ps1")
. (Join-Path $PSScriptRoot "Misc\ConvertTo-HashTable.ps1")
. (Join-Path $PSScriptRoot "Misc\ConvertTo-OrderedDictionary.ps1")
. (Join-Path $PSScriptRoot "Misc\ConvertTo-GitHubGoCredentials.ps1")
. (Join-Path $PSScriptRoot "Misc\Invoke-gh.ps1")
. (Join-Path $PSScriptRoot "Misc\Invoke-git.ps1")
#. (Join-Path $PSScriptRoot "Artifacts\Download-Artifacts.ps1")
#. (Join-Path $PSScriptRoot "Artifacts\Get-BcArtifactUrl.ps1")
#. (Join-Path $PSScriptRoot "Artifacts\Get-NavArtifactUrl.ps1")
#. (Join-Path $PSScriptRoot "Common\Download-File.ps1")
#. (Join-Path $PSScriptRoot "Common\New-DesktopShortcut.ps1")
#. (Join-Path $PSScriptRoot "Common\Remove-DesktopShortcut.ps1")
#. (Join-Path $PSScriptRoot "Common\ConvertTo-HashTable.ps1")
#. (Join-Path $PSScriptRoot "Common\Get-PlainText.ps1")
#. (Join-Path $PSScriptRoot "Common\Invoke-gh.ps1")
#. (Join-Path $PSScriptRoot "Common\Invoke-git.ps1")
#. (Join-Path $PSScriptRoot "Common\ConvertTo-OrderedDictionary.ps1")
# Company Handling functions
. (Join-Path $PSScriptRoot "CompanyHandling\Copy-CompanyInNavContainer.ps1")

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

@ -39,18 +39,18 @@ function Check-BcContainerHelperPermissions {
# Check access to C:\ProgramData\BcContainerHelper
if (!$silent) {
Write-Host "Checking permissions to $hostHelperFolder"
Write-Host "Checking permissions to $($bcContainerHelperConfig.hostHelperFolder)"
}
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($myUsername,'FullControl', 3, 'InheritOnly', 'Allow')
$access = [System.IO.Directory]::GetAccessControl($hostHelperFolder).Access |
$access = [System.IO.Directory]::GetAccessControl($bcContainerHelperConfig.hostHelperFolder).Access |
Where-Object { $_.IdentityReference -eq $rule.IdentityReference -and $_.FileSystemRights -eq $rule.FileSystemRights -and $_.AccessControlType -eq $rule.AccessControlType -and $_.InheritanceFlags -eq $rule.InheritanceFlags }
if ($access) {
if (!$silent) {
Write-Host -ForegroundColor Green "$myUsername has the right permissions to $hostHelperFolder"
Write-Host -ForegroundColor Green "$myUsername has the right permissions to $($bcContainerHelperConfig.hostHelperFolder)"
}
} else {
Write-Host -ForegroundColor Red "$myUsername does NOT have Full Control to $hostHelperFolder and all subfolders"
Write-Host -ForegroundColor Red "$myUsername does NOT have Full Control to $($bcContainerHelperConfig.hostHelperFolder) and all subfolders"
if (!$Fix) {
Write-Host -ForegroundColor Red "You need to run as administrator or you can run Check-BcContainerHelperPermissions -Fix to fix permissions"
} else {
@ -67,7 +67,7 @@ function Check-BcContainerHelperPermissions {
EXIT 1
}
}
$exitCode = (Start-Process powershell -ArgumentList "-command & {$scriptblock} -myUsername '$myUsername' -hostHelperFolder '$hostHelperFolder'" -Verb RunAs -wait -WindowStyle Hidden -PassThru).ExitCode
$exitCode = (Start-Process powershell -ArgumentList "-command & {$scriptblock} -myUsername '$myUsername' -hostHelperFolder '$($bcContainerHelperConfig.hostHelperFolder)'" -Verb RunAs -wait -WindowStyle Hidden -PassThru).ExitCode
if ($exitcode -eq 0) {
Write-Host -ForegroundColor Green "Permissions successfully added"
} else {

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

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

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

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

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

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

@ -66,7 +66,7 @@ function New-DesktopShortcut {
Remove-Item $filename -force
}
$tempfilename = Join-Path $containerHelperFolder "$([Guid]::NewGuid().ToString()).lnk"
$tempfilename = Join-Path $bcContainerHelperConfig.hostHelperFolder "$([Guid]::NewGuid().ToString()).lnk"
$Shell = New-object -comobject WScript.Shell
$Shortcut = $Shell.CreateShortcut($tempfilename)
$Shortcut.TargetPath = $TargetPath

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

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

@ -55,12 +55,12 @@ try {
return
}
if ($packageIdSpecified) {
$configPackage = Join-Path $hosthelperfolder "Extensions\$containerName\$($packageId).rapidstart"
$configPackage = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\$($packageId).rapidstart"
}
else {
$nameArr = "$([System.IO.Path]::GetFileNameWithoutExtension($containerConfigPackage))".Split('.')
$packageId = "$($nameArr[2]).$($nameArr[3]).$($nameArr[4])"
$configPackage = Join-Path $hosthelperfolder "Extensions\$containerName\$($packageId).rapidstart"
$configPackage = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\$($packageId).rapidstart"
}
if (Test-Path $configPackage) {
Remove-Item $configPackage -Force

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

@ -54,7 +54,7 @@ try {
}
if ($caches.Contains('all') -or $caches.Contains('bcartifacts') -or $caches.Contains('sandboxartifacts')) {
$bcartifactsCacheFolder = $bcartifactsCacheFolder
$bcartifactsCacheFolder = $bcContainerHelperConfig.bcartifactsCacheFolder
$subfolder = "*"
if (!($caches.Contains('all') -or $caches.Contains('bcartifacts'))) {
$subfolder = "sandbox"
@ -108,7 +108,7 @@ try {
}
$folders | ForEach-Object {
$folder = Join-Path $hostHelperFolder $_
$folder = Join-Path $bcContainerHelperConfig.hostHelperFolder $_
Get-Item $folder -ErrorAction SilentlyContinue | ?{ $_.PSIsContainer } | ForEach-Object {
Write-Host "Removing Cache $($_.FullName)"
[System.IO.Directory]::Delete($_.FullName, $true)

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

@ -25,7 +25,7 @@ function Import-BcContainerLicense {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try {
$containerLicenseFile = Join-Path $ExtensionsFolder "$containerName\my\license$([System.IO.Path]::GetExtension($licenseFile.Split('?')[0]))"
$containerLicenseFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\my\license$([System.IO.Path]::GetExtension($licenseFile.Split('?')[0]))"
if ($licensefile.StartsWith("https://", "OrdinalIgnoreCase") -or $licensefile.StartsWith("http://", "OrdinalIgnoreCase")) {
Write-Host "Downloading license file '$($licensefile.Split('?')[0])' to container"
Download-File -sourceUrl $licensefile -destinationFile $containerlicensefile

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

@ -25,7 +25,7 @@ function Invoke-ScriptInBcContainer {
[bool] $useSession = $bcContainerHelperConfig.usePsSession
)
$file = Join-Path $hostHelperFolder ([GUID]::NewGuid().Tostring()+'.ps1')
$file = Join-Path $bcContainerHelperConfig.hostHelperFolder ([GUID]::NewGuid().Tostring()+'.ps1')
$containerFile = ""
if (!$useSession) {
if ($isInsideContainer) {

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

@ -903,7 +903,7 @@ try {
$parameters += '--no-healthcheck'
}
$containerFolder = Join-Path $ExtensionsFolder $containerName
$containerFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName"
Remove-Item -Path $containerFolder -Force -Recurse -ErrorAction Ignore
New-Item -Path $containerFolder -ItemType Directory -ErrorAction Ignore | Out-Null
@ -1153,7 +1153,7 @@ try {
if ("$dvdPath" -eq "" -and "$artifactUrl" -eq "") {
# Extract files from image if not already done
$dvdPath = Join-Path $containerHelperFolder "$($NavVersion)-Files"
$dvdPath = Join-Path $bcContainerHelperConfig.hostHelperFolder "$($NavVersion)-Files"
if (!(Test-Path "$dvdPath\allextracted")) {
Extract-FilesFromBcContainerImage -imageName $imageName -path $dvdPath -force
@ -1413,7 +1413,7 @@ try {
$restoreBakFolder = $false
if ($bakFolder) {
if (!$bakFolder.Contains('\')) {
$bakFolder = Join-Path $containerHelperFolder "$bcStyle-$($NavVersion)-bakFolders\$bakFolder"
$bakFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "$bcStyle-$($NavVersion)-bakFolders\$bakFolder"
}
if (Test-Path (Join-Path $bakFolder "*.bak")) {
$restoreBakFolder = $true
@ -1438,13 +1438,13 @@ try {
throw "Database backup $bakFile doesn't exist"
}
if (-not $bakFile.StartsWith($hostHelperFolder, [StringComparison]::OrdinalIgnoreCase)) {
if (-not $bakFile.StartsWith($bcContainerHelperConfig.hostHelperFolder, [StringComparison]::OrdinalIgnoreCase)) {
$containerBakFile = Join-Path $containerFolder "database.bak"
Copy-Item -Path $bakFile -Destination $containerBakFile
$bakFile = $containerBakFile
}
if ($bakFile.StartsWith($hostHelperFolder, [StringComparison]::OrdinalIgnoreCase)) {
$bakFile = "$containerHelperFolder$($bakFile.Substring($hostHelperFolder.Length))"
if ($bakFile.StartsWith($bcContainerHelperConfig.hostHelperFolder, [StringComparison]::OrdinalIgnoreCase)) {
$bakFile = "$($bcContainerHelperConfig.containerHelperFolder)$($bakFile.Substring($bcContainerHelperConfig.hostHelperFolder.Length))"
}
$parameters += "--env bakfile=$bakFile"
}
@ -1508,7 +1508,7 @@ try {
"--env locale=$locale",
"--env databaseServer=""$databaseServer""",
"--env databaseInstance=""$databaseInstance""",
(getVolumeMountParameter -volumes $allVolumes -hostPath $hostHelperFolder -containerPath $containerHelperFolder),
(getVolumeMountParameter -volumes $allVolumes -hostPath $bcContainerHelperConfig.hostHelperFolder -containerPath $bcContainerHelperConfig.containerHelperFolder),
(getVolumeMountParameter -volumes $allVolumes -hostPath $myFolder -containerPath "C:\Run\my"),
"--isolation $isolation",
"--restart $restart"
@ -1744,11 +1744,11 @@ if ($multitenant) {
}
if ($useTraefik) {
$restPart = "/${containerName}rest"
$soapPart = "/${containerName}soap"
$devPart = "/${containerName}dev"
$snapPart = "/${containerName}snap"
$dlPart = "/${containerName}dl"
$restPart = "/$($containerName)rest"
$soapPart = "/$($containerName)soap"
$devPart = "/$($containerName)dev"
$snapPart = "/$($containerName)snap"
$dlPart = "/$($containerName)dl"
$webclientPart = "/$containerName"
$baseUrl = "https://$publicDnsName"
@ -1774,11 +1774,11 @@ if ($multitenant) {
}
$webclientRule="PathPrefix:$webclientPart"
$soapRule="PathPrefix:${soapPart};ReplacePathRegex: ^${soapPart}(.*) /$ServerInstance`$1"
$restRule="PathPrefix:${restPart};ReplacePathRegex: ^${restPart}(.*) /$ServerInstance`$1"
$devRule="PathPrefix:${devPart};ReplacePathRegex: ^${devPart}(.*) /$ServerInstance`$1"
$snapRule="PathPrefix:${snapPart};ReplacePathRegex: ^${snapPart}(.*) /$ServerInstance`$1"
$dlRule="PathPrefixStrip:${dlPart}"
$soapRule="PathPrefix:$($soapPart);ReplacePathRegex: ^$($soapPart)(.*) /$ServerInstance`$1"
$restRule="PathPrefix:$($restPart);ReplacePathRegex: ^$($restPart)(.*) /$ServerInstance`$1"
$devRule="PathPrefix:$($devPart);ReplacePathRegex: ^$($devPart)(.*) /$ServerInstance`$1"
$snapRule="PathPrefix:$($snapPart);ReplacePathRegex: ^$($snapPart)(.*) /$ServerInstance`$1"
$dlRule="PathPrefixStrip:$($dlPart)"
$webPort = "443"
if ($forceHttpWithTraefik) {
@ -1821,7 +1821,7 @@ if (-not `$restartingInstance) {
") | Add-Content -Path "$myfolder\AdditionalOutput.ps1"
}
$containerContainerFolder = Join-Path $containerHelperFolder "Extensions\$containerName"
$containerContainerFolder = Join-Path $bcContainerHelperConfig.ContainerHelperFolder "Extensions\$containerName"
("
if (-not `$restartingInstance) {
@ -1915,7 +1915,7 @@ if (-not `$restartingInstance) {
)
if ("$databaseServer" -ne "" -and $bcContainerHelperConfig.useSharedEncryptionKeys -and !$encryptionKeyExists) {
$sharedEncryptionKeyFile = Join-Path $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]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($databaseCredential.Password))))).ForEach{$_.ToString("X2")})\DynamicsNAV-v$($version.Major).key"
if (Test-Path $sharedEncryptionKeyFile) {
Write-Host "Using Shared Encryption Key file"
Copy-Item -Path $sharedEncryptionKeyFile -Destination $containerEncryptionKeyFile
@ -2172,7 +2172,7 @@ if (-not `$restartingInstance) {
# Include newsyntax if NAV Version is greater than NAV 2017
if ($includeCSide) {
$originalFolder = Join-Path $ExtensionsFolder "Original-$navversion"
$originalFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion"
if (!(Test-Path $originalFolder)) {
# Export base objects
Export-NavContainerObjects -containerName $containerName `
@ -2184,7 +2184,7 @@ if (-not `$restartingInstance) {
}
if ($version.Major -ge 15) {
$alFolder = Join-Path $ExtensionsFolder "Original-$navversion-al"
$alFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion-al"
if (!(Test-Path $alFolder) -or (Get-ChildItem -Path $alFolder -Recurse | Measure-Object).Count -eq 0) {
if (!(Test-Path $alFolder)) {
New-Item $alFolder -ItemType Directory | Out-Null
@ -2206,7 +2206,7 @@ if (-not `$restartingInstance) {
} -argumentList (Get-BCContainerPath -containerName $containerName -path $alFolder), $devCountry
}
else {
$appFile = Join-Path $ExtensionsFolder "BaseApp-$navVersion.app"
$appFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\BaseApp-$navVersion.app"
$appName = "Base Application"
if ($version -lt [Version]("15.0.35659.0")) {
$appName = "BaseApp"
@ -2217,7 +2217,7 @@ if (-not `$restartingInstance) {
-appFile $appFile `
-credential $credential
$appFolder = Join-Path $ExtensionsFolder "BaseApp-$navVersion"
$appFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\BaseApp-$navVersion"
Extract-AppFileToFolder -appFilename $appFile -appFolder $appFolder
'layout','src','translations' | ForEach-Object {
@ -2232,7 +2232,7 @@ if (-not `$restartingInstance) {
}
}
elseif ($version.Major -gt 10) {
$originalFolder = Join-Path $ExtensionsFolder "Original-$navversion-newsyntax"
$originalFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion-newsyntax"
if (!(Test-Path $originalFolder)) {
# Export base objects as new syntax
Export-NavContainerObjects -containerName $containerName `
@ -2242,7 +2242,7 @@ if (-not `$restartingInstance) {
-ExportTo 'txt folder (new syntax)'
}
if ($version.Major -ge 14 -and $includeAL) {
$alFolder = Join-Path $ExtensionsFolder "Original-$navversion-al"
$alFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion-al"
if ($runTxt2AlInContainer -ne $containerName) {
Write-Host "Using container $runTxt2AlInContainer to convert .txt to .al"
if (Test-Path $alFolder) {
@ -2251,7 +2251,7 @@ if (-not `$restartingInstance) {
}
}
if (!(Test-Path $alFolder)) {
$dotNetAddInsPackage = Join-Path $ExtensionsFolder "$containerName\coredotnetaddins.al"
$dotNetAddInsPackage = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\coredotnetaddins.al"
Copy-Item -Path (Join-Path $PSScriptRoot "..\ObjectHandling\coredotnetaddins.al") -Destination $dotNetAddInsPackage -Force
if ($runTxt2AlInContainer -ne $containerName) {
Write-Host "Using container $runTxt2AlInContainer to convert .txt to .al"

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

@ -421,7 +421,7 @@ try {
}
Write-Host "Using $isolation isolation"
$downloadsPath = $bcartifactsCacheFolder
$downloadsPath = $bcContainerHelperConfig.bcartifactsCacheFolder
if (!(Test-Path $downloadsPath)) {
New-Item $downloadsPath -ItemType Directory | Out-Null
}

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

@ -43,7 +43,7 @@ try {
if ($dotidx -eq -1) { $dotidx = $hostname.Length }
$tenantHostname = $hostname.insert($dotidx,"-*")
$containerFolder = Join-Path $ExtensionsFolder $containerName
$containerFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName"
$allVolumes = @(docker volume ls --format "{{.Mountpoint}}|{{.Name}}")
$myVolumeName = "$containerName-my"
$myVolume = $allVolumes | Where-Object { $_ -like "*|$myVolumeName" }

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

@ -34,8 +34,7 @@ function Set-BcContainerKeyVaultAadAppAndCertificate {
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try {
$ExtensionsFolder = Join-Path $hosthelperfolder "Extensions"
$sharedPfxFile = Join-Path $ExtensionsFolder "$containerName\my\$([GUID]::NewGuid().ToString()).pfx"
$sharedPfxFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\my\$([GUID]::NewGuid().ToString()).pfx"
$removeSharedPfxFile = $true
if ($pfxFile -like "https://*" -or $pfxFile -like "http://*") {
Write-Host "Downloading certificate file to container"

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

@ -16,7 +16,7 @@ function Add-DomainToTraefikConfig {
Write-Host "Looking up for dns Name '$PublicDnsName' in Traefik configuration . . ."
$tomlFile = (Join-Path -Path $hostHelperFolder -ChildPath "traefikforbc\config\traefik.toml")
$tomlFile = (Join-Path -Path $bcContainerHelperConfig.hostHelperFolder -ChildPath "traefikforbc\config\traefik.toml")
if (-not (Test-Path -Path $tomlFile)) {
throw "Traefik configuration could not been found! Please call Setup-TraefikContainerForBcContainers before using -useTraefik"
}

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

@ -1,6 +1,6 @@
$healthcheckurl = ("http://localhost/" + $env:webserverinstance + "/")
try {
$result = Invoke-WebRequest -Uri "${healthcheckurl}Health/System" -UseBasicParsing -TimeoutSec 10
$result = Invoke-WebRequest -Uri "$($healthcheckurl)Health/System" -UseBasicParsing -TimeoutSec 10
if ($result.StatusCode -eq 200 -and ((ConvertFrom-Json $result.Content).result)) {
# Web Client Health Check Endpoint will test Web Client, Service Tier and Database Connection
exit 0

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

@ -20,7 +20,7 @@ public static class Dummy {
$healthcheckurl = ("https://localhost/" + $env:webserverinstance + "/")
try {
$result = Invoke-WebRequest -Uri "${healthcheckurl}Health/System" -UseBasicParsing -TimeoutSec 10
$result = Invoke-WebRequest -Uri "($healthcheckurl)Health/System" -UseBasicParsing -TimeoutSec 10
if ($result.StatusCode -eq 200 -and ((ConvertFrom-Json $result.Content).result)) {
# Web Client Health Check Endpoint will test Web Client, Service Tier and Database Connection
exit 0

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

@ -27,7 +27,7 @@ $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -paramet
try {
Write-Host "Getting event log for $containername"
$eventLogFolder = Join-Path $hostHelperFolder "EventLogs"
$eventLogFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "EventLogs"
if (!(Test-Path $eventLogFolder)) {
New-Item $eventLogFolder -ItemType Directory | Out-Null
}

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

@ -50,7 +50,7 @@ try {
$repository = "$registry/$repository"
$registry = "registry.hub.docker.com"
$token = ($webclient.DownloadString("https://auth.docker.io/token?scope=repository:${repository}:pull&service=registry.docker.io") | ConvertFrom-Json).token
$token = ($webclient.DownloadString("https://auth.docker.io/token?scope=repository:$($repository):pull&service=registry.docker.io") | ConvertFrom-Json).token
$authorization = "Bearer $token"
}

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

@ -50,7 +50,7 @@ try {
$repository = "$registry/$repository"
$registry = "registry.hub.docker.com"
$token = ($webclient.DownloadString("https://auth.docker.io/token?scope=repository:${repository}:pull&service=registry.docker.io") | ConvertFrom-Json).token
$token = ($webclient.DownloadString("https://auth.docker.io/token?scope=repository:$($repository):pull&service=registry.docker.io") | ConvertFrom-Json).token
$authorization = "Bearer $token"
}
@ -63,10 +63,10 @@ try {
try {
$url = "https://$registry/v2/$repository/tags/list"
if ($pageSize -gt 0) {
$sometags = ($webclient.DownloadString("${url}?n=$pageSize") | ConvertFrom-Json)
$sometags = ($webclient.DownloadString("$($url)?n=$pageSize") | ConvertFrom-Json)
$tags = $sometags
while ($sometags.tags.Count -gt 0) {
$sometags = ($webclient.DownloadString("${url}?n=$pageSize&last=$($sometags.tags[$sometags.tags.Count-1])") | ConvertFrom-Json)
$sometags = ($webclient.DownloadString("$($url)?n=$pageSize&last=$($sometags.tags[$sometags.tags.Count-1])") | ConvertFrom-Json)
$tags.tags += $sometags.tags
}
} else {

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

@ -1,7 +1,17 @@
Param(
[switch] $skipContainerHelperCheck
[switch] $skipContainerHelperCheck = $true
)
# Single/Multi project
# Upload apps
# Starting version number
$ErrorActionPreference = "stop"
if ($true) {
@ -508,7 +518,7 @@ $Step.Intro {
$doit = Enter-Value `
-title " " -doNotClearHost `
-description "AL-Go for GitHub is plug-and-play DevOps. Easy to setup, easy to use.`nHaving said that, there are many ways to configure AL-Go for GitHub, this wizard takes you through many of the options and help you define the right settings.`n`nFirst thing you need to do, is to determine the structure of your repositories.`nThe recommendation is that apps, which are shipped together share the same repository with their test apps.`nIf you have ""common"" apps, which are used by multiple projects, we recommend that these are placed in a ""common"" repository.`nYou should start by setting up the repository for your ""common"" apps and after that, setup the repository with a dependency to the first repository." `
-description "AL-Go for GitHub is plug-and-play DevOps. Easy to setup, easy to use.`n`nHaving said that, there are many ways to configure AL-Go for GitHub, this wizard takes you through many of the options and help you define the right settings.`n`nFirst thing you need to do, is to determine the structure of your repositories.`nThe recommendation is that apps, which are shipped together share the same repository with their test apps.`nIf you have ""common"" apps, which are used by multiple projects, we recommend that these are placed in a ""common"" repository.`nYou should start by setting up the repository for your ""common"" apps and after that, setup the repository with a dependency to the first repository." `
-options @("Y","N") `
-question "Please select Y to start the AL-Go for GitHub setup wizard"
@ -534,7 +544,7 @@ $Step.Org {
__/ |
|___/
'@ `
-Description "Every GitHub user has a personal account and can be a member of any number of organizations. You can place your repository in a personal account or an organizational account.`nMicrosoft recommends placing your repository in an organizational account in order to be able to share GitHub agents, secrets and other things between the repositories`n`nVisit |https://github.com/settings/organizations| to see which organizations you are part of`n`nUnder which organization do you want to place your repositories?" `
-Description "Every GitHub user has a personal account and can be a member of any number of organizations. You can place your repository in a personal account or an organizational account. Microsoft recommends placing your repository in an organizational account in order to be able to share GitHub agents, secrets and other things between the repositories`n`nVisit |https://github.com/settings/organizations| to see which organizations you are part of`n`nUnder which organization do you want to place your repositories?" `
-question "Please specify the name of your GitHub organization" `
-previousStep `
-default $settings.Org `
@ -747,8 +757,8 @@ $Step.VersioningMethod {
__/ |
|___/
'@ `
-Description "The format of version numbers are major.minor.build.release.`nWhen building apps in AL-Go for GitHub, the Major.Minor part of the version number are read from app.json and the build.release part are calculated.`n- GitHub RUN_NUMBER is an auto-incrementing number for each workflow. The RunNumberOffset setting can be used to offset the starting value.`n- GitHub RUN_ID is an auto-incrementing number for all workflows.`n- GitHub RUN_ATTEMPT increases for every re-run of jobs.`n`nSelect the method used for calculating build and release part of your app:" `
-options ([ordered]@{"0" = "Use GitHub RUN_NUMBER.RUN_ATTEMPT (recommended)"; "1" = "Use GitHub RUN_ID.RUN_ATTEMPT"; "2" = "Use UTC datetime yyyyMMdd.hhmmss"}) `
-Description "The format of version numbers are major.minor.build.release.`nWhen building apps in AL-Go for GitHub, the Major.Minor part of the version number are read from app.json and the build.release part are calculated.`n- GitHub RUN_NUMBER is an auto-incrementing number for each workflow. The RunNumberOffset setting can be used to offset the starting value.`n- GitHub RUN_ATTEMPT increases for every re-run of jobs.`n`nSelect the method used for calculating build and release part of your app:" `
-options ([ordered]@{"0" = "Use GitHub RUN_NUMBER.RUN_ATTEMPT (recommended)"; "2" = "Use UTC datetime yyyyMMdd.hhmmss"}) `
-question "Versioning method" `
-previousStep `
-default $settings.versioningMethod

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

@ -5,10 +5,10 @@
[switch]$doNotAskForCredential
)
if (Test-Path "$hostHelperFolder\settings.ps1") {
. "$hostHelperFolder\settings.ps1"
if (Test-Path "$hostHelperFolder\aes.key") {
$key = Get-Content -Path "$hostHelperFolder\aes.key"
if (Test-Path "$($bcContainerHelperConfig.hostHelperFolder)\settings.ps1") {
. "$($bcContainerHelperConfig.hostHelperFolder)\settings.ps1"
if (Test-Path "$($bcContainerHelperConfig.hostHelperFolder)\aes.key") {
$key = Get-Content -Path "$($bcContainerHelperConfig.hostHelperFolder)\aes.key"
New-Object System.Management.Automation.PSCredential ($DefaultUserName, (ConvertTo-SecureString -String $adminPassword -Key $key))
} else {
New-Object System.Management.Automation.PSCredential ($DefaultUserName, (ConvertTo-SecureString -String $adminPassword))

78
InitializeModule.ps1 Normal file
Просмотреть файл

@ -0,0 +1,78 @@
param(
[switch] $Silent,
[string[]] $bcContainerHelperConfigFile = @(),
[string] $moduleName,
[string[]] $moduleDependencies = @()
)
Set-StrictMode -Version 2.0
$verbosePreference = "SilentlyContinue"
$warningPreference = 'Continue'
$errorActionPreference = 'Stop'
if ([intptr]::Size -eq 4) {
throw "ContainerHelper cannot run in Windows PowerShell (x86), need 64bit mode"
}
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$isAdministrator = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$isInsideContainer = ((whoami) -eq "user manager\containeradministrator")
try {
$myUsername = $currentPrincipal.Identity.Name
} catch {
$myUsername = (whoami)
}
$BcContainerHelperVersion = Get-Content (Join-Path $PSScriptRoot "Version.txt")
if (!$silent) {
Write-Host "$($moduleName.SubString(0,$moduleName.Length-5)) version $BcContainerHelperVersion"
}
$isInsider = $BcContainerHelperVersion -like "*-dev" -or $BcContainerHelperVersion -like "*-preview*"
$Source = @"
using System.Net;
public class TimeoutWebClient : WebClient
{
int theTimeout;
public TimeoutWebClient(int timeout)
{
theTimeout = timeout;
}
protected override WebRequest GetWebRequest(System.Uri address)
{
WebRequest request = base.GetWebRequest(address);
if (request != null)
{
request.Timeout = theTimeout;
}
return request;
}
}
"@;
try {
Add-Type -TypeDefinition $Source -Language CSharp -WarningAction SilentlyContinue | Out-Null
}
catch {}
if ($isInsider) {
$depVersion = "0.0"
}
else {
$depVersion = $BcContainerHelperVersion.split('-')[0]
}
$moduleDependencies | ForEach-Object {
$module = Get-Module $_
if ($module -ne $null -and $module.Version -lt [Version]$depVersion) {
Write-Error "Module $_ is already loaded in version $($module.Version). This module requires version $depVersion. Please reinstall BC modules."
}
elseif ($module -eq $null) {
Import-Module $_ -MinimumVersion $depVersion -DisableNameChecking -Global -ArgumentList $silent,$bcContainerHelperConfigFile }
}

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

@ -37,7 +37,7 @@ try {
Get-ChildItem -Path $fontsFolderPath | % { $_.Name }
}
$fontsFolder = Join-Path $extensionsFolder "$containerName\Fonts"
$fontsFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\Fonts"
if (Test-Path $fontsFolder) {
Remove-Item $fontsFolder -Recurse -Force
}

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

@ -1,25 +0,0 @@
<#
.Synopsis
Convert HashTable (authContext) to GitHub-Go Credentials
.Description
Convert HashTable (authContext) to GitHub-Go Credentials
.Example
New-BcAuthContext -includeDeviceLogin | ConvertTo-GitHubGoCredentials | Set-Clipboard
#>
function ConvertTo-GitHubGoCredentials() {
[CmdletBinding()]
Param(
[parameter(ValueFromPipeline)]
[Hashtable] $bcAuthContext
)
if ($bcAuthContext.ContainsKey('ClientId') -and $bcAuthContext.ContainsKey('ClientSecret') -and $bcAuthContext.clientId -and $bcAuthContext.clientSecret) {
@{ "ClientId" = $bcAuthContext.ClientId; "ClientSecret" = $bcAuthContext.ClientSecret } | ConvertTo-Json -Compress
}
elseif ($bcAuthContext.ContainsKey('RefreshToken') -and $bcAuthContext.RefreshToken) {
@{ "RefreshToken" = $bcAuthContext.RefreshToken } | ConvertTo-Json -Compress
}
else {
throw "BcAuthContext is wrongly formatted"
}
}
Export-ModuleMember -Function ConvertTo-GitHubGoCredentials

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

@ -31,7 +31,7 @@ try {
$id = Get-BcContainerId -containerName $containerName
# running hyperv containers doesn't support docker cp
$tempFile = Join-Path $hostHelperFolder ([GUID]::NewGuid().ToString())
$tempFile = Join-Path $bcContainerHelperConfig.hostHelperFolder ([GUID]::NewGuid().ToString())
try {
if (Test-Path $localPath -PathType Container) {
throw "localPath ($localPath) already exists as a folder. Cannot copy file, LocalPath needs to specify a filename."

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

@ -27,11 +27,11 @@ try {
if (!(Test-BcContainer -containerName $containerName)) {
throw "Container $containerName does not exist"
}
Write-Host "Copy $localPath to container ${containerName} ($containerPath)"
Write-Host "Copy $localPath to container $($containerName) ($containerPath)"
$id = Get-BcContainerId -containerName $containerName
# running hyperv containers doesn't support docker cp
$tempFile = Join-Path $hostHelperFolder ([GUID]::NewGuid().ToString())
$tempFile = Join-Path $bcContainerHelperConfig.hostHelperFolder ([GUID]::NewGuid().ToString())
try {
Copy-Item -Path $localPath -Destination $tempFile
Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($tempFile, $containerPath)

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

@ -72,11 +72,11 @@ try {
if ($filter -ne "None") {
throw "You cannot set the filter if you are using doNotUseDeltas - you need to convert the full app"
}
$myDeltaFolder = Join-Path $ExtensionsFolder "$containerName\objects$suffix"
$myDeltaFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\objects$suffix"
Export-NavContainerObjects -containerName $containerName -sqlCredential $sqlCredential -objectsFolder $myDeltaFolder -exportTo 'txt folder (new syntax)' -filter ""
if ("$dotNetAddInsPackage" -eq "") {
$dotNetAddInsPackage = Join-Path $ExtensionsFolder "$containerName\coredotnetaddins.al"
$dotNetAddInsPackage = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\coredotnetaddins.al"
Copy-Item -Path (Join-Path $PSScriptRoot "coredotnetaddins.al") -Destination $dotNetAddInsPackage -Force
}
}
@ -85,10 +85,10 @@ try {
$filter = "Modified=1"
}
Export-ModifiedObjectsAsDeltas -containerName $containerName -sqlCredential $sqlCredential -useNewSyntax -filter $filter -originalFolder $originalFolder
$myDeltaFolder = Join-Path $ExtensionsFolder "$containerName\delta$suffix"
$myDeltaFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\delta$suffix"
}
$myAlFolder = Join-Path $ExtensionsFolder "$containerName\al$suffix"
$myAlFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\al$suffix"
Convert-Txt2Al -containerName $runTxt2AlInContainer `
-myDeltaFolder $myDeltaFolder `

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

@ -82,9 +82,9 @@ try {
$Name = $_.Name
if ($Name.ToLowerInvariant().EndsWith(".delta")) {
$BaseName = $_.BaseName
$OrgName = Join-Path $myOriginalFolder "${BaseName}.TXT"
$OrgName = Join-Path $myOriginalFolder "$($BaseName).TXT"
if (!(Test-Path -Path $OrgName)) {
Copy-Item -Path $_.FullName -Destination (Join-Path $myDeltaFolder "${BaseName}.TXT")
Copy-Item -Path $_.FullName -Destination (Join-Path $myDeltaFolder "$($BaseName).TXT")
Remove-Item -Path $_.FullName
}
}

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

@ -46,8 +46,8 @@ try {
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential -doNotAskForCredential
if ((Get-NavContainerSharedFolders -containerName $containerName)[$hostHelperFolder] -ne $containerHelperFolder) {
throw "In order to run Export-ModifiedObjectsAsDeltas you need to have shared $hostHelperFolder to $containerHelperFolder in the container (docker run ... -v ${hostHelperFolder}:$containerHelperFolder ... <image>)."
if ((Get-NavContainerSharedFolders -containerName $containerName)[$bcContainerHelperConfig.hostHelperFolder] -ne $bcContainerHelperConfig.containerHelperFolder) {
throw "In order to run Export-ModifiedObjectsAsDeltas you need to have shared $($bcContainerHelperConfig.hostHelperFolder) to $($bcContainerHelperConfig.containerHelperFolder) in the container (docker run ... -v $($bcContainerHelperConfig.hostHelperFolder):$($bcContainerHelperConfig.containerHelperFolder) ... <image>)."
}
$suffix = ""
@ -58,16 +58,16 @@ try {
}
if (!$originalFolder) {
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
$originalFolder = Join-Path $ExtensionsFolder "Original-$navversion$suffix"
$originalFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion$suffix"
}
if (!(Test-Path $originalFolder)) {
throw "Folder $originalFolder must contain all Nav base objects (original). You can use Export-NavContainerObjects on a fresh container or create your development container using New-CSideDevContainer, which does this automatically."
}
$modifiedFolder = Join-Path $ExtensionsFolder "$containerName\modified$suffix"
$myOriginalFolder = Join-Path $ExtensionsFolder "$containerName\original$suffix"
$myDeltaFolder = Join-Path $ExtensionsFolder "$containerName\delta$suffix"
$modifiedFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\modified$suffix"
$myOriginalFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\original$suffix"
$myDeltaFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\delta$suffix"
# Export my objects
Export-NavContainerObjects -containerName $containerName `

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

@ -49,8 +49,8 @@ try {
$exportTo = 'txt folder'
}
if ("$objectsFolder" -eq "$hostHelperFolder" -or "$objectsFolder" -eq "$hostHelperFolder\") {
throw "The folder specified in ObjectsFolder will be erased, you cannot specify $hostHelperFolder"
if ("$objectsFolder" -eq "$($bcContainerHelperConfig.hostHelperFolder)" -or "$objectsFolder" -eq "$($bcContainerHelperConfig.hostHelperFolder)\") {
throw "The folder specified in ObjectsFolder will be erased, you cannot specify $bcContainerHelperConfig.hostHelperFolder"
}
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential -doNotAskForCredential

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

@ -37,12 +37,12 @@ try {
}
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
$originalFolder = Join-Path $ExtensionsFolder "Original-$navversion"
$mergeResultFile = Join-Path $ExtensionsFolder "$containerName\mergeresult.txt"
$originalFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\Original-$navversion"
$mergeResultFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\mergeresult.txt"
Remove-Item $mergeResultFile -Force -ErrorAction Ignore
$mergedObjectsFile = Join-Path $ExtensionsFolder "$containerName\mergedobjects.txt"
$mergedObjectsFile = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\mergedobjects.txt"
Remove-Item $mergedObjectsFile -Force -ErrorAction Ignore
$myOriginalFolder = Join-Path $ExtensionsFolder "$containerName\original"
$myOriginalFolder = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$containerName\original"
Remove-Item $myOriginalFolder -Force -Recurse -ErrorAction Ignore
Create-MyOriginalFolder -originalFolder $originalFolder `

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

@ -171,7 +171,7 @@ try {
else {
$folderPrefix = "onprem"
}
$applicationsPath = Join-Path $extensionsFolder "$folderPrefix-Applications-$Version-$country"
$applicationsPath = Join-Path $bcContainerHelperConfig.hostHelperFolder "Extensions\$folderPrefix-Applications-$Version-$country"
if (!(Test-Path $applicationsPath)) {
New-Item -Path $applicationsPath -ItemType Directory | Out-Null
}

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

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

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

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

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

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

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