Skip to content

Commit

Permalink
Customcodecops (microsoft#3488)
Browse files Browse the repository at this point in the history
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 <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk committed Apr 15, 2024
1 parent 4b5caab commit f157a40
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
21 changes: 16 additions & 5 deletions AppHandling/Compile-AppInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions AppHandling/Run-AlPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f157a40

Please sign in to comment.