gpt4 book ai didi

visual-studio-2010 - Visual Studio 2012 解决方案 TeamCity 中的 MSBuild

转载 作者:行者123 更新时间:2023-12-03 05:22:29 28 4
gpt4 key购买 nike

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

TeamCity 服务器仅安装了 VS 2010

构建运行时出现此错误:

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) 进行构建。

我已经在build.xml中将VisualStudioVersion设置为10??

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

项目内部也默认为 VS2010

  <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath
Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

最佳答案

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

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

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

完成此操作后,您的项目将进行编译。您仍应将 VisualStudioVersion 显式设置为您正在使用的版本,以确保其设置正确。

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-2010 - Visual Studio 2012 解决方案 TeamCity 中的 MSBuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15419610/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com