Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstrup1 committed Feb 7, 2025
1 parent 8f7a4c6 commit 7d110d5
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ Param(
[hashtable] $parameters
)

Write-Host "Skipping ImportTestToolkitToBcContainer.ps1"
Import-TestToolkitToBcContainer @parameters

<#
Import-Module (Join-Path $PSScriptRoot "../../../scripts/DevEnv/NewDevContainer.psm1" -Resolve)
Setup-ContainerForDevelopment -ContainerName $parameters.ContainerName -RepoVersion "26.0"
$installedApps = Get-BcContainerAppInfo -containerName $parameters.ContainerName -tenantSpecificProperties -sort DependenciesLast
$installedApps | ForEach-Object {
Write-Host "$($_.Name) - $($_.Version) - $($_.Tenant) - $($_.IsPublished) / $($_.IsInstalled)"
}
}
#>
8 changes: 2 additions & 6 deletions build/projects/Add-Ons (W1)/.AL-Go/NewBcContainer.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
Param(
[Hashtable]$parameters
)
$keepApps = @()

$projectSettings = Get-Content (Join-Path $PSScriptRoot "settings.json" -Resolve) | ConvertFrom-Json
if ($projectSettings.useProjectDependencies -eq $false) {
$keepApps = @("System Application", "Business Foundation", "Base Application", "Application")
}
$externalDependencies = (Get-Content (Join-Path $PSScriptRoot "customSettings.json" -Resolve) | ConvertFrom-Json).ExternalAppDependencies

$script = Join-Path $PSScriptRoot "../../../scripts/NewBcContainer.ps1" -Resolve
. $script -parameters $parameters -keepApps $keepApps
. $script -parameters $parameters -keepApps $externalDependencies
4 changes: 3 additions & 1 deletion build/projects/Add-Ons (W1)/.AL-Go/PreCompileApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Param(
)

if ($ENV:BuildMode -eq 'Clean') {
$externalDependencies = (Get-Content (Join-Path $PSScriptRoot "customSettings.json" -Resolve) | ConvertFrom-Json).ExternalAppDependencies

$scriptPath = Join-Path $PSScriptRoot "../../../scripts/PreCompileApp.ps1" -Resolve
. $scriptPath -parameters $compilationParams -appType $appType -recompileDependencies $true
. $scriptPath -parameters $compilationParams -appType $appType -recompileDependencies $externalDependencies
}
17 changes: 2 additions & 15 deletions build/projects/Add-Ons (W1)/.AL-Go/PublishBcContainerApp.ps1
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
Param([Hashtable]$parameters)

