Cake 构建在 OS X 上失败,无法找到 msbuild.exe

Cake build fails on OS X, can't find msbuild.exe

我正在尝试为我的 Xamarin 项目设置 Cake 构建。它在 Windows 上运行良好,但在 OS X (El Captain) 上运行失败。 build.sh is here, build.cake is here.

构建失败并在 NuGetRestore 上显示此消息:

MSBuild auto-detection: using msbuild version '4.0' from '/Library/Frameworks/Mono.framework/Versions/4.4.2/lib/mono/4.5'.
MsBuild.exe does not exist at '/Library/Frameworks/Mono.framework/Versions/4.4.2/lib/mono/4.5/msbuild.exe'.
An error occured when executing task 'Restore-NuGet-Packages'.
Error: NuGet: Process returned an error (exit code 1).

./build.sh -v "Diagnostic" 给出:

Executing: /Users/artur/sources/xamarin-range-slider/tools/NuGet.exe restore "/Users/artur/sources/xamarin-range-slider/Xamarin.RangeSlider.sln" -Verbosity detailed -NonInteractive
MSBuild auto-detection: using msbuild version '4.0' from '/Library/Frameworks/Mono.framework/Versions/4.4.2/lib/mono/4.5'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
System.AggregateException: One or more errors occurred. ---> NuGet.CommandLineException: MsBuild.exe does not exist at '/Library/Frameworks/Mono.framework/Versions/4.4.2/lib/mono/4.5/msbuild.exe'.
  at NuGet.CommandLine.MsBuildUtility.GetProjectReferences (System.String msbuildDirectory, System.String[] projectPaths, Int32 timeOut) <0x34e8ed0 + 0x00677> in <filename unknown>:0
  at NuGet.CommandLine.RestoreCommand.DetermineRestoreInputs () <0x3452690 + 0x002af> in <filename unknown>:0
  at NuGet.CommandLine.RestoreCommand+<ExecuteCommandAsync>d__23.MoveNext () <0x3451688 + 0x0028b> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) <0x1d1d960 + 0x00049> in <filename unknown>:0
  at System.Threading.Tasks.Task.Wait (Int32 millisecondsTimeout, CancellationToken cancellationToken) <0x1d1f150 + 0x000c8> in <filename unknown>:0
  at System.Threading.Tasks.Task.Wait () <0x1d1ef70 + 0x00033> in <filename unknown>:0
  at NuGet.CommandLine.Command.Execute () <0x343a298 + 0x00213> in <filename unknown>:0
  at NuGet.CommandLine.Program.MainCore (System.String workingDirectory, System.String[] args) <0x718cc0 + 0x005e0> in <filename unknown>:0
---> (Inner Exception #0) NuGet.CommandLineException: MsBuild.exe does not exist at '/Library/Frameworks/Mono.framework/Versions/4.4.2/lib/mono/4.5/msbuild.exe'.
  at NuGet.CommandLine.MsBuildUtility.GetProjectReferences (System.String msbuildDirectory, System.String[] projectPaths, Int32 timeOut) <0x34e8ed0 + 0x00677> in <filename unknown>:0
  at NuGet.CommandLine.RestoreCommand.DetermineRestoreInputs () <0x3452690 + 0x002af> in <filename unknown>:0
  at NuGet.CommandLine.RestoreCommand+<ExecuteCommandAsync>d__23.MoveNext () <0x3451688 + 0x0028b> in <filename unknown>:0 <---

An error occured when executing task 'Restore-NuGet-Packages'.
Error: Cake.Core.CakeException: NuGet: Process returned an error (exit code 1).
  at Cake.Core.Tooling.Tool`1[TSettings].ProcessExitCode (Int32 exitCode) <0x3a8b208 + 0x000fb> in <filename unknown>:0
  at Cake.Core.Tooling.Tool`1[TSettings].Run (Cake.Core.Tooling.TSettings settings, Cake.Core.IO.ProcessArgumentBuilder arguments, Cake.Core.IO.ProcessSettings processSettings, System.Action`1 postAction) <0x3a34a88 + 0x00177> in <filename unknown>:0
  at Cake.Core.Tooling.Tool`1[TSettings].Run (Cake.Core.Tooling.TSettings settings, Cake.Core.IO.ProcessArgumentBuilder arguments) <0x3a34a48 + 0x0002f> in <filename unknown>:0
  at Cake.Common.Tools.NuGet.Restore.NuGetRestorer.Restore (Cake.Core.IO.FilePath targetFilePath, Cake.Common.Tools.NuGet.Restore.NuGetRestoreSettings settings) <0x3a34328 + 0x0004b> in <filename unknown>:0
  at Cake.Common.Tools.NuGet.NuGetAliases.NuGetRestore (ICakeContext context, Cake.Core.IO.FilePath targetFilePath, Cake.Common.Tools.NuGet.Restore.NuGetRestoreSettings settings) <0x3a33f18 + 0x0012f> in <filename unknown>:0
  at CakeBuildScriptImpl.NuGetRestore (Cake.Core.IO.FilePath targetFilePath, Cake.Common.Tools.NuGet.Restore.NuGetRestoreSettings settings) <0x3a33ed8 + 0x0002b> in <filename unknown>:0
  at CakeBuildScriptImpl+<Execute>c__AnonStorey0.<>m__0 () <0x3a33e40 + 0x00087> in <filename unknown>:0
  at Cake.Core.CakeTaskBuilderExtensions+<>c__DisplayClass4.<Does>b__3 (ICakeContext context) <0x3a33e20 + 0x00014> in <filename unknown>:0
  at Cake.Core.ActionTask.Execute (ICakeContext context) <0x3a33d68 + 0x00059> in <filename unknown>:0
  at Cake.Core.DefaultExecutionStrategy.Execute (Cake.Core.CakeTask task, ICakeContext context) <0x3a33b18 + 0x00162> in <filename unknown>:0
  at Cake.Core.CakeEngine.ExecuteTask (ICakeContext context, IExecutionStrategy strategy, System.Diagnostics.Stopwatch stopWatch, Cake.Core.CakeTask task, Cake.Core.CakeReport report) <0x3a33538 + 0x00099> in <filename unknown>:0

这可能是因为路径中 NuGet.exe 上的一个版本不知道单声道。

通过 运行 build.sh -v "Diagnostic",您将获得有关如何为还原操作调用 NuGet 命令行的详细日志。

NuGetRestore(FilePath, ​NuGetRestoreSettings)​ on the NuGetRestoreSettings you can set the Verbosity property to Detailed 还有一个重载,可以从 NuGet 命令行获取更详细的日志记录。

如果它不是项目工具文件夹中的 nuget.exe,您可以更改引导程序以在路径中首先添加工具文件夹。 (如果您只想测试该理论,也可以在 NuGetRestoreSettings 上设置 ToolsPath 属性。

如果它是 运行 NuGet.exe 的路径,请通过 运行 不带参数的 nuget (mono ./tools/nuget.exe).

检查您拥有的 nuget 版本

作为参考,这似乎是 NuGet 控制台的一个已知问题,参考 GitHub 问题 NuGet/Home#3085