```
bcartifacts.azureedge.net -> bcartifacts-exdbf9fwegejdqak.b02.azurefd.net
bcinsider.azureedge.net -> bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net
bcpublicpreview.azureedge.net ->bcpublicpreview-f2ajahg0e2cudpgh.b02.azurefd.net
businesscentralapps.azureedge.net -> businesscentralapps-hkdrdkaeangzfydv.b02.azurefd.net
bcprivate.azureedge.net -> bcprivate-fmdwbsb3ekbkc0bt.b02.azurefd.net
```

Also: remove support for SAS Token

PR also contains a fix for building with symbols only .app files -
copying installApps to the packagesFolder as well as publishing to a
container. Reason is that you cannot download symbols from a container
if you publish a symbols only package to the container.

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
This commit is contained in:
Freddy Kristiansen 2024-04-04 09:28:54 +02:00 коммит произвёл GitHub
Родитель a154476d07
Коммит 43c9155bb5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
14 изменённых файлов: 177 добавлений и 262 удалений

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

@ -118,7 +118,7 @@ function New-AlpacaBcContainer {
$additionalFolders = @( "c:\run=$runFolderUrl" ) + $additionalFolders
if ($bcArtifact -like "https://*") {
$storageAccount = ("$bcArtifact////".Split('/')[2]).Split('.')[0]
$storageAccount = (ReplaceCDN -sourceUrl "$bcArtifact////".Split('/')[2] -useBlobUrl).Split('.')[0]
$artifactType = ("$bcArtifact////".Split('/')[3])
$version = ("$bcArtifact////".Split('/')[4])
$country = ("$bcArtifact////".Split('?')[0].Split('/')[5])

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

@ -209,7 +209,7 @@ function Run-AlCops {
$appSourceCopJson | ConvertTo-Json -Depth 99 | Set-Content (Join-Path $tmpFolder "appSourceCop.json") -Encoding UTF8
$appSourceRulesetFile = Join-Path $tmpFolder "appsource.default.ruleset.json"
Download-File -sourceUrl "https://bcartifacts.azureedge.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
Download-File -sourceUrl "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
$ruleset.includedRuleSets += @(@{
"action" = "Default"
"path" = Get-BcContainerPath -containerName $containerName -path $appSourceRulesetFile

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

@ -86,8 +86,7 @@
.Parameter outputFolder
This is the folder (relative to base folder) where compiled apps are placed. Only relevant when not using useDevEndpoint.
.Parameter artifact
The description of which artifact to use. This can either be a URL (from Get-BcArtifactUrl) or in the format storageAccount/type/version/country/select/sastoken, where these values are transferred as parameters to Get-BcArtifactUrl. Default value is ///us/current.
If you specify accept_insiderEula, you do not need to specify a sasToken
The description of which artifact to use. This can either be a URL (from Get-BcArtifactUrl) or in the format storageAccount/type/version/country/select, where these values are transferred as parameters to Get-BcArtifactUrl. Default value is ///us/current.
.Parameter useGenericImage
Specify a private (or special) generic image to use for the Container OS. Default is calling Get-BestGenericImageName.
.Parameter buildArtifactFolder
@ -616,24 +615,21 @@ else {
$version = $segments[2]
$country = $segments[3]; if ($country -eq "") { $country = "us" }
$select = $segments[4]; if ($select -eq "") { $select = "latest" }
$sasToken = $segments[5]
Write-Host "Determining artifacts to use"
$minsto = $storageAccount
$minsel = $select
$mintok = $sasToken
if ($additionalCountries) {
$minver = $null
@($country)+$additionalCountries | ForEach-Object {
$url = Get-BCArtifactUrl -storageAccount $storageAccount -type $type -version $version -country $_.Trim() -select $select -sasToken $sasToken -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
$url = Get-BCArtifactUrl -storageAccount $storageAccount -type $type -version $version -country $_.Trim() -select $select -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
Write-Host "Found $($url.Split('?')[0])"
if ($url) {
$ver = [Version]$url.Split('/')[4]
if ($minver -eq $null -or $ver -lt $minver) {
$minver = $ver
$minsto = $url.Split('/')[2].Split('.')[0]
$minsto = (ReplaceCDN -sourceUrl $url.Split('/')[2] -useBlobUrl).Split('.')[0]
$minsel = "Latest"
$mintok = $url.Split('?')[1]; if ($mintok) { $mintok = "?$mintok" }
}
}
}
@ -642,7 +638,7 @@ else {
}
$version = $minver.ToString()
}
$artifactUrl = Get-BCArtifactUrl -storageAccount $minsto -type $type -version $version -country $country -select $minsel -sasToken $mintok -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
$artifactUrl = Get-BCArtifactUrl -storageAccount $minsto -type $type -version $version -country $country -select $minsel -accept_insiderEula:$accept_insiderEula | Select-Object -First 1
if (!($artifactUrl)) {
throw "Unable to locate artifacts"
}
@ -664,7 +660,6 @@ Write-Host -NoNewLine -ForegroundColor Yellow "Pipeline name "
Write-Host -NoNewLine -ForegroundColor Yellow "Container name "; Write-Host $containerName
Write-Host -NoNewLine -ForegroundColor Yellow "Image name "; Write-Host $imageName
Write-Host -NoNewLine -ForegroundColor Yellow "ArtifactUrl "; Write-Host $artifactUrl.Split('?')[0]
Write-Host -NoNewLine -ForegroundColor Yellow "SasToken "; if ($artifactUrl.Contains('?')) { Write-Host "Specified" } else { Write-Host "Not Specified" }
Write-Host -NoNewLine -ForegroundColor Yellow "BcAuthContext "; if ($bcauthcontext) { Write-Host "Specified" } else { Write-Host "Not Specified" }
Write-Host -NoNewLine -ForegroundColor Yellow "Environment "; Write-Host $environment
Write-Host -NoNewLine -ForegroundColor Yellow "ReUseContainer "; Write-Host $reUseContainer
@ -1691,7 +1686,7 @@ Write-Host -ForegroundColor Yellow @'
})
}
$appSourceRulesetFile = Join-Path $folder "appsource.default.ruleset.json"
Download-File -sourceUrl "https://bcartifacts.azureedge.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
Download-File -sourceUrl "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/rulesets/appsource.default.ruleset.json" -destinationFile $appSourceRulesetFile
$ruleset.includedRuleSets += @(@{
"action" = "Default"
"path" = Get-BcContainerPath -containerName $containerName -path $appSourceRulesetFile
@ -1792,6 +1787,23 @@ Write-Host -ForegroundColor Yellow @'
}
}
if ($generateDependencyArtifact -and !$filesOnly -and !$useCompilerFolder) {
$depFolder = Join-Path $buildArtifactFolder "Dependencies"
Write-Host "Copying dependencies from $depFolder to $appPackagesFolder"
if (Test-Path $depFolder) {
Get-ChildItem -Path $depFolder -Recurse -file -Filter '*.app' | ForEach-Object {
$destName = Join-Path $appPackagesFolder $_.Name
if (Test-Path $destName) {
Write-Host "- $destName already exists"
}
else {
Write-Host "+ Copying $($_.FullName) to $destName"
Copy-Item -Path $_.FullName -Destination $destName -Force
}
}
}
}
$Parameters += @{
"appProjectFolder" = $folder
"appOutputFolder" = $appOutputFolder

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

@ -35,8 +35,7 @@
.Parameter doNotIgnoreInfos
Include this switch if you don't want to ignore Infos (if you want to include Infos)
.Parameter sasToken
OBSOLETE - sasToken is no longer needed
Shared Access Service Token for accessing insider artifacts of Business Central. Available on http://aka.ms/collaborate
OBSOLETE - sasToken is no longer supported
.Parameter countries
Array or comma separated list of country codes to validate against
.Parameter affixes
@ -96,7 +95,7 @@ Param(
[switch] $failOnError,
[switch] $includeWarnings,
[switch] $doNotIgnoreInfos,
[Obsolete("sasToken is no longer needed")]
[Obsolete("sasToken is no longer supported")]
[string] $sasToken = "",
[Parameter(Mandatory=$true)]
$countries,
@ -152,7 +151,7 @@ Write-Host -ForegroundColor Yellow @'
$ver = [Version]$url.Split('/')[4]
if ($minver -eq $null -or $ver -lt $minver) {
$minver = $ver
$minsto = $url.Split('/')[2].Split('.')[0]
$minsto = (ReplaceCDN -sourceUrl $url.Split('/')[2] -useBlobUrl).Split('.')[0]
$minsel = "Latest"
}
}
@ -260,7 +259,6 @@ Write-Host -NoNewLine -ForegroundColor Yellow "validateVersion "
Write-Host -NoNewLine -ForegroundColor Yellow "validateCurrent "; Write-Host $validateCurrent
Write-Host -NoNewLine -ForegroundColor Yellow "validateNextMinor "; Write-Host $validateNextMinor
Write-Host -NoNewLine -ForegroundColor Yellow "validateNextMajor "; Write-Host $validateNextMajor
Write-Host -NoNewLine -ForegroundColor Yellow "SasToken "; if ($sasToken) { Write-Host "Specified" } else { Write-Host "Not Specified" }
Write-Host -NoNewLine -ForegroundColor Yellow "countries "; Write-Host ([string]::Join(',',$countries))
Write-Host -NoNewLine -ForegroundColor Yellow "validateCountries "; Write-Host ([string]::Join(',',$validateCountries))
Write-Host -NoNewLine -ForegroundColor Yellow "affixes "; Write-Host ([string]::Join(',',$affixes))
@ -380,10 +378,10 @@ elseif ($_ -eq 1 -and $validateVersion) {
$artifactUrl = DetermineArtifactsToUse -version $validateVersion -countries $validateCountries -select Latest
}
elseif ($_ -eq 2 -and $validateNextMinor) {
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMinor -sasToken $sasToken
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMinor
}
elseif ($_ -eq 3 -and $validateNextMajor) {
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMajor -sasToken $sasToken
$artifactUrl = DetermineArtifactsToUse -countries $validateCountries -select NextMajor
}
if ($artifactUrl) {

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

@ -119,11 +119,11 @@ try {
if (!(Test-Path "C:\Windows\System32\msvcr120.dll")) {
Write-Host "Downloading vcredist_x86"
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.azureedge.net/prerequisites/vcredist_x86.exe','c:\run\install\vcredist_x86.exe')
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.blob.core.windows.net/prerequisites/vcredist_x86.exe','c:\run\install\vcredist_x86.exe')
Write-Host "Installing vcredist_x86"
start-process -Wait -FilePath c:\run\install\vcredist_x86.exe -ArgumentList /q, /norestart
Write-Host "Downloading vcredist_x64"
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.azureedge.net/prerequisites/vcredist_x64.exe','c:\run\install\vcredist_x64.exe')
(New-Object System.Net.WebClient).DownloadFile('https://bcartifacts.blob.core.windows.net/prerequisites/vcredist_x64.exe','c:\run\install\vcredist_x64.exe')
Write-Host "Installing vcredist_x64"
start-process -Wait -FilePath c:\run\install\vcredist_x64.exe -ArgumentList /q, /norestart
}
@ -140,7 +140,7 @@ try {
} else {
Write-Host "Downloading Signing Tools"
$winSdkSetupExe = "c:\run\install\winsdksetup.exe"
$winSdkSetupUrl = "https://bcartifacts.azureedge.net/prerequisites/winsdksetup.exe"
$winSdkSetupUrl = "https://bcartifacts.blob.core.windows.net/prerequisites/winsdksetup.exe"
(New-Object System.Net.WebClient).DownloadFile($winSdkSetupUrl,$winSdkSetupExe)
Write-Host "Installing Signing Tools"
Start-Process $winSdkSetupExe -ArgumentList "/features OptionId.SigningTools /q" -Wait

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

@ -42,50 +42,31 @@ function Download-Artifacts {
$tmpFolder = Join-Path ([System.IO.Path]::GetDirectoryName($destinationPath)) ([System.IO.Path]::GetRandomFileName())
$zipFile = Join-Path ([System.IO.Path]::GetTempPath()) "$([Guid]::NewGuid().ToString()).zip"
if ($bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject -and ($artifactUrl -like 'https://bcartifacts.*' -or $artifactUrl -like 'https://bcinsider.*')) {
# artifactUrl should be either:
# https://storageaccount.azureedge.net/type/version/country
# or
# https://storageaccount.blob.core.windows.net/type/version/country
if (-not ($artifactUrl -match '^https:\/\/([^.]+)\..*\.net\/([^\/]+)\/([^\/]+)\/([a-zA-Z0-9]+)$')) {
throw "Invalid artifact url '$artifactUrl'"
$retry = $false
do {
Download-File -sourceUrl $artifactUrl -destinationFile $zipFile -timeout $timeout
Write-Host "Unpacking artifact to tmp folder " -NoNewline
try {
Expand-7zipArchive -Path $zipFile -DestinationPath $tmpFolder -use7zipIfAvailable:(!$retry)
$retry = $false
}
$organization, $project = $bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject.Split('/')
New-Item -Path $tmpFolder -ItemType Directory | Out-Null
$artifactVersion = [System.Version]"$($Matches[3])"
$feed = $Matches[1]
$packageName = "$($Matches[2]).$($Matches[4]).$($artifactVersion.Major)"
$packageVersion = "$($artifactVersion.Minor).$($artifactVersion.Build).$($artifactVersion.Revision)"
Write-Host "Using az artifacts universal download --organization https://dev.azure.com/$organization --project $project --scope project --feed $feed --name $packageName --version $packageVersion"
az artifacts universal download --organization "https://dev.azure.com/$organization" --project $project --scope project --feed $feed --name $packageName --version $packageVersion --path $tmpFolder
}
else {
$retry = $false
do {
Download-File -sourceUrl $artifactUrl -destinationFile $zipFile -timeout $timeout
Write-Host "Unpacking artifact to tmp folder " -NoNewline
try {
Expand-7zipArchive -Path $zipFile -DestinationPath $tmpFolder -use7zipIfAvailable:(!$retry)
$retry = $false
catch {
Remove-Item -path $zipFile -force
if (Test-Path $tmpFolder) {
Remove-Item $tmpFolder -Recurse -Force
}
catch {
Remove-Item -path $zipFile -force
if (Test-Path $tmpFolder) {
Remove-Item $tmpFolder -Recurse -Force
}
if ($retry) {
throw "Error trying to unpack artifact, downloaded package is corrupt"
}
else {
if ($artifactUrl -match '^https:\/\/(.+)\.azureedge\.net\/(.*)$') {
Write-Host "Error unpacking platform artifact downloaded from CDN, retrying download from direct download URL"
$artifactUrl = "https://$($Matches[1]).blob.core.windows.net/$($Matches[2])"
$retry = $true
}
if ($retry) {
throw "Error trying to unpack artifact, downloaded package is corrupt"
}
else {
if ($artifactUrl -match '^https:\/\/(.+)\.azureedge\.net\/(.*)$') {
Write-Host "Error unpacking platform artifact downloaded from CDN, retrying download from direct download URL"
$artifactUrl = "https://$($Matches[1]).blob.core.windows.net/$($Matches[2])"
$retry = $true
}
}
} while ($retry)
}
}
} while ($retry)
$result = $false
try {
$attempts = 0
@ -162,7 +143,6 @@ try {
}
if (-not $exists) {
Write-Host "Downloading artifact $($appUri.AbsolutePath)"
TestSasToken -url $artifactUrl
DownloadPackage -artifactUrl $artifactUrl -destinationPath $appArtifactPath -timeout $timeout | Out-Null
}
try { [System.IO.File]::WriteAllText((Join-Path $appArtifactPath 'lastused'), "$([datetime]::UtcNow.Ticks)") } catch {}
@ -240,7 +220,6 @@ try {
}
if (-not $exists) {
Write-Host "Downloading platform artifact $($platformUri.AbsolutePath)"
TestSasToken -url $platformUrl
$downloadprereqs = DownLoadPackage -ArtifactUrl $platformUrl -DestinationPath $platformArtifactPath -timeout $timeout
if ($downloadprereqs) {
$prerequisiteComponentsFile = Join-Path $platformArtifactPath "Prerequisite Components.json"

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

@ -23,8 +23,7 @@
.Parameter storageAccount
The storageAccount that is being used where artifacts are stored (default is bcartifacts, usually should not be changed).
.Parameter sasToken
The token that for accessing protected Azure Blob Storage. Make sure to set the right storageAccount!
Note that Business Central Insider artifacts doesn't require a sasToken after October 1st 2023, you can use the switch -accept_insiderEula to accept the EULA instead.
OBSOLETE - sasToken is no longer supported
.Parameter accept_insiderEula
Accept the EULA for Business Central Insider artifacts. This is required for using Business Central Insider artifacts without providing a SAS token after October 1st 2023.
.Example
@ -46,6 +45,7 @@ function Get-BCArtifactUrl {
[DateTime] $after,
[DateTime] $before,
[String] $storageAccount = '',
[Obsolete("sasToken is no longer supported")]
[String] $sasToken = '',
[switch] $accept_insiderEula,
[switch] $doNotCheckPlatform
@ -116,7 +116,7 @@ try {
}
if (-not $country) { $country = 'w1' }
$insiders = Get-BcArtifactUrl -country $country -storageAccount bcinsider -select All -sasToken $sasToken -doNotCheckPlatform:$doNotCheckPlatform -accept_insiderEula:$accept_insiderEula
$insiders = Get-BcArtifactUrl -country $country -storageAccount bcinsider -select All -doNotCheckPlatform:$doNotCheckPlatform -accept_insiderEula:$accept_insiderEula
$nextmajor = $insiders | Where-Object { $_.Split('/')[4].StartsWith($nextmajorversion) } | Select-Object -Last 1
$nextminor = $insiders | Where-Object { $_.Split('/')[4].StartsWith($nextminorversion) } | Select-Object -Last 1
@ -128,43 +128,20 @@ try {
}
}
else {
if ($sasToken) {
TestSasToken -url $sasToken
}
if ($storageAccount -eq '') {
$storageAccount = 'bcartifacts'
}
if (-not $storageAccount.Contains('.')) {
$storageAccount += ".azureedge.net"
$storageAccount += ".blob.core.windows.net"
}
$BaseUrl = "https://$storageAccount/$($Type.ToLowerInvariant())/"
$storageAccount = $storageAccount -replace ".azureedge.net", ".blob.core.windows.net"
$BaseUrl = ReplaceCDN -sourceUrl "https://$storageAccount/$($Type.ToLowerInvariant())/" -useBlobUrl:($bcContainerHelperConfig.DoNotUseCdnForArtifacts)
$storageAccount = ReplaceCDN -sourceUrl $storageAccount -useBlobUrl
if ($storageAccount -eq 'bcinsider.blob.core.windows.net') {
if (!$accept_insiderEULA) {
if ($sasToken) {
Write-Host -ForegroundColor Yellow "After October 1st 2023, you can specify -accept_insiderEula to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) for Business Central Insider artifacts instead of providing a SAS token."
}
else {
throw "You need to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) by specifying -accept_insiderEula or by providing a SAS token to get access to insider builds"
}
}
}
$GetListUrl = "https://$storageAccount/$($Type.ToLowerInvariant())/"
if ($bcContainerHelperConfig.DoNotUseCdnForArtifacts) {
$BaseUrl = $GetListUrl
}
if (!([string]::IsNullOrEmpty($sasToken))) {
$GetListUrl += $sasToken + "&comp=list&restype=container"
}
else {
$GetListUrl += "?comp=list&restype=container"
if ($storageAccount -eq 'bcinsider.blob.core.windows.net' -and !$accept_insiderEULA) {
throw "You need to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) by specifying -accept_insiderEula or by providing a SAS token to get access to insider builds"
}
$GetListUrl = "https://$storageAccount/$($Type.ToLowerInvariant())/?comp=list&restype=container"
$upMajorFilter = ''
$upVersionFilter = ''
@ -197,117 +174,90 @@ try {
$upVersionFilter = $version.Substring($version.Length).TrimStart('.')
}
if ($bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject) {
$feedApiUrl = "https://feeds.dev.azure.com/$($bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject)/_apis/packaging/feeds/$($storageAccount.Split('.')[0])"
$query = "&packageNameQuery=$type"
if ($country) {
$query += ".$country"
if ($upMajorFilter) {
$query += ".$upMajorFilter"
}
$Artifacts = @()
$nextMarker = ''
$currentMarker = ''
$downloadAttempt = 1
$downloadRetryAttempts = 10
do {
if ($currentMarker -ne $nextMarker)
{
$currentMarker = $nextMarker
$downloadAttempt = 1
}
# Universal packages only supports semantic version numbers (3 digits)
# Since Business Central artifact version numbers uses 4 digits, we name the packages: "type.country.major" and the version number is then "minor.build.revision"
$result = invoke-restmethod -UseBasicParsing -Uri "$feedApiUrl/packages?api-version=7.0$query&includeAllVersions=$(($select -ne 'latest').ToString().ToLowerInvariant())"
$Artifacts = @($result.value | ForEach-Object {
# package name is type.country.major
$null, $country, $major = $_.name.Split('.')
if (!$upMajorFilter -or $upMajorFilter -eq $major) {
$_.versions | Where-Object { (!$upVersionFilter) -or ($_.version.StartsWith($upVersionFilter)) } | ForEach-Object {
# version number is minor.build.revision
return "$major.$($_.version)/$country"
}
Write-Verbose "Download String $GetListUrl$nextMarker"
try
{
$Response = Invoke-RestMethod -UseBasicParsing -ContentType "application/json; charset=UTF8" -Uri "$GetListUrl$nextMarker"
if (([int]$Response[0]) -eq 239 -and ([int]$Response[1]) -eq 187 -and ([int]$Response[2]) -eq 191) {
# Remove UTF8 BOM
$response = $response.Substring(3)
}
})
}
else {
$Artifacts = @()
$nextMarker = ''
$currentMarker = ''
$downloadAttempt = 1
$downloadRetryAttempts = 10
do {
if ($currentMarker -ne $nextMarker)
{
$currentMarker = $nextMarker
$downloadAttempt = 1
if (([int]$Response[0]) -eq 65279) {
# Remove Unicode BOM (PowerShell 7.4)
$response = $response.Substring(1)
}
Write-Verbose "Download String $GetListUrl$nextMarker"
try
{
$Response = Invoke-RestMethod -UseBasicParsing -ContentType "application/json; charset=UTF8" -Uri "$GetListUrl$nextMarker"
if (([int]$Response[0]) -eq 239 -and ([int]$Response[1]) -eq 187 -and ([int]$Response[2]) -eq 191) {
# Remove UTF8 BOM
$response = $response.Substring(3)
}
if (([int]$Response[0]) -eq 65279) {
# Remove Unicode BOM (PowerShell 7.4)
$response = $response.Substring(1)
}
$enumerationResults = ([xml]$Response).EnumerationResults
if ($enumerationResults.Blobs) {
if (($After) -or ($Before)) {
$artifacts += $enumerationResults.Blobs.Blob | % {
if ($after) {
$blobModifiedDate = [DateTime]::Parse($_.Properties."Last-Modified")
if ($before) {
if ($blobModifiedDate -lt $before -and $blobModifiedDate -gt $after) {
$_.Name
}
}
elseif ($blobModifiedDate -gt $after) {
$enumerationResults = ([xml]$Response).EnumerationResults
if ($enumerationResults.Blobs) {
if (($After) -or ($Before)) {
$artifacts += $enumerationResults.Blobs.Blob | % {
if ($after) {
$blobModifiedDate = [DateTime]::Parse($_.Properties."Last-Modified")
if ($before) {
if ($blobModifiedDate -lt $before -and $blobModifiedDate -gt $after) {
$_.Name
}
}
else {
$blobModifiedDate = [DateTime]::Parse($_.Properties."Last-Modified")
if ($blobModifiedDate -lt $before) {
$_.Name
}
elseif ($blobModifiedDate -gt $after) {
$_.Name
}
}
else {
$blobModifiedDate = [DateTime]::Parse($_.Properties."Last-Modified")
if ($blobModifiedDate -lt $before) {
$_.Name
}
}
}
else {
$artifacts += $enumerationResults.Blobs.Blob.Name
}
}
$nextMarker = $enumerationResults.NextMarker
if ($nextMarker) {
$nextMarker = "&marker=$nextMarker"
else {
$artifacts += $enumerationResults.Blobs.Blob.Name
}
}
catch
$nextMarker = $enumerationResults.NextMarker
if ($nextMarker) {
$nextMarker = "&marker=$nextMarker"
}
}
catch
{
$downloadAttempt += 1
Write-Host "Error querying artifacts. Error message was $($_.Exception.Message)"
Write-Host
if ($downloadAttempt -le $downloadRetryAttempts)
{
$downloadAttempt += 1
Write-Host "Error querying artifacts. Error message was $($_.Exception.Message)"
Write-Host "Repeating download attempt (" $downloadAttempt.ToString() " of " $downloadRetryAttempts.ToString() ")..."
Write-Host
if ($downloadAttempt -le $downloadRetryAttempts)
{
Write-Host "Repeating download attempt (" $downloadAttempt.ToString() " of " $downloadRetryAttempts.ToString() ")..."
Write-Host
}
else
{
throw
}
}
} while ($nextMarker)
}
else
{
throw
}
}
} while ($nextMarker)
if (!([string]::IsNullOrEmpty($country))) {
if (-not $bcContainerHelperConfig.ArtifactsFeedOrganizationAndProject) {
# avoid confusion between base and se
$countryArtifacts = $Artifacts | Where-Object { $_.EndsWith("/$country", [System.StringComparison]::InvariantCultureIgnoreCase) -and ($doNotCheckPlatform -or ($Artifacts.Contains("$($_.Split('/')[0])/platform"))) }
if (!$countryArtifacts) {
if (($type -eq "sandbox") -and ($bcContainerHelperConfig.mapCountryCode.PSObject.Properties.Name -eq $country)) {
$country = $bcContainerHelperConfig.mapCountryCode."$country"
$countryArtifacts = $Artifacts | Where-Object { $_.EndsWith("/$country", [System.StringComparison]::InvariantCultureIgnoreCase) -and ($doNotCheckPlatform -or ($Artifacts.Contains("$($_.Split('/')[0])/platform"))) }
}
# avoid confusion between base and se
$countryArtifacts = $Artifacts | Where-Object { $_.EndsWith("/$country", [System.StringComparison]::InvariantCultureIgnoreCase) -and ($doNotCheckPlatform -or ($Artifacts.Contains("$($_.Split('/')[0])/platform"))) }
if (!$countryArtifacts) {
if (($type -eq "sandbox") -and ($bcContainerHelperConfig.mapCountryCode.PSObject.Properties.Name -eq $country)) {
$country = $bcContainerHelperConfig.mapCountryCode."$country"
$countryArtifacts = $Artifacts | Where-Object { $_.EndsWith("/$country", [System.StringComparison]::InvariantCultureIgnoreCase) -and ($doNotCheckPlatform -or ($Artifacts.Contains("$($_.Split('/')[0])/platform"))) }
}
$Artifacts = $countryArtifacts
}
$Artifacts = $countryArtifacts
}
else {
$Artifacts = $Artifacts | Where-Object { !($_.EndsWith("/platform", [System.StringComparison]::InvariantCultureIgnoreCase)) }

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

@ -101,7 +101,6 @@ function Get-ContainerHelperConfig {
"RenewClientContextBetweenTests" = $false
"DebugMode" = $false
"DoNotUseCdnForArtifacts" = $false
"ArtifactsFeedOrganizationAndProject" = ""
"MinimumDotNetRuntimeVersionStr" = "6.0.16"
"MinimumDotNetRuntimeVersionUrl" = 'https://download.visualstudio.microsoft.com/download/pr/ca13c6f1-3107-4cf8-991c-f70edc1c1139/a9f90579d827514af05c3463bed63c22/dotnet-sdk-6.0.408-win-x64.zip'
"AlpacaSettings" = [PSCustomObject]@{

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

@ -30,19 +30,6 @@ function Download-File {
[int] $timeout = 100
)
function ReplaceCDN {
Param(
[string] $sourceUrl
)
$cdnStr = '.azureedge.net'
if ($sourceUrl -like "https://bcartifacts$cdnStr/*" -or $sourceUrl -like "https://bcinsider$cdnStr/*" -or $sourceUrl -like "https://bcprivate$cdnStr/*" -or $sourceUrl -like "https://bcpublicpreview$cdnStr/*") {
$idx = $sourceUrl.IndexOf("$cdnStr/",[System.StringComparison]::InvariantCultureIgnoreCase)
$sourceUrl = $sourceUrl.Substring(0,$idx) + '.blob.core.windows.net' + $sourceUrl.Substring($idx + $cdnStr.Length)
}
$sourceUrl
}
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
try {
@ -86,17 +73,17 @@ try {
Invoke-WebRequest -UseBasicParsing -Uri $sourceUrl -OutFile $destinationFile
}
else {
if ($bcContainerHelperConfig.DoNotUseCdnForArtifacts -or $sourceUrl -like 'https://bcinsider.azureedge.net/*') {
if ($bcContainerHelperConfig.DoNotUseCdnForArtifacts -or $sourceUrl -like 'https://bcinsider*.net/*') {
# Do not use CDN when configured or bcinsider
$sourceUrl = ReplaceCDN -sourceUrl $sourceUrl
$sourceUrl = ReplaceCDN -sourceUrl $sourceUrl -useBlobUrl
}
try {
DownloadFileLow -sourceUrl $sourceUrl -destinationFile $destinationFile -dontOverwrite:$dontOverwrite -timeout $timeout -headers $headers
DownloadFileLow -sourceUrl (ReplaceCDN -sourceUrl $sourceUrl) -destinationFile $destinationFile -dontOverwrite:$dontOverwrite -timeout $timeout -headers $headers
}
catch {
try {
$waittime = 2 + (Get-Random -Maximum 5 -Minimum 0)
$newSourceUrl = ReplaceCDN -sourceUrl $sourceUrl
$newSourceUrl = ReplaceCDN -sourceUrl $sourceUrl -useBlobUrl
if ($sourceUrl -eq $newSourceUrl) {
Write-Host "Error downloading..., retrying in $waittime seconds..."
}

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

@ -178,10 +178,10 @@ try {
$artifactUrl = $inspect.config.Env | Where-Object { $_ -like "artifactUrl=*" }
if ($artifactUrl) {
$artifactUrl = $artifactUrl.Split('?')[0]
"artifactUrl=https://bcartifacts.azureedge.net/",
"artifactUrl=https://bcinsider.azureedge.net/",
"artifactUrl=https://bcprivate.azureedge.net/",
"artifactUrl=https://bcpublicpreview.azureedge.net/" | ForEach-Object {
"artifactUrl=https://bcartifacts*.net/",
"artifactUrl=https://bcinsider*.net/",
"artifactUrl=https://bcprivate*.net/",
"artifactUrl=https://bcpublicpreview*.net/" | ForEach-Object {
if ($artifactUrl -like "$($_)*") {
$cacheFolder = Join-Path $artifactsCacheFolder $artifactUrl.SubString($_.Length)
if (-not (Test-Path $cacheFolder)) {

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

@ -540,16 +540,9 @@ try {
# When using artifacts, you always use best container os - no need to replatform
$useBestContainerOS = $false
if ($artifactUrl -like 'https://bcinsider.blob.core.windows.net/*' -or $artifactUrl -like 'https://bcinsider.azureedge.net/*') {
if ($artifactUrl -like 'https://bcinsider*') {
if (!$accept_insiderEULA) {
$sasToken = "?$("$($artifactUrl)?".Split('?')[1])"
if ($sasToken -eq '?') {
throw "You need to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) by specifying -accept_insiderEula or by providing a SAS token to get access to insider builds"
}
else {
TestSasToken -url $artifactUrl
Write-Host -ForegroundColor Yellow "After October 1st 2023, you can specify -accept_insiderEula to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) for Business Central Insider artifacts instead of providing a SAS token."
}
throw "You need to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) by specifying -accept_insiderEula"
}
}
@ -564,10 +557,10 @@ try {
Write-Host "The CRONUS Demo License shipped in Version 21.0 artifacts doesn't contain sufficient rights to all Test Libraries objects. Patching the license file."
$country = $appManifest.Country.ToLowerInvariant()
if (@('at','au','be','ca','ch','cz','de','dk','es','fi','fr','gb','in','is','it','mx','nl','no','nz','ru','se','us') -contains $country) {
$licenseFile = "https://bcartifacts.azureedge.net/prerequisites/21demolicense/$country/3048953.bclicense"
$licenseFile = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/prerequisites/21demolicense/$country/3048953.bclicense"
}
else {
$licenseFile = "https://bcartifacts.azureedge.net/prerequisites/21demolicense/w1/3048953.bclicense"
$licenseFile = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/prerequisites/21demolicense/w1/3048953.bclicense"
}
}

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

@ -205,10 +205,10 @@ try {
Write-Host "The CRONUS Demo License shipped in Version 21.0 artifacts doesn't contain sufficient rights to all Test Libraries objects. Patching the license file."
$country = $appManifest.Country.ToLowerInvariant()
if (@('at','au','be','ca','ch','cz','de','dk','es','fi','fr','gb','in','is','it','mx','nl','no','nz','ru','se','us') -contains $country) {
$licenseFile = "https://bcartifacts.azureedge.net/prerequisites/21demolicense/$country/3048953.bclicense"
$licenseFile = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/prerequisites/21demolicense/$country/3048953.bclicense"
}
else {
$licenseFile = "https://bcartifacts.azureedge.net/prerequisites/21demolicense/w1/3048953.bclicense"
$licenseFile = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/prerequisites/21demolicense/w1/3048953.bclicense"
}
}
@ -273,7 +273,7 @@ try {
$labels = Get-BcContainerImageLabels -imageName $baseImage -registryCredential $registryCredential
$imageArtifactUrl = ($inspect.config.env | ? { $_ -like "artifactUrl=*" }).SubString(12).Split('?')[0]
if ("$imageArtifactUrl".ToLowerInvariant().Replace('.blob.core.windows.net/','.azureedge.net/') -ne "$($artifactUrl.Split('?')[0])".ToLowerInvariant().Replace('.blob.core.windows.net/','.azureedge.net/')) {
if ((ReplaceCDN -sourceUrl $imageArtifactUrl -useBlobUrl) -ne (ReplaceCDN -sourceUrl $artifactUrl.Split('?')[0] -useBlobUrl)) {
Write-Host "Image $imageName was built with artifactUrl $imageArtifactUrl, should be $($artifactUrl.Split('?')[0])"
$forceRebuild = $true
}

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

@ -335,42 +335,6 @@ function AssumeNavContainer {
}
}
function TestSasToken {
Param
(
[string] $url
)
$sasToken = "?$("$($url)?".Split('?')[1])"
if ($sasToken -eq '?') {
# No SAS token in URL
return
}
try {
$se = $sasToken.Split('?')[1].Split('&') | Where-Object { $_.StartsWith('se=') } | ForEach-Object { [Uri]::UnescapeDataString($_.Substring(3)) }
$st = $sasToken.Split('?')[1].Split('&') | Where-Object { $_.StartsWith('st=') } | ForEach-Object { [Uri]::UnescapeDataString($_.Substring(3)) }
$sv = $sasToken.Split('?')[1].Split('&') | Where-Object { $_.StartsWith('sv=') } | ForEach-Object { [Uri]::UnescapeDataString($_.Substring(3)) }
$sig = $sasToken.Split('?')[1].Split('&') | Where-Object { $_.StartsWith('sig=') } | ForEach-Object { [Uri]::UnescapeDataString($_.Substring(4)) }
if ($sv -ne '2021-10-04' -or $sig -eq '' -or $se -eq '' -or $st -eq '') {
throw "Wrong format"
}
if ([DateTime]::Now -lt [DateTime]$st) {
Write-Host "::ERROR::The sas token provided isn't valid before $(([DateTime]$st).ToString())"
}
if ([DateTime]::Now -gt [DateTime]$se) {
Write-Host "::ERROR::The sas token provided expired on $(([DateTime]$se).ToString())"
}
elseif ([DateTime]::Now.AddDays(14) -gt [DateTime]$se) {
Write-Host "::WARNING::The sas token provided will expire on $(([DateTime]$se).ToString())"
}
}
catch {
$message = $_.ToString()
throw "The sas token provided is not valid, error message was: $message"
}
}
function Expand-7zipArchive {
Param (
[Parameter(Mandatory = $true)]
@ -1383,3 +1347,36 @@ function GetApplicationDependency( [string] $appFile, [string] $minVersion = "0.
}
return $version
}
function ReplaceCDN {
Param(
[string] $sourceUrl,
[switch] $useBlobUrl
)
$bcCDNs = @(
@{ "oldCDN" = "bcartifacts.azureedge.net"; "newCDN" = "bcartifacts-exdbf9fwegejdqak.b02.azurefd.net"; "blobUrl" = "bcartifacts.blob.core.windows.net" },
@{ "oldCDN" = "bcinsider.azureedge.net"; "newCDN" = "bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net"; "blobUrl" = "bcinsider.blob.core.windows.net" },
@{ "oldCDN" = "bcpublicpreview.azureedge.net"; "newCDN" = "bcpublicpreview-f2ajahg0e2cudpgh.b02.azurefd.net"; "blobUrl" = "bcpublicpreview.blob.core.windows.net" },
@{ "oldCDN" = "businesscentralapps.azureedge.net"; "newCDN" = "businesscentralapps-hkdrdkaeangzfydv.b02.azurefd.net"; "blobUrl" = "businesscentralapps.blob.core.windows.net" },
@{ "oldCDN" = "bcprivate.azureedge.net"; "newCDN" = "bcprivate-fmdwbsb3ekbkc0bt.b02.azurefd.net"; "blobUrl" = "bcprivate.blob.core.windows.net" }
)
foreach($cdn in $bcCDNs) {
$found = $false
$cdn.blobUrl, $cdn.newCDN, $cdn.oldCDN | ForEach-Object {
if ($sourceUrl.ToLowerInvariant().StartsWith("https://$_/")) {
$sourceUrl = "https://$(if($useBlobUrl){$cdn.blobUrl}else{$cdn.newCDN})/$($sourceUrl.Substring($_.Length+9))"
$found = $true
}
if ($sourceUrl -eq $_) {
$sourceUrl = "$(if($useBlobUrl){$cdn.blobUrl}else{$cdn.newCDN})"
$found = $true
}
}
if ($found) {
break
}
}
$sourceUrl
}

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

@ -35,13 +35,13 @@ Describe 'Misc' {
$exists | Should -Be $true
}
It 'Get-BcArtifactUrl' {
(Get-BCArtifactUrl -country "us").Startswith('https://bcartifacts.azureedge.net/sandbox/') | Should -Be $true
(Get-BCArtifactUrl -country "us").Startswith('https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/') | Should -Be $true
(Get-BCArtifactUrl -type OnPrem -select all).Count | Should -BeGreaterThan 3000
Get-BCArtifactUrl -country "us" -version '16.2.13509.13700' -select Closest | Should -Be (Get-BCArtifactUrl -country "us" -version '16.2.13509.31578')
}
It 'Get-NavArtifactUrl' {
(Get-NavArtifactUrl -nav 2017 -country 'dk' -select all).count | Should -BeGreaterThan 43
Get-NavArtifactUrl -nav 2018 -cu 30 -country de | Should -Be 'https://bcartifacts.azureedge.net/onprem/11.0.43274.0/de'
Get-NavArtifactUrl -nav 2018 -cu 30 -country de | Should -Be 'https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/11.0.43274.0/de'
}
It 'Download-File' {
#TODO