Build Artifacts I find are handy for things you want to throw around on the build server, such as command line tools from open source projects, etc.
Where I would make the call over a build artifact vs a package (npm, nuget, etc.) is when it’s something that needs to be run on the developers local, i.e. packages will downlaod to both the build server and the developers local, where as a build artifact is really only designed for use on the build server.
Build Artifacts are also handy for when you need to break builds into multiple builds for stages.
We’ve got a few TFS command line tools that we use to update data in TFS from our TeamCity server, all are built from github projects, so these are good examples of a command line tool we build internally that is only used on the build server itself.
You could use build artifacts for other things as well, but I prefer for anything serious putting it into a package manager, as this allows for better version control management.
The artifact output is controlled from the General Tab in you build’s Configuration Settings.
Once you have at least one successful build run you can use the folder tab to browse the build output and pick what you need (normally in the bin\release folder).
The format you need to use is
SourceFileOrFolder1 => TargetFileOrFolder1
SourceFileOrFolder2 => TargetFileOrFolder2
You can specify a zip file for your output which i would recommend to save space. to do this you simply give it the location in the format of “MyFile.zip!/Subfolder” and it will compress your output into a folder in the zip file.
SourceFileOrFolder1 => TargetZipFile!/TargetFileOrFolder1
SourceFileOrFolder2 => TargetZipFile!/TargetFileOrFolder2
After that’s done you can run a build and check the output in the artifact tab of the completed build
Once you have this working you can then go to other builds and add this output as a dependency.
So in the other builds you will use the dependence tab, as seen below.
And you need to use s similar format to include to files into this build.
SourceArtifactFolderOrFile => TargetBuildDirOutputFodlerOrFile
Again you can also use the ! to browse inside of zip files to pull out content
in the above example if will have the command line app i need in the build output folder under the TfsCreateBuildCmd folder.
So I can now add a build step that calls this command using “TfsCreateBuildCmd\TfsCreateBuild.exe” to call the command and do something.
And it’s that easy 🙂