试图在构建服务器上构建我的项目给我以下错误:

Microsoft (R) Build Engine Version 4.0.30319.1
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.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.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.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.

几个月前,我通过在Build Server上安装Visual Studio 2010解决了这个问题。但是现在我从头开始安装一个新的服务器,我想知道是否有更好的解决方案来解决这个问题。


当前回答

这就是你所需要的。只有103 mb。不要安装所有东西

其他回答

After installation of MSBuild tools from Microsoft, define the MSBuild path in the environment variable, so that it can be run from any path. Edit the .csproj file in any notepad editor such as notepad++, and comment the Check for the following elements, --> Make sure you use import only once, choose whichever works. Make sure you have the following folder exists on the drive, "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0" or whichever version is referenced by MSBuild target at "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" From the command prompt, run the following command, to check

C: > msbuild“C: \ \ DotnetCi。/p:Configuration=Release /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false

根据需要选择/p开关,请参考此处输入链接说明 在这里输入图像描述

创建一个新项目并复制设置可能会提供最好的指导。这是我戴上的样子

  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

如上所述,除了针对Microsoft. webapplication .targets的“Microsoft Visual Studio 2010 Shell(集成)可重分发包”和针对Microsoft. data . schema . sqltasks .targets的“Microsoft Visual Studio Team System 2008 Database Edition GDR R2”之外,最新的Windows SDK应该可以减少安装Visual Studio 2010的需求。然而,安装VS 2010可能实际上更少的整体下载和更少的工作。

来这里参加Visual Studio 2017的人。我也有类似的问题,更新到15.6.1后无法编译项目。 我不得不安装MSBulild工具,但错误仍然存在。

通过将v14.0文件夹从C:\Program Files (x86)\MSBuild\Microsoft\ VisualStudio复制到与v15.0相同的文件夹,我能够解决这个问题,这解决了所有错误。 现在我的文件夹结构如下所示,其中两个文件夹包含相同的内容。

在build/CI服务器上构建时,通过指定/p:VSToolsPath= "来完全关闭Microsoft.WebApplication.targets的导入。这将从本质上使下面一行的条件为假:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

在TeamCity中是这样做的: