Skip to content
Codeblack edited this page Mar 12, 2017 · 1 revision

The PowerShell scripts need to be in version control, and be part of the build-definition workspace, so the TFS Build Agent has access to them.

This page describes how to get the scripts, how to add them to source control and how to make them available in a build-definition.

Get the scripts

At this moment, you need to download the scripts from the src folder.

I'm looking at creating a NuGet and a Chocolatey package. The NuGet-package will add the build-scripts to a project/solution. The Chocolatey-package will just be an easy way to get the scripts and upgrade them. You'll still need to add the scripts into source-control.

Add to source control

Basically, there are two options: add the scripts to each solution you build, or add it to a central location and re-use it from there.

Adding the scripts to each solution provides the most flexibility, as you can modify the scripts without impacting other solutions. The downside of this can be, that you may end up with a lot of different scripts.

Adding the scripts to a central location saves you from adding the scripts to each solution. This still provides flexibility, since the scripts are controlled using parameters that are specified in each build-definition.

Add scripts to a solution

To add the scripts to a solution, you add them into a solution-folder, as shown in the image below. I recommend you use a physical folder with the same name as the solution-folder. The name itself is not important.

Add scripts to solution

Alternatively, you can add them to a specific project.

Add scripts to central location

I usually create a team-project in each team-project collection, that will hold custom assemblies (e.g. xUnit.NET, NUnit) and reusable scripts. This is the perfect location for the build-scripts, as shown in the following image.

Add scripts to central location

Make scripts available in a build-definition

The build agent needs the scripts to be in the workspace of the build-definition, so you need to make sure the scripts are part of that workspace.

If you've added the scripts to the solution, you most likely don't need to do anything. As long as you have the solution root-folder as part of the workspace, and not explicitly exclude the folder containing the scripts, the scripts will be available.

Workspace with scripts in solution

When the scripts are available through a central location in source-control, you need to add that location to the workspace of each build-definition.

Workspace with scripts in central location

Now you're ready to use the scripts.

Clone this wiki locally