From f157a40f342e08a9e8b3534de933b84a093ae83b Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Mon, 15 Apr 2024 10:33:59 +0200 Subject: [PATCH] Customcodecops (#3488) Allow CustomCodeCops to be a URL (instead of a file shared with the container) f.ex. https://github.com/StefanMaron/BusinessCentral.LinterCop/releases/download/v0.30.0/BusinessCentral.LinterCop.current.dll Remember that some customCodeCops requires you to set vsixFile = latest as well. --------- Co-authored-by: freddydk --- AppHandling/Compile-AppInNavContainer.ps1 | 21 ++++++++++++++----- AppHandling/Run-AlPipeline.ps1 | 4 ++-- .../Compile-AppWithBcCompilerFolder.ps1 | 9 +++++++- ReleaseNotes.txt | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/AppHandling/Compile-AppInNavContainer.ps1 b/AppHandling/Compile-AppInNavContainer.ps1 index 1eb0d0ad1..a2742c7e1 100644 --- a/AppHandling/Compile-AppInNavContainer.ps1 +++ b/AppHandling/Compile-AppInNavContainer.ps1 @@ -224,11 +224,15 @@ try { $CustomCodeCopFiles = @() if ($CustomCodeCops.Count -gt 0) { $CustomCodeCops | ForEach-Object { - $customCopPath = Get-BcContainerPath -containerName $containerName -path $_ - if ("$customCopPath" -eq "") { - throw "The custom code cop ($_) is not shared with the container." + if ($_ -like 'https://*') { + $customCopPath = $_ + } + else { + $customCopPath = Get-BcContainerPath -containerName $containerName -path $_ + if ("$customCopPath" -eq "") { + throw "The custom code cop ($_) is not shared with the container." + } } - $CustomCodeCopFiles += $customCopPath } } @@ -670,7 +674,14 @@ try { } if ($CustomCodeCops.Count -gt 0) { - $CustomCodeCops | ForEach-Object { $alcParameters += @("/analyzer:$_") } + $CustomCodeCops | ForEach-Object { + $analyzerFileName = $_ + if ($_ -like 'https://*') { + $analyzerFileName = Join-Path $binPath "Analyzers/$(Split-Path $_ -Leaf)" + Download-File -SourceUrl $_ -destinationFile $analyzerFileName + } + $alcParameters += @("/analyzer:$analyzerFileName") + } } if ($rulesetFile) { diff --git a/AppHandling/Run-AlPipeline.ps1 b/AppHandling/Run-AlPipeline.ps1 index 6f9fd388e..1433a925d 100644 --- a/AppHandling/Run-AlPipeline.ps1 +++ b/AppHandling/Run-AlPipeline.ps1 @@ -387,7 +387,7 @@ Param( ) function CheckRelativePath([string] $baseFolder, [string] $sharedFolder, $path, $name) { - if ($path) { + if ($path -and $path -notlike 'https://*') { if (-not [System.IO.Path]::IsPathRooted($path)) { if (Test-Path -path (Join-Path $baseFolder $path)) { $path = Join-Path $baseFolder $path -Resolve @@ -513,7 +513,7 @@ if ($customCodeCops -is [String]) { $customCodeCops = @($customC $appFolders = @($appFolders | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "appFolders" } | Where-Object { Test-Path $_ } ) $testFolders = @($testFolders | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "testFolders" } | Where-Object { Test-Path $_ } ) $bcptTestFolders = @($bcptTestFolders | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "bcptTestFolders" } | Where-Object { Test-Path $_ } ) -$customCodeCops = @($customCodeCops | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "customCodeCops" } | Where-Object { Test-Path $_ } ) +$customCodeCops = @($customCodeCops | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "customCodeCops" } | Where-Object { $_ -like 'https://*' -or (Test-Path $_) } ) $buildOutputFile = CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $buildOutputFile -name "buildOutputFile" $containerEventLogFile = CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $containerEventLogFile -name "containerEventLogFile" $testResultsFile = CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $testResultsFile -name "testResultsFile" diff --git a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 index b203d0bd1..0a483ee2f 100644 --- a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 +++ b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 @@ -366,7 +366,14 @@ try { } if ($CustomCodeCops.Count -gt 0) { - $CustomCodeCops | ForEach-Object { $alcParameters += @("/analyzer:$_") } + $CustomCodeCops | ForEach-Object { + $analyzerFileName = $_ + if ($_ -like 'https://*') { + $analyzerFileName = Join-Path $binPath "Analyzers/$(Split-Path $_ -Leaf)" + Download-File -SourceUrl $_ -destinationFile $analyzerFileName + } + $alcParameters += @("/analyzer:$analyzerFileName") + } } if ($rulesetFile) { diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 20b0d3d12..09b8a7d48 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,6 +1,7 @@ 6.0.16 Issue 3477 Regression: Error: App filenames must be unique Issue 3478 New-bccontainer fails on BC24 using option -UseNewDatabase +Allow CustomCodeCops to be a URL for just-in-time download instead of a file shared with the container 6.0.15 Issue 3467 Can't create a backup of a container with the Backup-BCContainerDatabases commandlet