13

I'm attempting to build an ASP.NET vNext project in TeamCity. When it tries to build, I get the following error:

C:\...\MyApp.kproj(7, 3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AspNet\Microsoft.Web.AspNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

The file it's looking for is actually located at C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AspNet\Microsoft.Web.AspNet.Props

I'm assuming that I need to get TeamCity to use the version of msbuild that ships with Visual Studio 2015. Is this even possible?

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
w.brian
  • 16,296
  • 14
  • 69
  • 118

3 Answers3

12

Edit: As of TeamCity 9.x, all works out of the box, but for earlier versions, the below is a solution.

The project import problem should be solved by setting a env.VSToolsPath environment property to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0.

However, you will not be able to build using the TeamCity included MSBuild runner. But using a command-line runner is very simple. I extracted a meta-runner like this. It has almost the same functionality as the included TeamCity MSBuild 2013 runner. If you need more configurability, just add more parameters.

My meta-runner ended up looking like this:

<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="MSBuild 2015">
  <description>MSBuild 2015 command line runner</description>
  <settings>
    <parameters>
      <param name="solutionFile" />
      <param name="target" value="Build" />
    </parameters>
    <build-runners>
      <runner name="MSBuild 2015" type="simpleRunner">
        <parameters>
          <param name="command.executable" value="C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" />
          <param name="command.parameters" value="/v:m /m /t:%target% %solutionFile%" />
          <param name="teamcity.step.mode" value="default" />
        </parameters>
      </runner>
    </build-runners>
    <requirements />
  </settings>
</meta-runner>

Note: TeamCity 9.1, due for Q2 2015 is expected to build VS2015 projects natively.

Erik A. Brandstadmoen
  • 10,430
  • 2
  • 37
  • 55
  • 1
    This worked like a charm for TeamCity 8.x. We now have MS Build Tools for 2015 working using meta runners. Nicely done, Erik! Thanks! – StephenPAdams Jan 12 '16 at 20:46
  • 2
    Glad it worked for you. Do note that in TeamCity 9.x, everything just works out-of-the-box, so I would recommend to upgrade if that is an option for you. – Erik A. Brandstadmoen Jan 13 '16 at 08:17
2

An alternative workaround is to simply replace the 12.0 tools with 14.0 tools. I just downloaded the lastest Visual Studio 2015 (Update 2) build tools. Installed it on my agents and

  1. Renamed C:\Program Files (x86)\MSBuild\12.0 => C:\Program Files (x86)\MSBuild\12.0-old

  2. Copied C:\Program Files (x86)\MSBuild\14.0 => C:\Program Files (x86)\MSBuild\12.0

Works! You need to have the 14.0-tools in both 12 and 14 folder for things to work.

Merrimack
  • 1,736
  • 14
  • 12
0

Per JetBrains, it is not directly supported, although it should be possible using TeamCity's command line runners.

w.brian
  • 16,296
  • 14
  • 69
  • 118