找不到导入的项目Microsoft.WebApplications.targets

时间:2011-08-30 06:22:04

标签: visual-studio tfs

在TFS服务器中配置持续集成时出现此错误,但已找到答案。也许这会对其他人有所帮助:

The imported project "C:\Program Files (x86)\
   MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\
   Microsoft.WebApplications.targets" was not found.

11 个答案:

答案 0 :(得分:53)

你需要......

  1. 在构建计算机上安装Visual Studio,
  2. 将MSBuild \ Visual Studio \ v10.0 \ WebApplications文件夹的内容手动复制到构建计算机上的相同位置。

答案 1 :(得分:11)

<!--<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />-->

评论.CSproj中的上一行。看起来像微软的bug,它在从visual studio 2008到2010更新项目时不会删除或评论。

答案 2 :(得分:7)

在设置与Jenkins的持续集成时,我看到了同样的错误。我能够向MSBUILD添加命令行参数:<action android:name="myapp.broadcast.notification"/>因为我在构建服务器上安装了Visual Studio 2012。

答案 3 :(得分:3)

下载&amp;安装Microsoft Visual Studio 2013 Shell (Isolated) Redistributable Package。或使用指向vs_isoshell.exe的直接链接。我打算在以后为此制作一个NuGet包。

我看到这种方法的优势在于它消除了对版权问题的任何疑问。

答案 4 :(得分:3)

I experienced something similar.

I had written this in our Autobuild.targets file run as part of a build. It defines MSWebApplicationTargets:

<MSWebApplicationTargets>$(SolutionDirectory)\packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3</MSWebApplicationTargets>

Then in a .csproj file that is part of the project and used in the build it had:

<Import
     Project="$(MSWebApplicationTargets)/tools/VSToolsPath/WebApplications/Microsoft.WebApplication.targets" />

Now our problem was that when we opened the project in Visual Studio it said that c:/tools/VSToolsPath/WebApplications/Microsoft.WebApplication.targets doesn't exist (because VS considered MSWebApplicationTargets to be undefined and so seemed to default it to c:\). You don't provide enough information though perhaps that is what caused your problem also.

All I had to do to solve this was add a condition:

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

Why do this with Microsoft.WebApplication.targets

As part of some futher discussion, I did this with Microsoft.WebApplication.targets so we didn't have to rely on Visual Studio being installed on the build servers. I added it as a dependency:

  • In Visual Studio right-click on the project and go to manage nuget packages. This created a packages.config file that listed MSBuild.Microsoft.VisualStudio.Web.targets as a dependency.
  • I then added nuget.exe restore to the start of the build script so that the dependencies are downloaded.

答案 5 :(得分:1)

如果您已经安装了Visual Studio?也许您安装了Visual Studio 2012(10.0表示VS 2010)?如果是这种情况,您可以只搜索.csproj文件中的“10.0”并将其替换为“11.0”,然后您就可以正常打开该项目了。

答案 6 :(得分:1)

我也有这个问题,除了这些文件已经存在。经过大量的故障排除后,答案变得非常简单:重新启动构建代理服务。就我而言,它是:&#34; Visual Studio Team Foundation Build Service Host 2013&#34;

答案 7 :(得分:1)

如果您不从构建服务器进行部署,则只需关闭构建服务器上的Microsoft.WebApplication.targets即可。请在此处查看我的回答:https://stackoverflow.com/a/35781566/4955344

答案 8 :(得分:0)

以下某些PowerShell通过在构建服务器上的MSBuild.exe.config中添加缺少的引用为我解决了此问题。调整VS版本/目标路径的路径。

[xml]$msbuild_config = Get-Content -Path "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe.config"
$webApplicationTarget = $msbuild_config.configuration.msbuildToolsets.toolset.property[0].Clone()
$webApplicationTarget.name = "MSWebApplicationTargets"
$webApplicationTarget.value = "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications"
$msbuild_config.configuration.msbuildToolsets.toolset.AppendChild($webApplicationTarget)
$msbuild_config.save("C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe.config")```

答案 9 :(得分:0)

我在VS2017上也遇到了这个错误;然后我将以下两项注释掉:

<!--<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /><Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />-->

重新打开解决方案,可以再次成功加载项目。 (我不知道这是怎么发生的,因为该项目可以在以前正常加载,也许我最近通过“ vs-installer.exe”添加了一些新功能)

答案 10 :(得分:0)

这是我在 vs19 中为解决此问题所做的工作。我导航到此路径:-

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio

并注意到 \vxx.0 (vs 抱怨的特定目录不存在)。就我而言,vs 正在寻找不存在的 \v16.0,尽管 \v15.0\v14.0\v12.0 在那里。所以我手动创建了一个 v16.0 文件夹并将 WebApplications\Microsoft.WebApplications.targetsv14.0 复制到 v16.0 文件夹,问题得到了解决,但是我不确定这是否是最好的方法解决这个问题,它似乎有点hacky。我无法在 .csproj 文件中更改此路径,因为该路径可能存储在 $(MSBuildBinPath) 之类的变量中,并且没有在那里进行硬编码。