在构建服务器上找不到 Microsoft.WebApplication.targets 文件。你有什么解决方法?

471

尝试在构建服务器上构建我的项目时,出现以下错误:

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


1
Web应用程序项目已经过时了吗?我想知道为什么需要旧版本的Visual Studio才能构建它们的理由是什么? - brianary
1
更重要的是,你是否实际通过构建服务器进行部署?例如,我不这样做,我甚至在解决方案中有一个单独的Web安装程序项目...但它仍然需要这个该死的东西...答案=从proj文件中删除它!很容易。 - Paul Zahra
8
通过将路径<Import Project="..\Packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\tools\VSToolsPath\WebApplications\Microsoft.WebApplication.targets" />替换为$(VSToolsPath),完成修复操作,修复后的代码如下: <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" /> - G J
24个回答

0

如果您正在尝试使用VSTS部署项目,则问题可能与选中“托管的Windows容器”选项有关,而不是“托管的VS2017”(或18等):

enter image description here


0

我通过在Docker容器中运行构建,特别是dotnet/framework/sdk来解决了这个问题。它包含VS构建工具。


0
在我的情况下,这只是一个端口阻止。

-1
  • 安装Microsoft的MSBuild工具后,将MSBuild路径定义在环境变量中,以便可以从任何路径运行。
  • 使用任何记事本编辑器(如notepad++)编辑.csproj文件,并注释掉
  • 检查以下元素,
    -->
    • 确保只导入一次,选择任何一个都可以。
    • 确保驱动器上存在以下文件夹,“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0”或MSBuild目标引用的任何版本,“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets”
    • 从命令提示符中运行以下命令,以检查

C:>msbuild "C:\\DotnetCi.sln" /p:Configuration=Release /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false


注释什么? - Zimano

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接