try {
$parameters["scope"] = "Tenant"
$parameters["ignoreIfAppExists"] = $true
if (Test-BcContainer -containerName $parameters.ContainerName) {
Publish-BcContainerApp @parameters
}
} catch {
# Sometimes Publishing fails after publishing "Application"
# error AL1024: A package with publisher 'Microsoft', name 'Application', and a version compatible with '25.0.0.0' could not be loaded. Value cannot be null. (Parameter 'appId')
# Restarting the container fixes this issue
Restart-NavContainer -containerName $parameters.ContainerName
if (Test-BcContainer -containerName $parameters.ContainerName) {
Publish-BcContainerApp @parameters
}
}
$parameters["useDevEndpoint"] = $true
Publish-BcContainerApp @parameters
8 changes: 8 additions & 0 deletions build/projects/Add-Ons (W1)/.AL-Go/customSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExternalAppDependencies" : [
"System Application",
"Business Foundation",
"Base Application",
"Application"
]
}
30 changes: 3 additions & 27 deletions build/scripts/AppExtensionsHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function Update-Dependencies() {

Write-Host "Recompiling dependencies"
# Copy apps to packagecachepath
$projectFolder = $CompilationParameters["appProjectFolder"]
$SymbolsFolder = $CompilationParameters["appSymbolsFolder"]

# Log what is in the symbols folder
Expand All @@ -33,45 +32,22 @@ function Update-Dependencies() {
throw
}

# Find app.json inside the source code
$appJson = Get-ChildItem -Path $sourceCodeFolder -Recurse -Filter "app.json" | Select-Object -First 1
# print the app.json path
Write-Host "Found app.json at $appJson"
Write-Host $appJson.FullName

# Recompile them
# Update the CompilationParameters
$CompilationParameters["appProjectFolder"] = $sourceCodeFolder
$CompilationParameters["appOutputFolder"] = $SymbolsFolder
$CompilationParameters["appSymbolsFolder"] = $newSymbolsFolder

# Disable all cops
$CompilationParameters["EnableAppSourceCop"] = $false
$CompilationParameters["EnableCodeCop"] = $false
$CompilationParameters["EnableUICop"] = $false
$CompilationParameters["EnablePerTenantExtensionCop"] = $false

$CompilationParameters.Remove("ruleset")

# Iterate through hashtable and print keys and values
foreach ($key in $CompilationParameters.Keys) {
Write-Host "$key : $($CompilationParameters[$key])"
}


Compile-AppWithBcCompilerFolder @CompilationParameters
# Find the created .app file in the newSymbolsFolder
$appFiles = Get-ChildItem -Path $newSymbolsFolder -Filter "*$App*.app"
# Copy the new app files to the symbols folder
<#foreach ($appFile in $appFiles) {
Write-Host "Copying $appFile to $SymbolsFolder"
$appFile | Copy-Item -Destination $SymbolsFolder -Force
}#>
#
<#
# Copy the new app files to the symbols folder
$appFiles = Get-ChildItem -Path $projectFolder -Filter "*.app"
foreach ($appFile in $appFiles) {
Write-Host "Copying $appFile to $SymbolsFolder"
$appFile | Copy-Item -Destination $SymbolsFolder -Force
}
#>
}
7 changes: 5 additions & 2 deletions build/scripts/DevEnv/NewDevContainer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ function Setup-ContainerForDevelopment() {
Write-Host "Moving $($_.Name) to Dev Scope"
Move-AppIntoDevScope -Name ($_.Name) -DatabaseName $DatabaseName
}
if ($_.Version -ne "$($RepoVersion.Major).$($RepoVersion.Minor).0.0") {
Set-AppVersion -Name ($_.Name) -DatabaseName $DatabaseName -Major $RepoVersion.Major -Minor $RepoVersion.Minor
if ($null -ne $RepoVersion) {
if ($_.Version -ne "$($RepoVersion.Major).$($RepoVersion.Minor).0.0") {
Write-Host "Setting version of $($_.Name) to $($RepoVersion).0.0"
#Set-AppVersion -Name ($_.Name) -DatabaseName $DatabaseName -Major $RepoVersion.Major -Minor $RepoVersion.Minor
}
}
}
} finally {
Expand Down
29 changes: 20 additions & 9 deletions build/scripts/NewBcContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,27 @@ if ("$env:GITHUB_RUN_ID" -eq "") {

New-BcContainer @parameters

$installedApps = Get-BcContainerAppInfo -containerName $containerName -tenantSpecificProperties -sort DependenciesLast
$installedApps | ForEach-Object {
if (-not $keepApps) {
Write-Host "Removing $($_.Name)"
Unpublish-BcContainerApp -containerName $parameters.ContainerName -name $_.Name -unInstall -doNotSaveData -doNotSaveSchema -force
}
Restart-BcContainer -containerName $parameters.ContainerName

$publishedApps = Get-BcContainerAppInfo -containerName $parameters.ContainerName -tenantSpecificProperties -sort DependenciesLast
$appsToRemove = @($publishedApps | Where-Object IsInstalled -eq $false)

Write-Host "Found $($publishedApps.Count) apps in the container"
Write-Host "Found $($appsToRemove.Count) apps to remove"
<#if ($keepApps) {
} else {
$appsToRemove = $publishedApps
}#>

foreach ($app in $appsToRemove) {
Write-Host "Removing $($_.Name)"
Unpublish-BcContainerApp -containerName $parameters.ContainerName -name $app.Name -unInstall -doNotSaveData -doNotSaveSchema -force
}

Unpublish-BcContainerApp -containerName $parameters.ContainerName -name "Shopify Connector" -unInstall -doNotSaveData -doNotSaveSchema -force

# Set the app version and move to dev scope
<#Import-Module "$PSScriptRoot\DevEnv\NewDevContainer.psm1"
Setup-ContainerForDevelopment -ContainerName $parameters.ContainerName -RepoVersion "26.0"
#>
Import-Module "$PSScriptRoot\DevEnv\NewDevContainer.psm1"
Setup-ContainerForDevelopment -ContainerName $parameters.ContainerName -RepoVersion $null

Invoke-ScriptInBcContainer -containerName $parameters.ContainerName -scriptblock { $progressPreference = 'SilentlyContinue' }
7 changes: 3 additions & 4 deletions build/scripts/PreCompileApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Param(
[ValidateSet('app', 'testApp', 'bcptApp')]
[string] $appType = 'app',
[ref] $parameters,
[boolean] $recompileDependencies = $false
[string[]] $recompileDependencies = @()
)

Import-Module $PSScriptRoot\EnlistmentHelperFunctions.psm1
Expand Down Expand Up @@ -48,7 +48,7 @@ if($appType -eq 'app')
$appName = (Get-Content -Path $appJson | ConvertFrom-Json).Name
$tempParameters["appName"] = "$($appName)_clean.app"

if ($recompileDependencies) {
if ($recompileDependencies.Count -gt 0) {
Import-Module $PSScriptRoot\AppExtensionsHelper.psm1
# Temp fix for: Error: AL0196 The call is ambiguous between the method
if (Test-Path "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\9.0.1") {
Expand All @@ -64,10 +64,9 @@ if($appType -eq 'app')
Rename-Item "C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.12" "9.0.1"
}
# End of temp fix
@("System Application", "Business Foundation", "Base Application", "Application") | ForEach-Object {
$recompileDependencies | ForEach-Object {
Update-Dependencies -App $_ -CompilationParameters ($parameters.Value.Clone())
}
#Update-Dependencies -App "System Application" -CompilationParameters ($parameters.Value.Clone())
}

if($useCompilerFolder) {
Expand Down

0 comments on commit 7d110d5

Please sign in to comment.