在安装了 VS2010 的机器上和在安装了 7.1 SDK 的机器上构建之间的差异

发布于 2024-10-03 15:28:22 字数 800 浏览 1 评论 0原文

我们正在尝试升级代码库以使用 Visual Studio 2010,但在构建服务器上对所有内容进行排序时遇到问题。我们不想在构建服务器上安装 Visual Studio 2010,因此只安装了 .Net 4 框架和 SDK (v7.1)。

我们仍然希望以 .Net 3.5 平台为目标(我们将在未来某个时候升级到 .Net 4,但现在还不想)。

我们已经设法编译代码,但现在遇到如下运行时错误。

无法加载文件或程序集“System.Drawing,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。系统找不到指定的文件。

问题是运行时正在尝试反序列化嵌入的资源,如果我查看反射器中的资源,我会发现它们都是 .Net 4.0 对象。例如,我们的 Windows 应用程序的图标的类型为 System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a。

那么看起来 MSBuild 正在错误地编译资源(使用与目标不同的运行时)?我通过查看在我的开发计算机上构建的 dll 和在构建服务器上构建的 dll 的差异来确认这一点 - 很明显看到一个 dll 的资源使用 2.0.0.0 版本,而另一个(来自构建服务器)使用 4.0 .0.0。在这两种情况下,项目引用都是 v2.0.0.0 dll(正如人们所期望的那样)。

有谁知道为什么 MSBuild 将资源编译为 4.0 对象?

提前致谢。

克里斯

We are trying to upgrade our code base to use Visual Studio 2010 but are having problems getting everything sorted on our build servers. We do not want to install Visual Studio 2010 on our build servers and so have installed just the .Net 4 framework and SDK (v7.1).

We are still wanting to target the .Net 3.5 platform (we will upgrade to .Net 4 at some point in the future but do not want to just yet).

We have managed to get the code to compile but now we are running into runtime errors like the following.

Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

The problem is that runtime is trying to deserialize the embedded resource and if I look at the resources in reflector, I see that they are all .Net 4.0 objects. For example, the icon of our a windows app is of type System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.

So it looks like MSBuild is compiling the resources incorrectly (using a different runtime to the target)? I have confirmed this by looking at the diffs of the dll built on my dev machine and that built on the build server - it is clear to see that one dll's resources use 2.0.0.0 version and the other (from the build server) uses 4.0.0.0. The project references are to the v2.0.0.0 dlls in both cases (as one would expect).

Does anyone have any idea as to why MSBuild is compiling the resources as 4.0 objects?

Thanks in advance.

Chris

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

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

发布评论

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

评论(1

孤寂小茶 2024-10-10 15:28:22

当您将解决方案升级到VS2010时,您是否更改了目标框架?您可以通过在文本编辑器中查看 csproj 文件来查找它。
您的构建服务器中有 7.0a 框架吗?

编辑:

我不久前遇到了同样的问题,它与未设置注册表项有关。看看这里:

我认为您需要手动添加注册表项HKLM\Software\Microsoft\MsBuild\ToolsVersions\SDK35ToolsPath

When you upgraded your solution to VS2010, did you change the targeted framework? You can look for it by viewing the csproj files in a text editor.
Do you have the 7.0a framework in your build server?

EDIT :

I ran into the same problem a while ago and it has something to do with registry key not set. Take a look here :
http://connect.microsoft.com/VisualStudio/feedback/details/594338/tfs-2010-build-agent-and-windows-7-1-sdk-targeting-net-3-5-generates-wrong-embedded-resources

I think you need to manually add the registry key HKLM\Software\Microsoft\MsBuild\ToolsVersions\SDK35ToolsPath

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