如何在 VS2010 C# 项目中定位 VS2008 中的 MSBuild 程序集

发布于 2024-11-08 06:42:48 字数 1294 浏览 0 评论 0原文

我开发了一个工具,用于构建其他解决方案文件,如果成功则运行输出。该工具最初是使用 VS2008 构建的,必须构建的解决方案文件也在 VS2008 中。为了在运行时构建解决方案文件,我添加了对 Microsoft.Build.Engine 和 Microsoft.Build.Framework 程序集的引用,到目前为止,一切顺利。

最近我被迫将我的主要解决方案移至VS2010,但必须在运行时构建的卫星解决方案暂时必须保留在VS2008中。为了增加一些更多的乐趣,VS2008 解决方案仅包含 C++ 项目(众所周知,它们在 VS2010 中转换为 vcxproj 格式)。

我遇到的问题是我无法加载上述程序集的 3.5 版本。尽管我在运行时付出了一切努力,但它总是加载它们的 4.0 版本。这会产生不良影响,当我尝试构建 VS2008 解决方案时,出现错误: 项目文件“bla bla bla.vcproj”采用“.vcproj”文件格式,MSBuild 不再支持该格式。请通过在 Visual Studio IDE 中打开该项目或运行转换工具来转换该项目,或者使用 MSBuild 3.5 或更早版本来生成该项目。

引用 MSBuild 程序集的 C# 项目是使用 TargetFramework 3.5 配置的,并且对程序集的引用如下:

<Reference Include="Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <SpecificVersion>True</SpecificVersion>
</Reference>

我还尝试将引擎 DefaultToolsVersion 设置为 3.5,但这也没有帮助。

我试图通过启动一个新进程并将参数发送到命令行来避免调用我想要的确切 MSBuild 版本,因为这将需要更多的工作来注册记录器并同步消息,以便我的主应用程序可以知道是否构建成功,在这种情况下运行输出。我真的希望这不是唯一的出路。

任何想法、解决方案或任何类型的帮助都非常感谢。 提前致谢

I've developed a tool which I use to build other solution files, and if succeeded then runs the output. The tool was initially built with VS2008 and the solution files that must build are also in VS2008. To build the solution files at runtime I've added references to Microsoft.Build.Engine and Microsoft.Build.Framework assemblies, and so far, so good.

Recently I was forced to move my main solution to VS2010, but the satellite solutions which must be built at runtime must be kept in VS2008 for the moment. Just to add up some more fun, the VS2008 solutions contains only C++ projects (which as everyone knows they are converted to vcxproj format in VS2010).

The issue I'm having, is that I'm not being able to load versions 3.5 of the mentioned assemblies. Despite all my efforts at runtime it always loads version 4.0 of them. This has the unwanted effect that when I try to build the VS2008 solutions I get the error: The project file "bla bla bla.vcproj" is in the ".vcproj" file format, which MSBuild no longer supports. Please convert the project by opening it in the Visual Studio IDE or running the conversion tool, or use MSBuild 3.5 or earlier to build it.

The C# project with the reference to the MSBuild assemblies is configured with TargetFramework 3.5, and the references to the assemblies are like this:

<Reference Include="Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <SpecificVersion>True</SpecificVersion>
</Reference>

I've also tried setting the engine DefaultToolsVersion to 3.5, but that didn't help either.

I'm trying to avoid calling the exact MSBuild version I want by lunching a new Process and sending the arguments to the command line, cause that would involve more work to register a logger and synchronizing the messages, so that my main app can know if the build succeeded and in that case run the output. I really hope that's not the only way to go.

Any ideas, solutions, or help of any kind is really appreciated.
Thanks in advance

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

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

发布评论

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

评论(1

疏忽 2024-11-15 06:42:50

最后我终于可以让它工作了。仅供记录,如果有人偶然遇到同样的问题,问题是我的解决方案中的另一个项目(不是使用 MSBuild 的项目)仍然针对框架 4,这导致我的运行时为 4.0 而不是 3.5

Finally I could manage to get it working. Just for the record, if by chance anyone stumbles with the same problem, the issue was another project in my solution (not the one using MSBuild) still targeting framework 4, which was causing my runtime to be 4.0 instead of 3.5

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