Skip to content

Commit f157a40

Browse files
authored
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 <[email protected]>
1 parent 4b5caab commit f157a40

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

AppHandling/Compile-AppInNavContainer.ps1

+16-5
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,15 @@ try {
224224
$CustomCodeCopFiles = @()
225225
if ($CustomCodeCops.Count -gt 0) {
226226
$CustomCodeCops | ForEach-Object {
227-
$customCopPath = Get-BcContainerPath -containerName $containerName -path $_
228-
if ("$customCopPath" -eq "") {
229-
throw "The custom code cop ($_) is not shared with the container."
227+
if ($_ -like 'https://*') {
228+
$customCopPath = $_
229+
}
230+
else {
231+
$customCopPath = Get-BcContainerPath -containerName $containerName -path $_
232+
if ("$customCopPath" -eq "") {
233+
throw "The custom code cop ($_) is not shared with the container."
234+
}
230235
}
231-
232236
$CustomCodeCopFiles += $customCopPath
233237
}
234238
}
@@ -670,7 +674,14 @@ try {
670674
}
671675

672676
if ($CustomCodeCops.Count -gt 0) {
673-
$CustomCodeCops | ForEach-Object { $alcParameters += @("/analyzer:$_") }
677+
$CustomCodeCops | ForEach-Object {
678+
$analyzerFileName = $_
679+
if ($_ -like 'https://*') {
680+
$analyzerFileName = Join-Path $binPath "Analyzers/$(Split-Path $_ -Leaf)"
681+
Download-File -SourceUrl $_ -destinationFile $analyzerFileName
682+
}
683+
$alcParameters += @("/analyzer:$analyzerFileName")
684+
}
674685
}
675686

676687
if ($rulesetFile) {

AppHandling/Run-AlPipeline.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ Param(
387387
)
388388

389389
function CheckRelativePath([string] $baseFolder, [string] $sharedFolder, $path, $name) {
390-
if ($path) {
390+
if ($path -and $path -notlike 'https://*') {
391391
if (-not [System.IO.Path]::IsPathRooted($path)) {
392392
if (Test-Path -path (Join-Path $baseFolder $path)) {
393393
$path = Join-Path $baseFolder $path -Resolve
@@ -513,7 +513,7 @@ if ($customCodeCops -is [String]) { $customCodeCops = @($customC
513513
$appFolders = @($appFolders | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "appFolders" } | Where-Object { Test-Path $_ } )
514514
$testFolders = @($testFolders | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "testFolders" } | Where-Object { Test-Path $_ } )
515515
$bcptTestFolders = @($bcptTestFolders | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "bcptTestFolders" } | Where-Object { Test-Path $_ } )
516-
$customCodeCops = @($customCodeCops | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "customCodeCops" } | Where-Object { Test-Path $_ } )
516+
$customCodeCops = @($customCodeCops | ForEach-Object { CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $_ -name "customCodeCops" } | Where-Object { $_ -like 'https://*' -or (Test-Path $_) } )
517517
$buildOutputFile = CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $buildOutputFile -name "buildOutputFile"
518518
$containerEventLogFile = CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $containerEventLogFile -name "containerEventLogFile"
519519
$testResultsFile = CheckRelativePath -baseFolder $baseFolder -sharedFolder $sharedFolder -path $testResultsFile -name "testResultsFile"

CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1

+8-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,14 @@ try {
366366
}
367367

368368
if ($CustomCodeCops.Count -gt 0) {
369-
$CustomCodeCops | ForEach-Object { $alcParameters += @("/analyzer:$_") }
369+
$CustomCodeCops | ForEach-Object {
370+
$analyzerFileName = $_
371+
if ($_ -like 'https://*') {
372+
$analyzerFileName = Join-Path $binPath "Analyzers/$(Split-Path $_ -Leaf)"
373+
Download-File -SourceUrl $_ -destinationFile $analyzerFileName
374+
}
375+
$alcParameters += @("/analyzer:$analyzerFileName")
376+
}
370377
}
371378

372379
if ($rulesetFile) {

ReleaseNotes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
6.0.16
22
Issue 3477 Regression: Error: App filenames must be unique
33
Issue 3478 New-bccontainer fails on BC24 using option -UseNewDatabase
4+
Allow CustomCodeCops to be a URL for just-in-time download instead of a file shared with the container
45

56
6.0.15
67
Issue 3467 Can't create a backup of a container with the Backup-BCContainerDatabases commandlet

0 commit comments

Comments
 (0)