我通过命令行构建一个项目,而不是在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" />

做完了。

其他回答

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

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

在命令行中运行这个命令也可以解决这个问题。 SETX VisualStudioVersion“12.0”

当我安装一些VS组件时,我得到了这个错误。不幸的是,这些答案都没有帮到我。我使用TFS进行命令开发,没有编辑构建定义的权限。我通过删除VS110COMNTOOLS和VS120COMNTOOLS环境变量来解决这个问题。我想它是和我的VS组件一起安装的。

Giammin的解决方案部分是不正确的。您不应该从解决方案中删除整个PropertyGroup。如果你这样做,MSBuild的“DeployTarget=Package”特性将停止工作。这个特性依赖于“VSToolsPath”的设置。

<PropertyGroup>
  <!-- VisualStudioVersion is incompatible with later versions of Visual Studio.  Removing. -->
  <!-- <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> -->
  <!-- VSToolsPath is required by MSBuild for features like "DeployTarget=Package" -->
  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
...
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

要解决这个问题,只需要做一件事:将TeamCity升级到8.1版本。因为对Visual Studio 2012/2013和MSBuild Tools 2013的支持只在TeamCity 8.1中引入。一旦你升级了你的TeamCity,在你的构建步骤中相应地修改MSBuild Tools版本设置,问题就会消失。更多信息请阅读这里:http://blog.turlov.com/2014/07/upgrade-teamcity-to-enable-support-for.html