-->

Microsoft.WebApplication.targets没有被发现,在构建服务器。 什么

2019-10-28 08:26发布

试图建立生成服务器上我的项目给了我下面的错误:

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.

我在几个月前解决了这个问题,在构建服务器上安装Visual Studio 2010。 但我现在建立一个从无到有的新服务器,我想知道是否有任何更好的解决方案来解决这个问题。

Answer 1:

要回答这个问题的标题(但不是你要输出的问题):

复制从你的dev的机器下面的文件夹到您的构建服务器修复了这个,如果只是Web应用程序

C:\ Program Files文件(x86)的\的MSBuild \微软\ VisualStudio的\ V10.0 \ web应用

根据您如何生成中断删除86。 如果你有其他的项目类型,你可能需要拷贝整个文件夹的MSBuild。



Answer 2:

如果没有安装VS不支持构建和发布无线接入点。 随着中说,如果你真的不希望安装VS那么你需要的所有文件复制下%ProgramFiles32%\MSBuild\Microsoft\

您将需要安装Web部署工具为好。 我认为这就是它。



Answer 3:

UPD: as of VS2017, there is workload in Build Tools that eliminates this problem completely. See @SOReader answer.

If you'd prefer not to modify anything on build server, and you still want the project to build right out of source control, it might be a good idea to put the required binaries under source control. You'll need to modify the imports section in your project file to look like this:

<Import Project="$(SolutionDir)\BuildTargets\WebApplications\Microsoft.WebApplication.targets" />
<Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

The first line is the actual import from the new location that is relative to the solution directory. The second one is a turned-off version (Condition="false") of the original line that allows for Visual Studio to still consider your project to be a valid Web Application Project (that's the trick that VS 2010 SP1 does itself).

Don't forget to copy the C:\Program Files (x86)\Microsoft\VisualStudio\v10.0\WebApplications to BuildTargets folder under your source control.



Answer 4:

您也可以使用NuGet包MSBuild.Microsoft.VisualStudio.Web.targets ,Visual Studio项目(S)中引用它们,然后改变你引用的舍甫琴科ķ建议。



Answer 5:

眼下,在2017年,你可以用MSBuildTools安装WebApplication的redists。 只要到这个网页 ,将下载的MSBuild 2017年工具,并同时安装点击Web development build tools即可安装,以及这些目标:

这将导致在安装缺少的库C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications默认



Answer 6:

基于这个职位在这里你可以简单地下载微软的Visual Studio 2010壳(集成)再发行组件包并安装目标。

这避免了需要构建服务器上安装Visual Studio。

我刚才想了这一点,现在,可以验证它的工作原理:

之前:

错误MSB4019:导入项目 “C:\ Program Files文件(x86)的\的MSBuild \微软\ VisualStudio的\ V10.0 \ web应用\ Microsoft.WebApplication.targets” 没有被发现。 确认在声明的路径是正确的,并且该文件存在于磁盘上。

安装之后:

[正确构建]

这不仅是一个构建服务器上安装Visual Studio,显然远更好的解决方案。



Answer 7:

最新的Windows SDK,因为除了上面提到的, “微软的Visual Studio 2010壳(集成)再发行组件包”的Microsoft.WebApplication.targets和“Microsoft Visual Studio团队系统2008年数据库版GDR R2”为Microsoft.Data.Schema .SqlTask​​s.targets应减轻需要安装Visual Studio 2010年。不过,在安装VS 2010也许实际上是较少的总下载并最终更少的工作。



Answer 8:

当构建/ CI服务器上构建,关闭进口Microsoft.WebApplication.targets完全通过指定/p:VSToolsPath='' 。 这种意志,本质上,使下面的行假的条件:

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


这是它是如何在做的TeamCity:



Answer 9:

添加依赖通过的NuGet和设置参数构建

目标:没有变化/安装必要的生成代理

我已经采取了混合的方法来劳埃德的NuGet方法在这里 ,这是基于关闭的通过Andrik犯二进制依赖的解决方案。

之所以是我希望能够无需物品,诸如此预配置它们添加新的生成代理。

  1. 在使用Visual Studio的机器,打开解决方案; 忽略网络项目失败。
  2. 在NuGet包管理器,添加MSBuild.Microsoft.VisualStudio.Web.targets ,如劳埃德提及。
  3. 这将解决二进制文件[solution]\packages\MSBuild.Microsoft.VisualStudio.Web.targets.nn.nnn\tools\VSToolsPath\
    1. 您可以将这些复制到文件夹引用提交和,
    2. 或者只是使用他们,他们都在。 我选择了这个,但我将不得不后来以应对路径的版本号。

在版本7中,我做了以下。 这可能没有必要,并根据意见,绝对不是现在需要的。 请看下面的评论。

  1. 接下来,在你的TeamCity构建配置,添加构建Paramenter为env.VSToolsPath并将其设置为VSToolsPath文件夹; 我用..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\tools\VSToolsPath


Answer 10:

如果您的Visual Studio 2012迁移到2013,然后打开*与edior .csproj的项目文件。
并检查“项目”标签的ToolsVersion元素。

它的值更改为4.0〜12.0

  •  <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" ... 
  •  <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" ... 

或者如果你建立与MSBuild的则只需指定VisualStudioVersion财产

MSBuild的/p:VisualStudioVersion=12.0

解决方案来源



Answer 11:

这似乎MSBuild的新版本不Microsoft.WebApplication.targets发货。 要解决你需要更新您的csproj文件,像这样:

1)编辑Web应用程序的csproj(右键)。 查找有关朝着构建工具底部的csproj部分。 它应该像这样。

