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

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解决了这个问题。但是现在我从头开始安装一个新的服务器,我想知道是否有更好的解决方案来解决这个问题。


当前回答

我通过添加来解决这个问题 / p: VCTargetsPath = " C: \ Program Files \ MSBuild \ Microsoft.Cpp \ v4.0 \ V120” 成 使用MSBuild >命令行参数构建Visual Studio项目或解决方案

其他回答

你也可以使用NuGet包MSBuild.Microsoft.VisualStudio.Web。目标,在你的Visual Studio项目中引用它们,然后按照Andriy K的建议更改你的引用。

我通过添加来解决这个问题 / p: VCTargetsPath = " C: \ Program Files \ MSBuild \ Microsoft.Cpp \ v4.0 \ V120” 成 使用MSBuild >命令行参数构建Visual Studio项目或解决方案

我在MS connect上找到了这个:

是的,您需要安装Visual Studio 2010在你的构建机器上进行构建 数据库项目。这样做确实 不需要额外的许可证 Visual Studio。

所以,这是我目前唯一的选择。

如果将Visual Studio 2012迁移到2013,则打开*。Csproj项目文件编辑器。 并检查'Project'标签的ToolsVersion元素。

将其值从4.0更改为12.0

从 <?XML版本="1.0"编码="utf-8"?> <Project ToolsVersion="4.0"… 来 <?XML版本="1.0"编码="utf-8"?> <Project ToolsVersion="12.0"…

或者如果你用msbuild构建,那么只需指定VisualStudioVersion属性

msbuild / p: VisualStudioVersion = 12.0

解决方案的来源

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开关,请参考此处输入链接说明 在这里输入图像描述