Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Actions/.Modules/ReadSettings.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function GetDefaultSettings
"customALGoFiles" = [ordered]@{
"filesToInclude" = @()
"filesToExclude" = @()
"filesToRemove" = @()
}
"postponeProjectInBuildOrder" = $false
}
Expand Down
27 changes: 27 additions & 0 deletions Actions/.Modules/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@
"type": "object",
"properties": {
"filesToInclude": {
"description": "An array of file specifications to include in the update. Files that match these specifications are copied from the template to the repository. When used in a custom template's settings, inclusions are also propagated from the original template to consumer repos even if the files no longer exist in the custom template.",
"type": "array",
"items": {
"type": "object",
Expand All @@ -763,6 +764,7 @@
}
},
"filesToExclude": {
"description": "An array of file specifications to exclude from the update. Files that match these specifications are not copied from the template to the repository. When used in a custom template's settings, exclusions are also propagated from the original template to consumer repos even if the files no longer exist in the custom template.",
"type": "array",
"items": {
"type": "object",
Expand All @@ -777,6 +779,31 @@
}
}
}
},
"filesToRemove": {
"description": "An array of file specifications to unconditionally remove from the repository during 'Update AL-Go System Files', regardless of whether the files exist in the template. Useful for cleaning up files that have been removed from the template but may still exist in repositories.",
"type": "array",
"items": {
"type": "object",
"properties": {
"sourceFolder": {
"type": "string",
"description": "The source folder from which to remove files, relative to the template repository root."
},
"filter": {
"type": "string",
"description": "A filter string to select which files to remove. It can contain '*' and '?' wildcards."
},
"destinationFolder": {
"type": "string",
"description": "The destination folder where the files should be removed, relative to the repository root."
},
"perProject": {
"type": "boolean",
"description": "Indicates whether the removal should be applied per project. In that case, destinationFolder is relative to each project folder."
}
}
}
}
}
},
Expand Down
226 changes: 194 additions & 32 deletions Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1

Large diffs are not rendered by default.

