tôi đã xem xét một số câu hỏi khác liên quan đến sgen trên đây và một trong hai câu trả lời của họ không áp dụng hoặc câu trả lời của họ không sửa lỗi này cho tôi. Tôi đã cài đặt một số SDK để khắc phục vấn đề này mà không có may mắn. Không nên thay đổi loại tham chiếu vì đây là nơi duy nhất đây là sự cố. Một khi gợi ý là đặt SGen.exe vào thư mục C:\Windows\Microsoft.NET\Framework\v3.5
, nhưng điều đó không được thực hiện trên hộp nơi đây không phải là vấn đề. Trong trường hợp này, SGen.exe
thực sự tồn tại và là đúng nơi mà nó được cho là, nhưng MSBuild vẫn đang gặp vấn đề với việc tìm kiếm nó vì một lý do nào đó!MSBuild không thể tìm thấy sgen khi biên soạn một giải pháp
Bối cảnh:
Chúng tôi có một kịch bản Nant tự động hóa xây dựng của chúng tôi. Trong trường hợp này, NAnt đang gọi MSBuild và MSBuild đang tạo ra lỗi xác nhận là không thể tìm thấy SGen. Dự án dựa trên .NET 3.5. Tôi có môi trường dev chính của tôi (64-bit Vista Ultimate), nơi kịch bản hoạt động hoàn hảo và tôi đang cố gắng sao chép nó trong một máy ảo (64-bit Win 7 Ultimate). Tôi nghĩ rằng tôi có tất cả mọi thứ đến mức mà tôi nên được tốt để đi nhưng điều này không thành công trên hộp Win7 (hoạt động hoàn hảo trên hộp Vista).
Tôi đã thực hiện một số so sánh giữa hai hộp và cả hai đều là trông giống nhau về vấn đề này nhưng vẫn không thành công. Ví dụ: giá trị sdkInstallRootv2.0
của được đặt thành C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\
trên cả hai máy. Trong cả hai máy, SGen.exe
nằm trong thư mục con bin
của đường dẫn đó.
Nant Script:
nhắn<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>
Các lỗi tôi nhận được là:
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)
Tôi đang làm gì sai ở đây đó gây ra MSBuild để VẪN không thể tìm sgen?
Để làm rõ, tôi đã cài đặt các SDK 3.5 và 2.0 và không ai trong số họ thay đổi hành vi cho việc này. – Jaxidian
Bạn đã cố gắng MSBuild giải pháp của bạn trực tiếp (mà không được gọi bởi NAnt)? – Filburt
Yup, cùng một vấn đề. – Jaxidian