Visual Studio 2012解决方案的TeamCity中的MSBuild [英] MSBuild in TeamCity of Visual Studio 2012 solution

查看:139
本文介绍了Visual Studio 2012解决方案的TeamCity中的MSBuild的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要在TeamCity中构建的VS 2012 Web项目/sln.它使用TeamCity上安装的.NET 4.5.

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.

TeamCity服务器仅安装了 VS 2010 .

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. 

它正在尝试使用Visual Studio 2012(v11.0)进行构建.

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

尽管在 build.xml 中,我已将 VisualStudioVersion 设置为 10 ?

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"  />

在项目内部也默认使用VS2010

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>

推荐答案

实际上,您不需要在CI服务器上安装Visual Studio.您只需要将几个文件夹从开发计算机复制到CI服务器上的相同位置.

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 Assemblys \ Microsoft \ Framework \ .NETFramework \ v4.6

.NET 4.5.2:

  • C:\ Program Files(x86)\参考程序集\ Microsoft \ Framework \ .NETFramework \ v4.5.2

.NET 4.5.1:

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

.NET 4.5:

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

.NET 4.0.1:

  • C:\ Program Files(x86)\参考程序集\ Microsoft \ Framework \ .NETFramework \ v4.0.1

.NET 4.0:

  • C:\ Program Files(x86)\参考程序集\ Microsoft \ Framework \ .NETFramework \ v4.0

或者,如马特建议,您可以将它们复制到项目的子目录中,并更改MSBuild文件中的<MSBuildExtensionsPath32>位置(通常为.csproj.vbproj).

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.

完成此操作后,将编译您的项目.您仍然应该将VisualStudioVersion显式设置为您要使用的VisualStudioVersion,以确保其设置正确.

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.

注意::该解决方案适用于所有项目类型(包括Web项目).对于一个网站(没有项目文件),我最终安装了 Windows SDK 与我正在使用的.NET SDK版本匹配,因为缺少注册表项,导致其无法生成.

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.

这篇关于Visual Studio 2012解决方案的TeamCity中的MSBuild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