71 changes: 35 additions & 36 deletions Actions/CheckForUpdates/CheckForUpdates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if ($token) {
# if $downloadLatest is set to true, CheckForUpdates will download the latest version of the template repository, else it will use the templateSha setting in the .github/AL-Go-Settings file

# Get Repo settings as a hashtable (do NOT read any specific project settings, nor any specific workflow, user or branch settings)
$repoSettings = ReadSettings -buildMode '' -project '' -workflowName '' -userName '' -branchName '' | ConvertTo-HashTable -recurse
$repoSettings = ReadSettings -buildMode '' -project '' -workflowName '' -userName '' -branchName '' -trigger '' | ConvertTo-HashTable -recurse
$templateSha = $repoSettings.templateSha

# If templateUrl has changed, download latest version of the template repository (ignore templateSha)
Expand All @@ -61,6 +61,7 @@ if ($repoSettings.templateUrl -ne $templateUrl -or $templateSha -eq '') {
}

$originalTemplateFolder = $null
$templateRepoSettings = $null
$templateFolder = DownloadTemplateRepository -token $token -templateUrl $templateUrl -templateSha ([ref]$templateSha) -downloadLatest $downloadLatest
$templateFolder = GetSrcFolder -repoType $repoSettings.type -templateUrl $templateUrl -templateFolder $templateFolder
Write-Host "Template Folder: $templateFolder"
Expand All @@ -71,42 +72,40 @@ $templateInfo = "$templateOwner/$($templateUrl.Split('/')[4])"

$isDirectALGo = IsDirectALGo -templateUrl $templateUrl
if (-not $isDirectALGo) {
$templateRepoSettingsFile = Join-Path $templateFolder $RepoSettingsFile
if (Test-Path -Path $templateRepoSettingsFile -PathType Leaf) {
$templateRepoSettings = Get-Content $templateRepoSettingsFile -Encoding UTF8 | ConvertFrom-Json | ConvertTo-HashTable -Recurse
if ($templateRepoSettings.Keys -contains "templateUrl" -and $templateRepoSettings.templateUrl -ne $templateUrl) {
# The template repository is a url to another AL-Go repository (a custom template repository)
Trace-Information -Message "Using custom AL-Go template repository"

# TemplateUrl and TemplateSha from .github/AL-Go-Settings.json in the custom template repository points to the "original" template repository
# Copy files and folders from the custom template repository, but grab the unmodified file from the "original" template repository if it exists and apply customizations
# Copy .github/AL-Go-Settings.json to .github/templateRepoSettings.doNotEdit.json (will be read before .github/AL-Go-Settings.json in the final repo)
# Copy .AL-Go/settings.json to .github/templateProjectSettings.doNotEdit.json (will be read before .AL-Go/settings.json in the final repo)

Write-Host "Custom AL-Go template repository detected, downloading the 'original' template repository"
$originalTemplateUrl = $templateRepoSettings.templateUrl
if ($templateRepoSettings.Keys -contains "templateSha") {
$originalTemplateSha = $templateRepoSettings.templateSha
}
else {
$originalTemplateSha = ""
}
# Get template Repo settings as a hashtable (do NOT read any variable settings, specific project settings, nor any specific workflow, user or branch settings)
$templateRepoSettings = ReadSettings -baseFolder $templateFolder -buildMode '' -project '' -workflowName '' -userName '' -branchName '' -trigger '' -orgSettingsVariableValue '' -repoSettingsVariableValue '' -environmentSettingsVariableValue '' | ConvertTo-HashTable -recurse
if ($templateRepoSettings.templateUrl -and $templateRepoSettings.templateUrl -ne $templateUrl) {
# The template repository is a url to another AL-Go repository (a custom template repository)
Trace-Information -Message "Using custom AL-Go template repository"

# TemplateUrl and TemplateSha from .github/AL-Go-Settings.json in the custom template repository points to the "original" template repository
# Copy files and folders from the custom template repository, but grab the unmodified file from the "original" template repository if it exists and apply customizations
# Copy .github/AL-Go-Settings.json to .github/templateRepoSettings.doNotEdit.json (will be read before .github/AL-Go-Settings.json in the final repo)
# Copy .AL-Go/settings.json to .github/templateProjectSettings.doNotEdit.json (will be read before .AL-Go/settings.json in the final repo)

Write-Host "Custom AL-Go template repository detected, downloading the 'original' template repository"
$originalTemplateUrl = $templateRepoSettings.templateUrl
if ($templateRepoSettings.Keys -contains "templateSha") {
$originalTemplateSha = $templateRepoSettings.templateSha
}
else {
$originalTemplateSha = ""
}

# Download the "original" template repository - use downloadLatest if no TemplateSha is specified in the custom template repository
$originalTemplateFolder = DownloadTemplateRepository -token $token -templateUrl $originalTemplateUrl -templateSha ([ref]$originalTemplateSha) -downloadLatest ($originalTemplateSha -eq '')
$originalTemplateFolder = GetSrcFolder -repoType $repoSettings.type -templateUrl $originalTemplateUrl -templateFolder $originalTemplateFolder
# Download the "original" template repository - use downloadLatest if no TemplateSha is specified in the custom template repository
$originalTemplateFolder = DownloadTemplateRepository -token $token -templateUrl $originalTemplateUrl -templateSha ([ref]$originalTemplateSha) -downloadLatest ($originalTemplateSha -eq '')
$originalTemplateFolder = GetSrcFolder -repoType $repoSettings.type -templateUrl $originalTemplateUrl -templateFolder $originalTemplateFolder

Write-Host "Original Template Folder: $originalTemplateFolder"
Write-Host "Original Template Folder: $originalTemplateFolder"

# Set TemplateBranch and TemplateOwner
# Keep TemplateUrl and TemplateSha pointing to the custom template repository
$templateBranch = $originalTemplateUrl.Split('@')[1]
$templateOwner = $originalTemplateUrl.Split('/')[3]
# Set TemplateBranch and TemplateOwner
# Keep TemplateUrl and TemplateSha pointing to the custom template repository
$templateBranch = $originalTemplateUrl.Split('@')[1]
$templateOwner = $originalTemplateUrl.Split('/')[3]

$isDirectALGo = IsDirectALGo -templateUrl $originalTemplateUrl
if ($isDirectALGo) {
Trace-Information -Message "Original template repository is direct AL-Go"
}
$isDirectALGo = IsDirectALGo -templateUrl $originalTemplateUrl
if ($isDirectALGo) {
Trace-Information -Message "Original template repository is direct AL-Go"
}
}
}
Expand All @@ -115,7 +114,7 @@ if (-not $isDirectALGo) {
$baseFolder = $ENV:GITHUB_WORKSPACE
$projects = @(GetProjectsFromRepository -baseFolder $baseFolder -projectsFromSettings $repoSettings.projects)

$filesToInclude, $filesToExclude = GetFilesToUpdate -settings $repoSettings -projects $projects -baseFolder $baseFolder -templateFolder $templateFolder -originalTemplateFolder $originalTemplateFolder
$filesToInclude, $filesToExclude, $filesToRemove = GetFilesToUpdate -settings $repoSettings -projects $projects -baseFolder $baseFolder -templateFolder $templateFolder -templateSettings $templateRepoSettings -originalTemplateFolder $originalTemplateFolder

# $updateFiles will hold an array of files, which needs to be updated
$updateFiles = @()
Expand Down Expand Up @@ -203,8 +202,8 @@ foreach($fileToInclude in $filesToInclude) {
}

Push-Location -Path $baseFolder
# Remove files that are in $filesToExclude and exist in the repository
$removeFiles = $filesToExclude | Where-Object { $_ -and (Test-Path -Path $_.destinationFullPath -PathType Leaf) } | ForEach-Object {
# Remove files that are in $filesToExclude or $filesToRemove and exist in the repository
$removeFiles = @($filesToExclude) + @($filesToRemove) | Where-Object { $_ -and (Test-Path -Path $_.destinationFullPath -PathType Leaf) } | ForEach-Object {
$relativePath = Resolve-Path -Path $_.destinationFullPath -Relative
Write-Host "File marked for removal: $relativePath"
$relativePath
Expand Down
10 changes: 10 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### Enhanced `customALGoFiles` setting

The `customALGoFiles` setting of a custom template was only applied on the next Update (from `AL-Go-TemplateRepoSettings.doNotEdit.json`). Now the up-to-date settings of the custom template are used directly during "Update AL-Go System Files". The template's `filesToInclude`, `filesToExclude`, and `filesToRemove` settings are merged with the consumer repo's settings before resolution.

- **`filesToInclude`** now also resolves files from the original AL-Go template. Files present in the official template that are not overridden by your custom template are propagated to consumer repos. When a file exists in both, the custom template version takes precedence.
- **`filesToExclude`** now also resolves files from the original AL-Go template (same dual-resolution as `filesToInclude`). Files resolved by `filesToInclude` whose source matches a `filesToExclude` entry are not copied to consumer repos, and existing copies are removed.
- **`filesToRemove`** (new property): Unconditionally removes matching files from consumer repos. Files are searched in both the template and end repository. Takes precedence over `filesToInclude`. Entries use `sourceFolder` (relative to the template), `filter`, and optionally `destinationFolder` and `perProject`.

Read more at [Customizing AL-Go for GitHub](Scenarios/CustomizingALGoForGitHub.md#Using-custom-template-files).

### Use artifact manifest to pick .NET runtime for assembly probing

When compiling apps with the workspace compiler, AL-Go now reads the `dotNetVersion` from the BC artifact's `manifest.json` (copied into the compiler folder by BcContainerHelper) and selects an installed .NET runtime whose major version matches. This avoids version drift between the build agent's highest installed runtime and the platform the artifact was built against. If the manifest does not declare a `dotNetVersion`, or no installed runtime matches the required major, versioned .NET assembly probing paths are omitted (a warning is logged in the latter case).
Expand Down
Loading