4

UPDATE:

Just an update as we finally got our licensing fixed and installed Visual Studio 2012 on our build agent. As soon as we finished the install everything built perfectly.

Thank you everyone for all your answers and help. The answer I accepted listed this option as the fourth one to try and we did try everything else and this was all that made it build.

Help when I try to build a WCF library project on my Windows Server 2008 R2 build machine I get this error:

C:\BuildAgent\work\e8ce1d5b0f26c529\Configuration\ECUWeb\EcuWeb.ServiceLib\EcuWeb.ServiceLib.csproj(90, 3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Project Configuration\ECUWeb\EcuWeb.ServiceLib\EcuWeb.ServiceLib.csproj failed.

The build agent has visual studio 2010 and .net4.5 installed however I am using VS2012 on my machine. Is there an SDK I can install or do I have to install VS2012? Also this is a teamcity task that just runs MSBuild on the solution file.

twreid
  • 1,453
  • 2
  • 22
  • 42
  • Have you checked whether following file as specified in error is existing in your build agent? C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets – RinoTom Feb 20 '13 at 12:48
  • Yes, I have checked and the WCF folder doesn't even exist. – twreid Feb 20 '13 at 13:44
  • I found a similar question in SO itself. [WCF compilation error on CI server: Microsoft.VisualStudio.ServiceModel.targets not found](http://stackoverflow.com/questions/14640045/wcf-compilation-error-on-ci-server-microsoft-visualstudio-servicemodel-targets). But this is not answered. There was a suggestion to install Windows SDK to solve this in that post. That doesn't solve the issue it seems. So, I hope you may need to install Visual Studio 2012 itself or we will wait if anybody can give a better answer. – RinoTom Feb 20 '13 at 14:21
  • Yea I tried installing that sdk from the link already. – twreid Feb 20 '13 at 16:00
  • Did you figure it out? – granadaCoder Feb 25 '13 at 22:31
  • We are going to just install VS2012 on the build machine, but we are waiting for some licensing things before we can do that. So I haven't been able to verify that fixed it or not, but as soon as we install it I will be back to post the results. – twreid Feb 26 '13 at 20:45
  • 4
    I don't like installing VS on the build server, but to each his own I guess. I can't say "it's wrong", but I just like to be very aware of all my dependency dll's. – granadaCoder Feb 27 '13 at 21:51
  • Did you end up putting VS on the server? Microsoft really should make things so this isn't a last-resort issue. – granadaCoder Apr 17 '13 at 15:01
  • 1
    @granadaCoder Yes, we had to install VS2012 on the build machine to get this working. – twreid Apr 17 '13 at 18:38
  • :) for getting it to work. :( for having to install VS. – granadaCoder Apr 17 '13 at 18:38

2 Answers2

4

When the CI environment doesn't have the "necessaries", then I have found a few resolutions:

One : Install the SDK (as previously mentioned).

Two : Every once in a while, you can copy the ".targets" file over manually from a machine with VS20xx installed on it. This is actually a good scenario, in that it is an easy fix.

Example here: Microsoft.WebApplication.targets was not found, on the build server. What's your solution?

Three: Something "akin" to an SDK install. An extra package here or there. Here is an example:

Build error in tfsbuild with database project

Four : Every once in a while, Microsoft screws you. And your only recourse is to install the full fledged Visual Studio. Which I hate, because a CI machine shouldn't need Visual Studio.

Community
  • 1
  • 1
granadaCoder
  • 26,328
  • 10
  • 113
  • 146
  • Well I have tried everything except installing VS2012 so that's my next stop. – twreid Feb 20 '13 at 19:44
  • So you tried to copy "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF\*.*" from a machine with VS installed over to the build machine? – granadaCoder Feb 21 '13 at 14:45
  • Yea and then it couldn't find the System.ServiceModel.Core assembly. – twreid Feb 21 '13 at 14:49
  • Are you the only developer? Because that's weird. How could the project reference something that never existed? Also, are both the dev machine and build machine x64 machines? Like, one isn't 32 bit is it? – granadaCoder Feb 21 '13 at 14:55
  • No I'm not the only developer, but we are the first team to use .Net4.5 and WCF. We currentlt use TeamCity for our CI and before I added the WCF project we had no build issues. Yes, the build machine is x64 and so is my workstation. However I ahve vs2012 and the build agent only has VS2010 and then .Net4.5 was installed after. – twreid Feb 21 '13 at 15:30
  • I have that target, but only have VS2010 and FW 4.0 installed, fyi. Can you poll the other team members to see if they have that target? Somebody has it I would guess. I mean, somebody had to have it for the reference to get added in the first place (I'd think so) – granadaCoder Feb 21 '13 at 16:07
  • @twreid you ever get this figured out? i'm in the exact same boat but *really* don't want to put a copy of VS2012 all my build agents. – joshua.ewer Mar 26 '13 at 19:11
  • @joshua.ewer I basically tried all the suggestions with no luck. We are just waiting on some more in house testing to finish up on our build agents and then we will go live with VS2012 on our agents to resolve this issue. – twreid Mar 26 '13 at 20:21
  • I was able to fix this on my build server. I detailed the steps here: http://stackoverflow.com/a/17272275/430634 – Steve Rukuts Jun 24 '13 at 09:36
3

One thing to check - determine whether the reference is even required.

I had a 2012 Solution with a .csproj file in it that had a reference to Microsoft.VisualStudio.ServiceModel.targets in it. I was upgrading from VS 2012 to VS 2013. I had two machines, which I'll call DESKTOP and LAPTOP. DESKTOP had VS 2012 on it, and I installed VS 2013 on it too. Hence the following file existed, and I was able to compile my solution:

$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets

On LAPTOP, I didn't have VS 2012. I installed 2013 from scratch, and was trying to get my solution (which is under TFS source control) working. I got the said error (VisualStudio.ServiceModel.targets doesn't exist ... validate that declaration is correct).

It turns out that I didn't even need this file -- In my .csproj file on DESKTOP, I simply commented out the element, and the solution re-compiled successfully (including having unit tests pass). So I checked it in to TFS from DESKTOP, got latest code on LAPTOP, and it compiled (and unit tests passed) there too:

<!-- Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" / -->
CJBS
  • 15,147
  • 6
  • 86
  • 135