编译解决方案时MSBuild找不到SGen [英] MSBuild cannot find SGen when compiling a solution

查看:36
本文介绍了编译解决方案时MSBuild找不到SGen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:WindowsMicrosoft.NETFrameworkv3.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!

背景:

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

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).

我对这两个盒子进行了一些比较,它们在这方面看起来完全相同,但仍然失败.例如,HKEY_LOCAL_MACHINESOFTWAREMicrosoft.NETFrameworksdkInstallRootv2.0 值设置为 C:Program FilesMicrosoft.NETSDKv2.0 64bit 在两台机器上.在两台机器中,SGen.exe 都在该路径的 bin 子目录中.

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_MACHINESOFTWAREMicrosoft.NETFramework's sdkInstallRootv2.0 value is set to C:Program FilesMicrosoft.NETSDKv2.0 64bit on both machines. In both machines, SGen.exe is in that path's bin subdirectory.

NAnt 脚本:

<target name="report-installer" depends="fail-if-environment-not-set">
    <exec program="MSBuild.exe" basedir="${framework35.directory}">
        <arg value="${tools.directory.current}ReportInstallerReportInstaller.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:ProjectsProductionToolsReportInstallerReportInstaller.sln" on node 0 (default targets).
     [exec]   Building solution configuration "Release|Any CPU".
     [exec] Project "C:ProjectsProductionToolsReportInstallerReportInstaller.sln" (1) is building "C:ProjectsProductionToolsReportInstallerReportInstaller.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_MACHINESOFTWAREMicrosoft.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:WindowsMicrosoft.NETFrameworkv2.0.50727Microsoft.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_MACHINESOFTWAREMicrosoft.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:ProjectsProductionToolsReportInstallerReportInstaller.csproj" (default targets) -- FAILED.
     [exec] Done Building Project "C:ProjectsProductionToolsReportInstallerReportInstaller.sln" (default targets) -- FAILED.
     [exec]
     [exec] Build FAILED.
     [exec]
     [exec] "C:ProjectsProductionToolsReportInstallerReportInstaller.sln" (default target) (1) ->
     [exec] "C:ProjectsProductionToolsReportInstallerReportInstaller.csproj" (default target) (2) ->
     [exec] (GenerateSerializationAssemblies target) ->
     [exec]   C:WindowsMicrosoft.NETFrameworkv2.0.50727Microsoft.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_MACHINESOFTWAREMicrosoft.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:ProjectsProductionSource
eports.build(15,4):
     [call] External Program Failed: C:WindowsMicrosoft.NETFrameworkv3.5MSBuild.exe (return code was 1)

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

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

推荐答案

这似乎是我最近刚遇到的一个常见问题.

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".

更新

如果您还没有尝试过,请确保为 Release AND Debug 配置设置了 Off</GenerateSerializationAssemblies>.

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

这篇关于编译解决方案时MSBuild找不到SGen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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