c# - 外部VS2013构建错误 "error MSB4019: The imported pro

我正在通过命令行而不是在 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

或编辑您的构建定义:

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

相关文章:

visual-studio - obj 和 bin 文件夹(由 Visual Studio 创建)用

android - 如何使用 gradle 在 APK 文件名中设置 versionName?

build - Gradle buildscript 依赖项

java - NoClassDefFoundError - Eclipse 和 Android

java - Gradle 没有找到 tools.jar

node.js - Node 包 ( Grunt ) 已安装但不可用

macos - 在 Mac OS X 上安装/升级 gradle

android - 在圆圈 ci 中找不到 com.android.tools.build :gra

java - "mvn clean install"与 "mvn install"有何不同?

objective-c - iOS - 构建失败,CocoaPods 找不到头文件