我通过命令行构建一个项目,而不是在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。我试着在登记处搜索,但一无所获。
遗憾的是,我没有看到任何简单的方法来使用确切的命令行。我使用一个构建工具。
想法吗?
我遇到了同样的问题,找到了一个更简单的解决方案
这是由于Vs2012在csproj文件中添加了以下内容:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
您可以安全地删除该部分,然后构建解决方案。
正如Sielu指出的,您必须确保.proj文件开始
<Project ToolsVersion="12",否则下次打开
项目与visual studio 2010,它将再次添加删除的节点。
否则,如果你需要使用webdeploy或者你使用构建服务器,上面的解决方案将不起作用,但你可以在你的构建脚本中指定VisualStudioVersion属性:
msbuild myproject.csproj /p:VisualStudioVersion=12.0
或者编辑你的构建定义:
我遇到了同样的问题,找到了一个更简单的解决方案
这是由于Vs2012在csproj文件中添加了以下内容:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
您可以安全地删除该部分,然后构建解决方案。
正如Sielu指出的,您必须确保.proj文件开始
<Project ToolsVersion="12",否则下次打开
项目与visual studio 2010,它将再次添加删除的节点。
否则,如果你需要使用webdeploy或者你使用构建服务器,上面的解决方案将不起作用,但你可以在你的构建脚本中指定VisualStudioVersion属性:
msbuild myproject.csproj /p:VisualStudioVersion=12.0
或者编辑你的构建定义: