Azure Pipelines predefined variables and directory structure
Kohei Kawata
Posted on January 3, 2022
Summary
In this article, I would like to share my learnings about the directory structure of Azure pipeline Microsoft-hosted agents. This code sample includes the ready-to-use Azure pipelines with windows-2019
and windows-2022
.
TOC
Predefined variables
Azure Pipelines have predefined variables which you can use on your pipelines. There are different directory variables, some of which overlap, some of them are under a different partition. I am trying to describe those predefined variables below.
windows-2019 (Microsoft-hosted agent)
-
Agent.ToolsDirectory
orAgent.TempDirectory
are used for different versions of tools.Agent.ToolsDirectory
is underC:
and then tools are cached and not cleaned up across the pipeline runs.Agent.TempDirectory
is underD:
and then cleaned up after a pipeline run. The code example below lets the pipeline use the cached versions of .NET 6 tools.
- task: UseDotNet@2
displayName: Use .NET 6 sdk
inputs:
packageType: sdk
version: 6.0.x
installationPath: $(Agent.ToolsDirectory)/dotnet
-
Agent.BuildDirectory
andPipeline.Workspace
are atD:\a\1
which is a workspace directory for a particular pipeline. -
Build.StagingDirectory
andBuild.ArtifactStagingDirectory
are atD:\a\1\a
, which is used for where build artifacts are copied before being pushed. -
Build.BinariesDirectory
is atD:\a\1\b
, which is used for compiled binaries. -
Build.SourcesDirectory
andSystem.DefaultWorkingDirectory
are atD:\a\1\a
, which are used for your source code files.
.NET Restore, Build, Publish
dotnet restore
dotnet restore
creates obj
folder and includes some of files regarding Nuget packages.
dotnet build
dotnet build
outputs dll files and exe files under bin
and obj
.
dotnet publish
dotnet publish
outputs dll files and exe files under a pointed folder. For example, the code example outputs files under publish
folder and then those files are zipped. In this case, the project name is TravelApi
and the zip file name is TravelApi.zip
, which is used for Azure App Service deployment. The difference from dotnet build
is TravelApi.zip
includes web.config
in addition to the build files.
Posted on January 3, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024
November 30, 2024