Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild in TeamCity of Visual Studio 2012 solution

I have a VS 2012 web project /sln that I am trying to build in TeamCity. it uses .NET 4.5 which is installed on TeamCity.

The TeamCity server has VS 2010 installed only.

I get this error when the build runs:

C:\BuildAgent\work\d5bc4e1b8005d077\CUSAAdmin.Web\CUSAAdmin.Web.csproj(799, 3):  error MSB4019:  The imported project      "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found.   Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. Project CUSAAdmin.Web\CUSAAdmin.Web.csproj failed.   Project CUSAAdmin.sln failed.  

It is trying to use Visual Studio 2012 (v11.0) to build.

I have set the VisualStudioVersion to be 10 in the build.xml though??

 <Target Name="BuildPackage">    <MSBuild Projects="CUSAAdmin.sln" ContinueOnError="false"       Targets="Rebuild"        Properties="Configuration=$(Configuration); VisualStudioVersion=10.0"  /> 

As well inside the project it is defaulting to VS2010

  <PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath      Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> 
like image 678
Ian Vink Avatar asked Mar 14 '13 20:03

Ian Vink


People also ask

Does Visual Studio include MSBuild?

If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin.

Where can I find MSBuild?

MSBuild is installed in the \Current folder under each version of Visual Studio, and the executables are in the \Bin subfolder.

Is it is possible to build application if MSBuild is not installed?

Is it possible to build an application on a system if the MSBuild is not installed? If so, How? Yes, it is actually possible because the MSBuild doesn't depend on the Visual Studio of its operations. Users simply need to install the msbuild.exe file for this.

Where is MSBuild for VS 2015?

1>C:\Program Files (x86)\MSBuild\Microsoft. Cpp\v4. 0\Platforms\Win32\Microsoft. Cpp.


1 Answers

Actually, you don't need to install Visual Studio on your CI server. You only need to copy a few folders from a development machine to the same location on the CI server.

VS 2015:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications

VS 2013:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications

VS 2012:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications

VS 2010:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications

.NET 4.6:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6

.NET 4.5.2:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2

.NET 4.5.1:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1

.NET 4.5:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5

.NET 4.0.1:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.1

.NET 4.0:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

Or, as Matt suggested, you could copy them into a subdirectory of your project and alter the <MSBuildExtensionsPath32> location in your MSBuild (typically .csproj or .vbproj) file.

Once you have done this, your project will compile. You should still set the VisualStudioVersion explicitly to the one you are using just to be sure it is set right.

NOTE: This solution works for all project types (including web projects). For a web site (that has no project file), I ended up installing the Windows SDK matching the .NET SDK version I am using, because there were missing registry keys that were causing it not to build.

like image 182
NightOwl888 Avatar answered Sep 20 '22 16:09

NightOwl888