Azure DevOps

The ALCops extension for Azure DevOps provides pipeline tasks that download, install and configure the ALCops Code Analyzers for your Business Central AL projects. It handles NuGet package resolution, target framework detection and analyzer extraction for your pipelines.

Installation

Install the extension from the Visual Studio Marketplace into your Azure DevOps organization. Once installed, the four ALCops tasks become available in all pipelines across the organization.

Quick Start

The simplest way to get started is to add the ALCopsInstallAnalyzers task and then pass the analyzer DLLs to the AL compiler:

steps:
  - task: ALCopsInstallAnalyzers@0
    inputs:
      tfm: "net8.0"

  # Simplified example.
  # Demonstrates that custom code analyzers must be referenced during compilation
  # so their diagnostics are executed as part of the build process.
  - pwsh: |
        al compile `
            "/project:$(Build.SourcesDirectory)" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.ApplicationCop.dll" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.DocumentationCop.dll" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.FormattingCop.dll" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.LinterCop.dll" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.PlatformCop.dll" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.TestAutomationCop.dll" `
            "/analyzer:$(Build.SourcesDirectory)/.alcops/ALCops.Common.dll"

Tasks

The extension ships four pipeline tasks:

TaskDescription
ALCopsInstallAnalyzersDownload and install ALCops analyzer DLLs
ALCopsDetectTfmFromBCArtifactDetect the target framework from a BC artifact URL
ALCopsDetectTfmFromNuGetDevToolsDetect the target framework from the BC DevTools NuGet package
ALCopsDetectTfmFromMarketplaceDetect the target framework from the AL Language VS Code extension

Instead of hardcoding the TFM, use one of the three DetectTfm tasks to determine the correct value automatically. Pick the approach that matches the data already available in your pipeline.

Auto-detect from BC Artifact

If your pipeline already resolves a BC artifact URL (e.g., via Get-BCArtifactUrl in PowerShell), pass it to ALCopsDetectTfmFromBCArtifact. The task reads the artifact manifest to determine the .NET version used by that BC build.

steps:
  - task: ALCopsDetectTfmFromBCArtifact@0
    name: detectTfm
    inputs:
      artifactUrl: "$(bcArtifactUrl)"

  - task: ALCopsInstallAnalyzers@0
    inputs:
      tfm: "$(detectTfm.tfm)"

Auto-detect from NuGet DevTools

If you use the Microsoft.Dynamics.BusinessCentral.Development.Tools NuGet package for compilation, the DevTools version maps directly to a target framework. Set version to latest, prerelease, or a specific version number.

steps:
  - task: ALCopsDetectTfmFromNuGetDevTools@0
    name: detectTfm
    inputs:
      version: "latest"

  - task: ALCopsInstallAnalyzers@0
    inputs:
      tfm: "$(detectTfm.tfm)"

Auto-detect from VS Marketplace

When you do not have a BC artifact URL or NuGet DevTools version handy, you can detect the TFM from the AL Language VS Code extension published on the Visual Studio Marketplace. The task downloads the extension metadata and inspects the compiler DLL inside.

steps:
  - task: ALCopsDetectTfmFromMarketplace@0
    name: detectTfm
    inputs:
      channel: "current"

  - task: ALCopsInstallAnalyzers@0
    inputs:
      tfm: "$(detectTfm.tfm)"

Set channel to prerelease to match a pre-release AL Language version, or pin to a specific version with the extensionVersion input.

Task Reference

ALCopsInstallAnalyzers

Download and install ALCops analyzer DLLs.

Inputs

InputRequiredDefaultDescription
versionNolatestALCops version to install: latest, prerelease, or an exact version (e.g., 1.2.3).
packageSourceNonugetWhere to download the package: nuget (nuget.org) or local (a .nupkg file on disk).
localPackagePathNoPath to a local .nupkg file. Only used when packageSource is local.
tfmNoTarget framework (net8.0, netstandard2.1, net10.0). Leave empty and provide compilerPath for auto-detection.
compilerPathNoPath to the directory containing Microsoft.Dynamics.Nav.CodeAnalysis.dll. Used for auto-detection when tfm is not set. The directory is searched recursively if the DLL is not in the root.
outputPathNo$(Build.SourcesDirectory)/.alcopsWhere to place the extracted analyzer DLLs.

Output Variables

VariableDescription
alcopsVersionThe installed ALCops analyzer version.
tfmThe target framework that was used (detected or specified).
analyzerPathFull path to the directory containing the extracted analyzer DLLs.
analyzersSemicolon-separated list of analyzer DLL paths.

ALCopsDetectTfmFromBCArtifact

Detect the target framework from a Business Central artifact URL by reading its manifest.

Inputs

InputRequiredDefaultDescription
artifactUrlYesBusiness Central artifact URL (e.g., from Get-BCArtifactUrl).

Output Variables

VariableDescription
tfmThe detected target framework moniker (e.g., net8.0, netstandard2.1).
dotNetVersionThe .NET version string from the artifact manifest (e.g., 8.0.24).

ALCopsDetectTfmFromNuGetDevTools

Detect the target framework from the Microsoft.Dynamics.BusinessCentral.Development.Tools NuGet package version.

Inputs

InputRequiredDefaultDescription
versionNolatestDevTools version: latest, prerelease, or a specific version (e.g., 26.0.12345.0).

Output Variables

VariableDescription
tfmThe detected target framework moniker (e.g., net8.0, netstandard2.1).
devToolsVersionThe resolved DevTools package version.

ALCopsDetectTfmFromMarketplace

Detect the target framework from the AL Language VS Code extension on the Visual Studio Marketplace.

Inputs

InputRequiredDefaultDescription
channelNocurrentWhich channel to check: current (latest stable) or prerelease.
extensionVersionNoPin to a specific AL Language extension version (e.g., 15.0.12345.0). Overrides channel.

Output Variables

VariableDescription
tfmThe detected target framework moniker (e.g., net8.0, netstandard2.1).
extensionVersionThe resolved AL Language extension version.
assemblyVersionThe assembly version of the CodeAnalysis DLL inside the extension.

Example Pipelines

For complete, working pipeline examples that use ALCops, visit dev.azure.com/Arthurvdv/ALCops . These pipelines demonstrate real-world setups including TFM auto-detection, version pinning, and integration with BcContainerHelper.