This is a quick post on how to get control over git checkout in Azure DevOps.
In Azure DevOps (Microsoft ALM solution), Azure Build Pipelines are always defined from a git repository that can come from different type of hosting system (Azure Repo, GitHub, BitBucket, etc.).
By default, an Azure Build Pipeline will always do a checkout of the code source. This is usually fine in most of cases but in some of them you may want to have control on the checkout, for instance if you want to load submodules or if you want to use LFS.
In our case, we need to checkout the source code on a Windows system to do some code quality checks. So it is mandatory git option AutoCRLF is disabled. Here is how we can do it easily:
pool: vmImage: windows-latest steps: - script: "git config --global core.autocrlf false" displayName: "Configure Git" - checkout: self displayName: "Clone repository" - task: UseDotNet@2 displayName: "Get .NET SDK $(dotnet.sdk.version)" inputs: packageType: "sdk" version: $(dotnet.sdk.version) - script: | dotnet tool update -g dotnet-format dotnet format --check --verbosity diagnostic displayName: "Check .NET format"
We just have to save and run to see it the build is successful and we can now use “dotnet format –check” option:
More information on Pipeline options for Git repositories documentation page.