Thursday, 10 May 2012

Portable Class Library Projects and your Build Server

Yesterday my build server started failing on a particular project and after a quick look at the log I found that it simply wasn't building the solution. Peculiar as I knew it built fine on several development machines, however I dug into the logs and found the following:
  •  error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Portable\v4.0\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Oh dear, now I know Portable Class Libraries is an add on so I went to MSDN Visual Studio Gallery and got the installer so that I could chuck it on to the build server.

However when attempting to install I got a great message saying I needed VS2010 and SP1 installed, obviously for a build server this wasn't going to happen. After a bit of digging on MSDN I found that the installer actually has a switch that when used just installs the targets for MSBuild.
To install the Portable Class Library Tools on a build machine without installing Visual Studio 2010, save the download file (PortableLibraryTools.exe) on your computer, and run the installation program from a Command Prompt window. Include the /buildmachine switch on the command line.

Simply run the installer with the /BuildMachine switch and everything installs hunky dory.

PortableLibraryTools.exe  /buildmachine


To my great relief the build server started building again and things went back to normal.

6 comments:

  1. Thanks. This solved that particular mystery for me today.

    ReplyDelete
  2. Awesome! ...and still relevant with Visual Studio 2013 and .NET 4.5

    ReplyDelete
  3. Thanks!!.. you saved me lots of minutes!

    ReplyDelete
  4. I was going in circles and this tip saved me. Thanks a lot

    ReplyDelete
  5. Years passed and this issue happened to me!

    ReplyDelete