DEV Community

Discussion on: Understanding the directory structure created by Azure DevOps tasks.

Collapse
 
dcparsons profile image
Doug Parsons • Edited

Great article!

I think the one thing that should be pointed out is that none of these folders are guaranteed to have anything in them, depending on how your build is configured.

For example, if I have a set of steps in my YAML that look like this:

steps:

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

The only folder that is going to have anything in it is the 's' directory because that is where the build agent clones the source to. The build would then run inside the 's' folder and the output would be directed to whatever folder was configured in the projects (usually bin), so our output would live in /a/1/s/bin/myassembly.dll

You don't actually have to use any of the folders that the build agent provides variables for at all if you don't want to. If you wanted to send your build output to a directory called output you could do something like the following (some code omitted for brevity)

variables:
  base-output-directory: '$(Agent.BuildDirectory)\output'
...
steps:
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(build-platform)'
    configuration: '$(build-configuration)'
    msbuildArgs: /p:OutDir=$(base-output-directory)

This would send the output of our solution to /a/1/output.

Finally, a little of "the devil is in the details": if you find yourself needing to have different folders in your build directory, keep the folder names short and sweet. The folder names 'a', 'b', and 's' are done intentionally (probably for a number of reasons) but they help to reduce the chance of pathing errors. What I mean is that if your build agent is running on Windows, you can't have a file path longer than 259 characters. If the folder names were more descriptive (artifacts, binaries, source) those are additional characters that count against the total path. While this may seem like an edge case, one of the projects I maintain has this very problem because some developers decided to get overly descriptive in their class and folder naming structures.

Keep up the good work!