当文件实际引用 v10 时,找不到 v11.0WebApplicationsMicrosoft.WebApplication.targets [英] v11.0WebApplicationsMicrosoft.WebApplication.targets was not found when file actually references v10

查看:31
本文介绍了当文件实际引用 v10 时,找不到 v11.0WebApplicationsMicrosoft.WebApplication.targets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先介绍一下背景.2012 年底,我们将 vs2008 解决方案迁移到了 vs2010,但我们仍以 .NET 3.5 为目标.(我只知道这里最新最好的!)

First some background. At the end of 2012 we migrated our vs2008 solution to vs2010 but we still target .NET 3.5. (I know nothing but the latest and greatest here!)

直到几周前人们开始收到这些错误时,我们才遇到此设置的任何问题:

We hadn't had any issues with this setup until a few weeks ago when people started getting these errors:

"foo.csproj" (Rebuild target) (16:5) ->
  C:...foo.csproj(142,3): error MSB4019: The imported project "C:Program Files (x86)MSBuildMicrosoftVisualStudiov11.0WebApplicationsMicrosoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

有趣的是,如果您查看项目文件,它引用了 v10,这是有道理的,因为我们不使用 Visual Studio 2012.

The interesting thing is that if you look at the project file it references v10 which makes sense because we don't use Visual Studio 2012.

这个错误同时发生在我们几个人身上,甚至发生在几个月没有改变的旧代码分支上.

This error hit several of us at once and even on older code branches that haven't changed in months.

我怀疑某些更新被推送到我们的机器上,使事情变得混乱,但我不知道该怎么办.

I suspect some update got pushed onto our machines that confused things but I don't know what to do about it.

短期解决方案是安装 VS 2012 而不使用它,但我希望有比这更简洁的东西.

The short term solution has been to install VS 2012 and not use it but I'm hoping for something a little cleaner than that.

推荐答案

我在使用 Visual Studio 2013 时遇到了同样的问题.结果我使用的是旧版本的 MSBuild——.NET 附带的版本框架——来自命令行.Microsoft 现在将 MSBuild 作为 Visual Studio 本身的一部分发布,也作为单独的安装程序(http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx).

I ran into the same issue with Visual Studio 2013. It turns out that I was using the old version of MSBuild--the one that ships with the .NET Framework--from the command line. Microsoft is now releasing MSBuild as part of Visual Studio itself and also as a separate installer (http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx).

解决方案是使用位于 C:Program Files (x86)MSBuild12.0Bin 中的新版 MSBuild.exe.一旦我这样做了,所有目标错误都消失了.

The solution was to use the new version of MSBuild.exe located in C:Program Files (x86)MSBuild12.0Bin. Once I did that, all the targets errors disappeared.

编辑 1

正如评论中提到的,MSBuild 的每个新版本都会带来一个新目录.对于 Visual Studio 2015,使用 C:Program Files (x86)MSBuild14.0Bin.

As mentioned in the comments, each new version of MSBuild brings with it a new directory. For Visual Studio 2015, use C:Program Files (x86)MSBuild14.0Bin.

编辑 2

如评论中所述,对于 Visual Studio 2017,使用 C:Program Files (x86)Microsoft Visual Studio2017MSBuild15.0BinMSBuild.exe.

As mentioned in the comments, for Visual Studio 2017, use C:Program Files (x86)Microsoft Visual Studio2017<Edition>MSBuild15.0BinMSBuild.exe.

这篇关于当文件实际引用 v10 时,找不到 v11.0WebApplicationsMicrosoft.WebApplication.targets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