MSBuild 编译解决方案时找不到 SGen

发布于 2024-08-28 07:53:32 字数 4703 浏览 11 评论 0原文

我在这里查看了其他几个与 SGen 相关的问题,要么他们的答案不适用,要么他们的答案不能为我解决这个问题。我安装了几个 SDK 来解决这个问题,但没有成功。不应更改引用类型,因为这是唯一出现问题的地方。曾经建议将 SGen.exe 放入 C:\Windows\Microsoft.NET\Framework\v3.5 文件夹中,但在这不是问题的盒子上没有这样做。在这种情况下,SGen.exe 实际上存在,并且位于它应该在的位置,但由于某种原因,MSBuild 仍然无法找到它!

背景:

我们有一个 NAnt 脚本来自动化我们的构建。在这种情况下,NAnt 正在调用 MSBuild,而 MSBuild 正在生成错误,声称无法找到 SGen。该项目基于 .NET 3.5。我有我的主要开发环境(64 位 Vista Ultimate),其中脚本运行良好,我尝试在 VM(64 位 Win 7 Ultimate)中复制它。我想我已经拥有了一切,应该可以使用了,但这在 Win7 机器上失败了(在 Vista 机器上完美运行)。

我对两个盒子进行了一些比较,它们在这方面看起来相同,但仍然失败。例如,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFrameworksdkInstallRootv2.0 值设置为 C:\Program Files\Microsoft.NET\SDK\两台机器上的 v2.0 64bit\。在两台计算机中,SGen.exe 位于该路径的 bin 子目录中。

NAnt 脚本:

<target name="report-installer" depends="fail-if-environment-not-set">
    <exec program="MSBuild.exe" basedir="${framework35.directory}">
        <arg value="${tools.directory.current}\ReportInstaller\ReportInstaller.sln" />
        <arg value="/p:Configuration=${buildconfiguration.current}" />
    </exec>
</target>

我收到的错误消息是这样的:

report-installer:

     [exec] Microsoft (R) Build Engine Version 3.5.30729.4926
     [exec] [Microsoft .NET Framework, Version 2.0.50727.4927]
     [exec] Copyright (C) Microsoft Corporation 2007. All rights reserved.
     [exec]
     [exec] Build started 4/8/2010 11:28:23 AM.
     [exec] Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" on node 0 (default targets).
     [exec]   Building solution configuration "Release|Any CPU".
     [exec] Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" (1) is building "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.csproj" (2) on node 0 (default targets).
     [exec]   Could not locate the .NET Framework SDK.  The task is looking for the path to the .NET Framework SDK at the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.  You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK.  2.) Manually set the above registry key to the correct location.
     [exec] CoreCompile:
     [exec] Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
     [exec] C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1902,9): error MSB3091: Task failed because "sgen.exe" was not found, or the .NET Framework SDK v2.0 is not installed.  The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework. You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK v2.0.  2.) Manually set the above registry key to the correct location.  3.) Pass the correct location into the "ToolPath" parameter of the task.
     [exec] Done Building Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.csproj" (default targets) -- FAILED.
     [exec] Done Building Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" (default targets) -- FAILED.
     [exec]
     [exec] Build FAILED.
     [exec]
     [exec] "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" (default target) (1) ->
     [exec] "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.csproj" (default target) (2) ->
     [exec] (GenerateSerializationAssemblies target) ->
     [exec]   C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1902,9): error MSB3091: Task failed because "sgen.exe" was not found, or the .NET Framework SDK v2.0 is not installed.  The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.  You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK v2.0.  2.) Manually set the above registry key to the correct location.  3.) Pass the correct location into the "ToolPath" parameter of the task.
     [exec]
     [exec]     0 Warning(s)
     [exec]     1 Error(s)
     [exec]
     [exec] Time Elapsed 00:00:00.24
     [call] C:\Projects\Production\Source\reports.build(15,4):
     [call] External Program Failed: C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe (return code was 1)

我在这里做错了什么导致 MSBuild 仍然无法找到 SGen?

I've looked at several other SGen-related questions on here and either their answers don't apply or their answers don't fix this for me. I have installed several SDKs to fix this issue with no luck. Reference types should not be changed since this is the only place this is a problem. Once suggestion is to put SGen.exe into the C:\Windows\Microsoft.NET\Framework\v3.5 folder, but that's not been done on the box where this is not a problem. In this scenario, SGen.exe actually exists and is right where it's supposed to be, but MSBuild still is having issues with finding it for some reason!

Background:

We have a NAnt script that automates our builds. In this scenario, NAnt is calling MSBuild and MSBuild is generating the error claiming to be unable to find SGen. The project is .NET 3.5-based. I have my primary dev environment (64-bit Vista Ultimate) where the script works perfectly and I am attempting to duplicate it in a VM (64-bit Win 7 Ultimate). I THINK I have everything to the point where I should be good-to-go but this fails on the Win7 box (works perfectly on the Vista box).

I have done some comparisons between the two boxes and they both look identical in this regard, but it still fails. For example, the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework's sdkInstallRootv2.0 value is set to C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\ on both machines. In both machines, SGen.exe is in that path's bin subdirectory.

NAnt Script:

<target name="report-installer" depends="fail-if-environment-not-set">
    <exec program="MSBuild.exe" basedir="${framework35.directory}">
        <arg value="${tools.directory.current}\ReportInstaller\ReportInstaller.sln" />
        <arg value="/p:Configuration=${buildconfiguration.current}" />
    </exec>
</target>

The error message I get is this:

report-installer:

     [exec] Microsoft (R) Build Engine Version 3.5.30729.4926
     [exec] [Microsoft .NET Framework, Version 2.0.50727.4927]
     [exec] Copyright (C) Microsoft Corporation 2007. All rights reserved.
     [exec]
     [exec] Build started 4/8/2010 11:28:23 AM.
     [exec] Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" on node 0 (default targets).
     [exec]   Building solution configuration "Release|Any CPU".
     [exec] Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" (1) is building "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.csproj" (2) on node 0 (default targets).
     [exec]   Could not locate the .NET Framework SDK.  The task is looking for the path to the .NET Framework SDK at the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.  You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK.  2.) Manually set the above registry key to the correct location.
     [exec] CoreCompile:
     [exec] Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
     [exec] C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1902,9): error MSB3091: Task failed because "sgen.exe" was not found, or the .NET Framework SDK v2.0 is not installed.  The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework. You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK v2.0.  2.) Manually set the above registry key to the correct location.  3.) Pass the correct location into the "ToolPath" parameter of the task.
     [exec] Done Building Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.csproj" (default targets) -- FAILED.
     [exec] Done Building Project "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" (default targets) -- FAILED.
     [exec]
     [exec] Build FAILED.
     [exec]
     [exec] "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.sln" (default target) (1) ->
     [exec] "C:\Projects\Production\Tools\ReportInstaller\ReportInstaller.csproj" (default target) (2) ->
     [exec] (GenerateSerializationAssemblies target) ->
     [exec]   C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1902,9): error MSB3091: Task failed because "sgen.exe" was not found, or the .NET Framework SDK v2.0 is not installed.  The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.  You may be able to solve the problem by doing one of the following:  1.) Install the .NET Framework SDK v2.0.  2.) Manually set the above registry key to the correct location.  3.) Pass the correct location into the "ToolPath" parameter of the task.
     [exec]
     [exec]     0 Warning(s)
     [exec]     1 Error(s)
     [exec]
     [exec] Time Elapsed 00:00:00.24
     [call] C:\Projects\Production\Source\reports.build(15,4):
     [call] External Program Failed: C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe (return code was 1)

What am I doing wrong here that is causing MSBuild to STILL be unable to find SGen?

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

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

发布评论

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

评论(4

你丑哭了我 2024-09-04 07:53:32

这似乎是我自己最近遇到的一个常见问题。

在“构建”选项卡上的项目属性中,将选项“生成序列化程序集”从“自动”设置为“关闭”。


更新

如果您尚未尝试,请确保为发布和调试配置设置Off

This seems to be a common issue I just ran into these days myself.

In your project properties on the "Build" tab set the option "Generate serialization assembly" from "Auto" to "Off".


update

If you not already tried, make sure that <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> is set for Release AND Debug configuration.

一个人的旅程 2024-09-04 07:53:32

我认为有一个解决方案,无需安装旧版本的 VS

请尝试以下操作:

Key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0\

字符串值:
名称:安装文件夹
值(默认):C:\Program Files (x86)\Microsoft.NET\SDK\v2.0\

或将此代码保存为 .reg 文件并执行:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0]
"InstallationFolder"="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\v2.0

I think there is a solution without the pain of installing old versions of VS

Please try the following:

Key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0\

String Value:
Name: InstallationFolder
Value(default): C:\Program Files (x86)\Microsoft.NET\SDK\v2.0\

or save this code as .reg file and execute:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0]
"InstallationFolder"="C:\\Program Files (x86)\\Microsoft.NET\\SDK\\v2.0
最偏执的依靠 2024-09-04 07:53:32

在“构建”选项卡上的项目属性中,将“生成序列化程序集”选项从“自动”设置为“关闭”。

它解决了我的问题。

In your project properties on the "Build" tab set the option "Generate serialization assembly" from "Auto" to "Off".

Its resolved my issue.

巴黎夜雨 2024-09-04 07:53:32

我不确定发生了什么或为什么发生这种情况,但我为解决此问题所做的就是安装 Visual Studio 2005。我已经安装了 .NET 2.0 SDK 以及 .NET 3.5 SDK,但运气不佳,但安装了Visual Studio 2005 安装程序为我解决了这个问题。这是一个可怕的解决方案,但它仍然是一个解决方案。

希望我们能够尽快迁移到 .NET 4.0,并彻底摆脱 .NET 2.0 及其问题。

I'm not sure what or why this was happening but what I did to get around this was to install Visual Studio 2005. I had already installed the .NET 2.0 SDK as well as the .NET 3.5 SDK with no luck but something with the Visual Studio 2005 installer resolved this issue for me. This is a HORRIBLE solution, but it was, nonetheless, a solution.

Hopefully we can migrate to .NET 4.0 soon and be completed rid of .NET 2.0 and its issues.

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