2015-05-09

SourceLink.MSBuild uploaded to NuGet Gallery

Microsoft open sourced MSBuild a couple of months ago under the very open MIT License. I just published three of the assemblies in a SourceLink.MSBuild NuGet package earlier this week from my branch. The package contains the Build assembly and its two dependencies: Build.Framework and Build.Utilities.Core. The assemblies have a SourceLink prefix instead of Microsoft to avoid conflict. The namespace and code remain the same and all tests pass. The pdb files are included in the package and they are source indexed of course.

Why?

SourceLink gets a list of files to source index from MSBuild project files. As I mentioned in my last post, the $(VisualStudioVersion) is used by Visual Studio 2013 and higher versions after they decided to bundle MSBuild. Unfortunately, the MSBuild libraries bundled with .NET 4 do not set that property correctly. This makes sense, since they predate VS 2013. The libraries included with VS could be used, but I do not know how to reference the latest version. Creating and using this NuGet package solves the problem.

Building MSBuild

Building and packaging the open source MSBuild package ended up being more work than I thought it would be. Here is a list of all the changes, most dealing with the renaming of the assemblies. A big thanks to AppVeyor for proving the build service. Build #50 on AppVeyor ended up being the official build for the published package. I created a build.ps1 PowerShell script. Here the final part of that build running on AppVeyor:


build.ps1 Highlights

There is a lot going on in the 75 line build.ps1 file. It probably deserves a blog post. Here I'm going to highlight using SourceLink.exe to do the source indexing and using Paket to build the NuGet package.

Here I install SourceLink.exe via Chocolatey.


SourceLink.exe index is run on each of the project files after the are built. This source indexes each of the pdb files that were built. I'm making use of iex, an alias for Invoke-Expression, which simply lets me create the command dynamically.


Here is the paket command and paket.template I used, although it looks like a couple of tabs snuck in along with a misspelling. The important stuff is correct like the dependency on Tpl.Dataflow.



I started using paket pack last week for this project and a couple others at work rather than nuget pack and I like it.