我通过命令行构建一个项目,而不是在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。我试着在登记处搜索,但一无所获。

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

想法吗?


当前回答

在我的情况下,我只是通过打开.csproj文件在行下面注释,并做到了这一点

。< !——<导入项目="..\PRPJECTNAME. "目标" />—>

我的问题可能不同,但我被拖到这里,但这可能会帮助到某人。

我从我的解决方案中选择了一个单一的网络项目,并试图将其作为一个独立的项目来打开,这是一个问题,在以上heck我能够解决问题。

其他回答

基于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 > ->

你会发现

C:\Program Files  (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets 

在出现此错误的csproj文件中。 只需从csproj中删除这个,然后构建。

在我的情况下,我只是通过打开.csproj文件在行下面注释,并做到了这一点

。< !——<导入项目="..\PRPJECTNAME. "目标" />—>

我的问题可能不同,但我被拖到这里,但这可能会帮助到某人。

我从我的解决方案中选择了一个单一的网络项目,并试图将其作为一个独立的项目来打开,这是一个问题,在以上heck我能够解决问题。

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)' != ''" />

在我的情况下,我使用了错误版本的MSBuild.exe。

您需要使用的版本取决于您用于创建项目的Visual Studio的版本。在我的情况下,我需要14.0(使用Visual Studio 2015)。

这是在:

C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe

你可以浏览以下网页:

C:\Program Files (x86)\MSBuild

寻找其他版本。