I'm trying to get into using Azure Devops Pipelines, and my first pet project is a simple .NET command line app I'm trying to get to be built.
I picked the "VS Build .NET Desktop" task template, and the build per se works fine - the bits are compiled without trouble
YAML:
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Log:
##[section]Starting: VSBuild
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.151.2
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "d:\a\1\s\AzureDevopsTaskCreator.sln"
...(lots of lines omitted)
CopyFilesToOutputDirectory:
Copying file from "d:\a\1\s\obj\Release\AZTaskCreator.exe" to "d:\a\1\s\bin\Release\AZTaskCreator.exe".
AZTaskCreator -> d:\a\1\s\bin\Release\AZTaskCreator.exe
Copying file from "d:\a\1\s\obj\Release\AZTaskCreator.pdb" to "d:\a\1\s\bin\Release\AZTaskCreator.pdb".
But now I wanted to somehow publish the output from this build so I could download it (or deploy it somewhere). But I've been struggling with getting these things hooked up.
So I tried to first zip the build output into an archive (which could then be published):
YAML
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/AZCreateTasks$(Build.BuildId).zip'
replaceExistingArchive: true
verbose: true
Log:
##[section]Starting: ArchiveFiles
##[command]d:\a\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\2.151.2\7zip\7z.exe a -tzip -bb3 d:\a\1\a\AZCreateTasks8.zip @d:\a\_temp\yat6561e8redmiomp7bbuik9
My problem is: HOW can I tell the "Archive Files" step to use the output directory of the previous build? I was assuming that the default $(Build.BinariesDirectory)
would do that - but obviously, it doesn't:
d:\a\1\s\bin\Release\
directoryd:\a\_temp\yat6561e8redmiomp7bbuik9
directoryHow can I "connect" these two steps so that the "Archive Files" step actually respects and uses the output directory of the VS Build step??
I'm having a terribly hard time finding any useful documentation on what kind of "system pre-defined" magic variables are in play here, and how to influence these .....
A Build Pipeline is used to generate Artifacts out of Source Code. A Release Pipeline consumes the Artifacts and conducts follow-up actions within a multi-staging system. It is best practice to establish a link between a Build Pipeline and the corresponding Release Pipeline.
Azure DevOps supports two forms of version control - Git and Azure Repos. Any changes you push to your version control repository will be automatically built and validated.
Key differencesGitHub Actions uses YAML files to define workflows and does not support a graphical editor. Azure Pipelines allows you to omit some structure in job definitions. For example, if you only have a single job, you don't need to define the job and only need to define its steps.
According to the log, the build output is in d:\a\1\s\...
the s
folder it the sources directory, to access this folder there is pre-defined varaible: Build.SourcesDirectory
.
So instead of using $(Build.BinariesDirectory)
use the above variable:
rootFolderOrFile: '$(Build.SourcesDirectory)'
But now you will get a zip with the sources files including the dll's, so consider to append the path until the folder/s you want.
For example:
rootFolderOrFile: '$(Build.SourcesDirectory)/obj/Release'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With