Pass parameters from TeamCity to nuspec files

Aim: Pass parameters from TeamCity to nuspec files in order to set the solution configuration from TeamCity.

In TeamCity, create a new system parameter in the Parameters page of project. In this case, the parameter DatabaseConfiguration sets which solution configuration will be built (e.g. Full = all projects, Partial = only newly updated projects).
1 tc_system_parameter
In the Visual Studio (sln) build step, set Configuration to


and set Command Line Parameters to


2 tc_build_parameters
In the SSDT projects, update the .nuspec files, e.g. update Accounts.nuspec to

<?xml version="1.0"?>
<package xmlns="">
<authors>Deirdre OLeary</authors>
<description>Package for Accounts</description>
      <file src="\bin\$DatabaseConfiguration$\Deploy.ps1" />
      <file src="\bin\$DatabaseConfiguration$\Accounts.dacpac" target="Content" />

This method is particularly useful for composite projects where the Accounts project has a reference (Same Database) to a snapshot of the Accounts-Base project (e.g. because Accounts-Base contains the “old” unchanging objects & Accounts contains only newly updated objects). In this case, to ensure that the Accounts-Base snapshot is included in the .nupkg, include the following line in the .nuspec file.

      <file src="\bin\$DatabaseConfiguration$\Accounts-Base*.dacpac" target="Content" />

When building from TeamCity, you will see the following warning in the log.

MSBuild command line parameters contain "/property:" or "/p:". It is recommended to define System Property on Build Parameters instead.

However, I have not yet found a way to pass the parameter to the .nuspec file without using “/p”.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Kevin Kline

Career and Technical Advice for the IT Professional


Explaining the bits and bytes of SQL Server and Azure

SQL Authority with Pinal Dave

SQL Server Performance Tuning Expert


A blog about PowerShell and general Windows sysadmin stuff

Simon Learning SQL Server

I'm trying to become "better" at SQL Server and data - here's how I'm doing it!

%d bloggers like this: