编译解决方案时,MSBuild无法找到SGen

Jax*_*ian 7 .net msbuild nant 64-bit sgen

我在这里查看了其他几个与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旗舰版)中复制它.我认为我已经掌握了一切我应该很好的东西但是在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>
Run Code Online (Sandbox Code Playgroud)

我得到的错误信息是这样的:

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)
Run Code Online (Sandbox Code Playgroud)

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

Fil*_*urt 17

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

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


更新

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

  • 谢谢 Filburt,这对我有用,但不确定如果我确实需要 SerializationAssemblies 我会做什么。:-] (2认同)