9
votes

I'm trying to build a Xamarin.iOS project in Xamarin Studio. Nuget packages restoration is enabled but during any build I get the following error:

/.nuget/NuGet.targets: Error: Command 'mono --runtime=v4.0.30319 "/.nuget/NuGet.exe" install "/ProjectName/packages.config" -source "" -RequireConsent -solutionDir "/" exited with code: 127. (ProjectName)

Running the same command from the terminal gives no issues and works absolutely fine with the following output message:

Restoring NuGet packages... To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.

.nuget/NuGet.exe and .nuget/NuGet.targets are up to date. With the disabled nuget restore at the project .csproj file compilation works just fine.

Please advise.

2

2 Answers

7
votes

Exit code: 127 = "command not found"

Does running that following cmd really work from the base solution directory?

mono --runtime=v4.0.30319 "/.nuget/NuGet.exe" install "/ProjectName/packages.config" -source "" -RequireConsent -solutionDir "/"
  • Mono not being able to find the CIL exe would result in an exit code of 2, but I am assuming it is not finding mono correctly...

If you type which mono is it found in /usr/local/bin or /usr/bin ?

Try :

sudo ln /Library/Frameworks/Mono.framework/Commands/mono /usr/bin

And retry from Xamarin Studio.

Ref: https://forums.xamarin.com/discussion/43192/os-x-10-11-el-capitan-beta-and-xamarin-compiler-error-127

3
votes

With @RobertN's help I was able to locate the error and configured nuget's build target correctly to use proper mono. I specified full path to mono and it works now.

Was:

<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>

Now:

<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">/Library/Frameworks/Mono.framework/Versions/Current/bin/mono --runtime=v4.0 "$(NuGetExePath)"</NuGetCommand>

EDIT1: but the most proper way is to create a link to mono and msc commands by disabling System Integrity Protection in recovery mode:

csrutil disable

http://forums.xamarin.com/discussion/43192/os-x-10-11-el-capitan-beta-and-xamarin-compiler-error-127#latest

Then restart and run those commands:

sudo ln /Library/Frameworks/Mono.framework/Commands/mcs /usr/bin/
sudo ln /Library/Frameworks/Mono.framework/Commands/mono /usr/bin/