为什么 MSBuild ToolsVersion 4.0 无法构建旧项目?

发布于 2024-09-07 08:01:48 字数 1406 浏览 7 评论 0原文

我们使用 Cruse Control 来管理我们的构建过程。 当我们将 vs2008 项目转换为 vs2010 时,我们将 Web 和类库项目的目标框架设置为 3.5。

此时,我们不会将所有解决方案都转换为 vs2010;如果不需要的话就不会。

我最近更新了 Cruise Control 用于指向 MSBuild 4.0 的 MSbuild 项目文件,以便我们的构建过程能够构建 vs2010 项目。

C:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

一切都很顺利,直到提交了一个针对 4.0 框架的 Web 项目。 这时就出现了这个错误:

CS0433:类型“System.Web.Routing.RouteCollection”存在于 c:\Windows\Microsoft.NET\ assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a 中 Global.asax.cs 中的 \System.Web.dll 和 c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Routing.dll(15, 43)

此时我意识到Windows/Microsoft.NET/Assembly 文件夹。

现在...所有 MSBuild 项目,即使它们使用 MSBuild 4.0,仍然将工具版本设置为 3.5。 那么为什么 3.5 目标构建要查看新的 4.0 程序集文件夹并发现此冲突呢?可能是因为我使用的是 MSBuild 4.0。但如果我可以更改 MSBuild 使用的 toolVersion,您可能会认为我可以告诉它以 3.5 为目标,而不必担心这些潜在的冲突。

为了解决这个问题,我转到巡航控制使用的相关 MSBuild 项目文件,并将其工具版本更改为 4.0。这已经通过了冲突错误。但现在每次它尝试构建一个我们尚未转换为 vs2010 项目的解决方案中的项目时,它都会中断并出现如下错误:

SomeFilePath 中的 MyProject.csproj: LC0000:“无法加载文件或程序集或其依赖项之一。该程序集是由比当前加载的运行时更新的运行时构建的,因此无法加载。在 LC(0, 0) 中

如果我在 Visual Studio 2010 中打开包含该项目的解决方案并进行转换、构建它并提交它并强制另一个构建,我会通过该错误,但发现另一个不是然而转换后的项目却抛出了同样的错误。

所以现在我确信使用 MSBuild 4.0 并真正针对 4.0 框架。为什么4.0无法构建3.5项目或vs2008解决方案项目?

We're using Cruse Control to manage our build process.
AS we convert vs2008 projects to vs2010, we're leaving the target framework set at 3.5 for web and class library projects.

At this point we're not going through and converting all our solutions to vs2010; not if we don't have to.

I recently updated the MSbuild project files that cruise control uses to point at MSBuild 4.0 so our build process would be able to build vs2010 projects.

C:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

All was well until a web project that was targeting the 4.0 framework was committed.
At which point this error popped up:

CS0433: The type 'System.Web.Routing.RouteCollection' exists in both c:\Windows\Microsoft.NET\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll and c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Routing.dll in Global.asax.cs(15, 43)

At which point I became aware of the Windows/Microsoft.NET/Assembly folders.

Now... All the MSBuild projects, even though they were using MSBuild 4.0, still had the tools version set at 3.5.
So why was a 3.5 targeted build looking at the new 4.0 assembly folders and finding this conflict? Probably because I was using MSBuild 4.0. But if I can change the toolVersion that MSBuild uses, you'd think I can tell it to target 3.5 without worrying about these potential conflicts.

To resolve this issue, I went to the relevant MSBuild project files that cruise control uses and changed their toolsVersion to 4.0. This got passed that conflict error. But now everytime it tries to build a project that's in a solution that we haven't yet converted to a vs2010 project, it breaks with an error like this:

MyProject.csproj in SomeFilePath:
LC0000: 'Could not load file or assembly or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.' in LC(0, 0)

If I open the solution that contains that project in Visual Studio 2010 and do the conversion, build it and commit that and force another build, I get passed that error only to find that another not yet converted project is tossing that same error.

So now I am for sure using MSBuild 4.0 and for real targeting the 4.0 framework. Why can't 4.0 build 3.5 projects or vs2008 solution projects?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情丝乱 2024-09-14 08:01:48

问题是您已将部分项目迁移到 Visual Studio 2010。任何引用 2010 项目(按项目引用)的 2008 项目都会出现此编译时错误。尝试将所有 .csproj 文件更新到 2010,然后再次尝试重建。

The issue is that you have migrated part of your projects to to visual studio 2010. Any 2008 project that references a 2010 project (by project reference) will give you this compile time error. Try updating all .csproj files to 2010 and try rebuilding again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文