Today’s release brings some improvements to the way you build your ReadyRoll database projects.
These changes make it easier to do Continuous Integration with ReadyRoll, whether you’re building your projects on self-hosted hardware (eg. with TeamCity or TFS Build), or in the cloud (eg. with AppHarbor or Bamboo OnDemand).
Previously you need to manually install a whole bunch of software on your build agent to deploy and test your database projects. This included Visual Studio 2012/Visual Studio 2010 with SP1, SQL Server Data Tools, ReadyRoll itself plus a handful of client tools.
Now, with the power of Chocolatey and NuGet, this process has been made a whole lot simpler. This coupled with the fact that ReadyRoll build agent licenses are free (as in beer). This gives you the flexibility to scale your Continuous Integration/Delivery environment without incurring additional cost. It also means no messy software activation steps to run on your build agents!
Installing Build Agent Pre-Requisites with Chocolatey
Before getting started, ReadyRoll’s most basic requirement is that the host system is running one of the following operating systems:
- Windows Server 2008 R2 SP1
- Windows Server 2012
- Windows 7 SP1
- Windows 8
Once you’ve got an operating system up-and-running, you’ll need to get the supporting software installed. This includes:
- SQL Server Data Tools
Provides build-time support for SQL parsing and .NET CLR compilation.
- SQL Server Express 2012
Allows ReadyRoll to test the deployment of your database on a stand-alone instance of SQL Server (referred to as a Shadow build).
Now if you have some time to burn you could go ahead and download these and manually click-through the dozens of dialog boxes needed to get them installed. However if you’d rather have a coffee break so you can think about how awesome it will be when your database builds are automated (as some of us do!), then Chocolatey could be your saviour today.
To install the pre-requisites above, including Chocolatey, open a command prompt in administrator mode and run the following:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin CALL cinst SSDT11 CALL cinst MsSqlServer2012Express @ECHO Adding [NT AUTHORITY\Authenticated Users] to sysadmin role on local SQL instance "%ProgramFiles%\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -S . -E -Q "ALTER SERVER ROLE [sysadmin] ADD MEMBER [BUILTIN\Users];"
That’s it! Well, it may take a little while to install but you won’t be prompted during the installation (your acceptance of the Microsoft EULA’s is implied; see more legal stuff here).
Oh and that last command (
ALTER SERVER ROLE...) just ensures that your build agent can access the newly-installed SQLEXPRESS instance (which becomes the default SQL Server instance on the machine). You might choose to make this access more restrictive if you know which user your build agent will run-as.
Bootstrapping Build-Time Dependencies with NuGet
In an ideal world, all the software that is needed to produce a build would be checked into source control so we wouldn’t need to install any software on the build server; a key tenet of Continuous Delivery is that builds should be reproducible, and changes in the software environment can often result in inconsistent build artifacts being produced.
Though you can’t yet bootstrap an instance of SQL Server Express or even the Data Tools to your project code, ReadyRoll 1.4.3 does at least allow you to commit its build-time dependencies to source control using the power of NuGet. This means that you can rely on the outcome of your database builds to be consistent between deployment environments (ie. TEST/QA/PROD). It also means that there’s nothing extra to install on your build agents to get your ReadyRoll builds to work.
To integrate the build-time dependencies into your project, open the Package Manager Console tool-window and install the package from the NuGet gallery:
This will install the package into the current solution, rather than into a specific Database Project within the solution. This is a current limitation in NuGet, so to work around this we’ll need to link the page to the database project manually.
To do this, firstly select the ReadyRoll Database Project in the Solution Explorer, then click Project… Unload Project.
Then, right-click the project in the Solution Explorer and click Edit Project.
<ReadyRollTargetsPath> element and replace the contents as follows:
<PropertyGroup> <ReadyRollTargetsPath>..\packages\ReadyRoll.MsBuild.18.104.22.168\tools\ReadyRoll.Data.Schema.SSDT.targets</ReadyRollTargetsPath> </PropertyGroup>
Save the project file, then right-click the project in the Solution Explorer and select Reload Project
Confirm that the build-time dependencies have been successfully linked to the project by building the solution:
Now commit the solution/project changes along with the package files to source control.
Congratulations, your build agents are now ready to roll your database projects!
Head to the ReadyRoll website to grab Version 1.4.3 now!