c# - 外部VS2013构建错误 "error MSB4019: The imported project <path> was not found"

标签 c# web-applications visual-studio-2013 build visual-build-professional

我正在通过命令行而不是在 Visual Studio 2013 中构建项目。请注意,我已将项目从 Visual Studio 2012 升级到 2013。该项目在 IDE 中构建良好。另外,我先完全卸载了VS2012,重新启动,安装了VS2013。我拥有的唯一 Visual Studio 版本是 2013 Ultimate。

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。我尝试在注册表中搜索,但没有找到任何结果。

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

想法?

最佳答案

我遇到了同样的问题并找到了更简单的解决方案

这是由于Vs2012在csproj文件中添加了以下内容:

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

您可以安全地删除该部分,然后您的解决方案就会构建。

As Sielu pointed out you have to ensure that the .proj file begin with <Project ToolsVersion="12" otherwise the next time you open the project with visual studio 2010, it will add the removed node again.

否则,如果您需要使用 webdeploy 或使用构建服务器,上述解决方案将不起作用,但您可以指定 VisualStudioVersion构建脚本中的属性:

msbuild myproject.csproj /p:VisualStudioVersion=12.0

或编辑您的构建定义:

edit build definition to specify the <code>VisualStudioVersion</code> property

关于c# - 外部VS2013构建错误 "error MSB4019: The imported project <path> was not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19718281/

相关文章:

c# - 重构字典,改变键类型

c# - 在 C# 中进行 cURL 调用

java - 解释: How does Java work as a web application?

java - 将样式添加到 tomcat 8 中的目录列表

mysql - Openshift:如何通过 RHC 或 SSH 将数据库导入 MySQL?

c++ - 让自定义 Find*.cmake 文件根据 visual studio 构建类型(调试/发布)查找不同的库

c++ - 无法使用 visual studio 导出 C++ dll

c# - 内部匿名方法中变量的作用域

c++ - Visual Studio 2013 VC++ 编译器

C# Office Development : Microsoft. Office.Tools.Word.Controls.Button 给出错误