gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 10:12:50 31 4
gpt4 key购买 nike

我在这里查看了其他几个与 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子目录。

南特脚本:

<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?

最佳答案

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

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

更新

如果您还没有尝试过,请确保 <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>为发布和调试配置设置。

关于.net - 编译解决方案时MSBuild找不到SGen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2601911/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com