<PropertyGroup>  
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
</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" />  

2)你需要添加VisualStudioVersion标签下面一个VSToolsPath线,所以它看起来像这样

<PropertyGroup>  
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
  <!--Add the below line to fix the project loading in VS 2017 -->
  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  <!--End -->
</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" />  

参考链接: https://alastaircrabtree.com/cannot-open-vs-2015-web-project-in-vs-2017/



Answer 12:

这是你所需要的。 只有103MB。 不要安装一切



Answer 13:

我发现这在MS连接 :

是的,你需要在构建机上安装Visual Studio 2010中创建数据库项目。 这样做并不需要Visual Studio中的一个额外的许可。

所以,这是我现在唯一的选择。



Answer 14:

我的解决办法是在这里好几个答案的混合。

我检查了构建服务器,和Windows7 / NET4.0 SDK已经安装了,所以我没有找到路径:

C:\ Program Files文件(x86)的\的MSBuild \微软\ VisualStudio的\ 9.0 \ web应用\ Microsoft.WebApplication.targets`

然而,在这条线:

<导入项目= “$(MSBuildExtensionsPath)\微软\ VisualStudio的\ 9.0 \ web应用\ Microsoft.WebApplication.targets”/>

$(MSBuildExtensionsPath)扩展到C:\ Program Files文件\的MSBuild不具备的路径。

所以我所做的就是创建一个符号连接,使用这个命令:

mklink / J “C:\ Program Files文件\的MSBuild \微软\ VisualStudio的” “C:\ Program Files文件(x86)的\的MSBuild \微软\ VisualStudio的”

这样,$(MSBuildExtensionsPath)扩展为一个有效的路径,并且需要在应用程序本身并没有改变,只是在构建服务器(可能是一个可以创建符号链接,每次构建,以确保这一步不丢失和被“记录在案“)。



Answer 15:

我加入这个固定
/p:VCTargetsPath="C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V120"


Build > Build a Visual Studio project or solution using MSBuild > Command Line Arguments



Answer 16:

我尝试了一堆的解决方案,但最终这个答案为我工作: https://stackoverflow.com/a/19826448/431522

它基本上需要有一个目录的MSBuild调用,而不是在Visual Studio目录的MSBuild。

我还添加了目录的MSBuild我路径,使脚本更容易编码。



Answer 17:

任何人都来到这里为Visual Studio 2017年我有类似的问题,更新后无法编译项目15.6.1。 我必须安装MSBulild工具,但仍然错误在那里。

我能够通过复制来解决该问题v14.0从文件夹C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio到同一文件夹作为v15.0和解决所有的错误。 所以,现在我的文件夹结构看起来像下面,其中两个文件夹包含相同的内容。



Answer 18:

如果您使用的MSBuild,作为生成服务器的情况下,什么工作对我来说是:

更改以下:

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

至:

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

我的MSBUILD命令是: *"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" solution.sln /p:Configuration=Debug /p:Platform="Any CPU"*

希望这可以帮助别人。



Answer 19:

如果您正在尝试部署使用VSTS项目情况,那么问题可能与检查“托管窗容器”选项,而不是“托管VS2017”(或18等)连接:



文章来源: Microsoft.WebApplication.targets was not found, on the build server. What's your solution?