我通过命令行构建一个项目,而不是在Visual Studio 2013中。注意,我已经将我的项目从Visual Studio 2012升级到2013。项目在IDE中构建得很好。此外,我完全卸载VS2012,重新启动,并安装VS2013。我唯一拥有的Visual Studio版本是2013终极版。

ValidateProjects:
    39>path_to_project.csproj(245,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.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.
    39>Done Building Project "path_to_project.csproj" (Clean target(s)) -- FAILED.

这里有两句话:

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

原来的第二行是v10.0,但我手动将其更改为v12.0。

$(VSToolsPath)从我所看到的v11.0 (VS2012)文件夹中延伸出来,这显然已经不存在了。路径应该是v12.0。

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\

我尝试在系统环境变量表中指定VSToolsPath,但外部构建实用程序仍然使用v11.0。我试着在登记处搜索,但一无所获。

遗憾的是,我没有看到任何简单的方法来使用确切的命令行。我使用一个构建工具。

想法吗?


当前回答

我也犯了同样的错误。我这么做是为了弥补

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

改变

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

做完了。

其他回答

基于TFS 2015 Build Server

如果你纠正这个错误……错误MSB4019:导入项目“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft. webapplication . exe”没有找到“Targets”。确认<Import>声明中的路径是正确的,并且该文件存在于磁盘上。

打开错误消息中指定的项目的.csproj文件,并注释掉下面的部分

< !<属性tygroup > -> < !“$”“>10.0</ visual studios > ->” < !<VSToolsPath Condition=“$(VSToolsPath)”=“>$”(msbuildextensionspath spath)\微软\视觉工作室\v$)</VSToolsPath> < !</属性tygroup > ->

我也有这个问题,你可以通过在构建定义中设置工具版本来修复它。

这很容易做到。打开构建定义并转到“Process”页面。然后在“3”下面。高级”组中有一个名为“MSBuild Arguments”的属性。按照以下语法放置参数

/p:VisualStudioVersion=12.0 

如果有更多参数,请用空格分隔,而不是逗号。

我安装了Visual Studio 2013。这招对我很管用:

<PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' != ''">12.0</VisualStudioVersion>`
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

因此,我将条件从==更改为!=,并将值从10.0更改为12.0。

我-没有什么能帮助将VisualStudioVersion变量的v11.0值更改为v10.0。在.csproj文件中改变变量没有。通过命令提示符设置却没有。等等……

最终将特定版本(v11.0)的本地文件夹复制到构建服务器。

使用正确的MSBuild版本。设置“环境变量”为:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

这也适用于VS 2019项目

之前我们将其设置为C:\Windows\Microsoft.NET\Framework\v4.0.30319