100

Closed

NuGet.exe does not work on Mono on OS X

description

Platform: Mac OS X

Step to reproduce:
  1. Download and install latest Mono Runtime or SDK (2.10.2 — http://ftp.novell.com/pub/mono/archive/2.10.2/macos-10-x86/5.4/MonoFramework-MDK-2.10.2_5.4.macos10.novell.x86.dmg -OR- http://ftp.novell.com/pub/mono/archive/2.10.2/macos-10-x86/5.4/MonoFramework-MRE-2.10.2_5.4.macos10.novell.x86.dmg)
  2. Download latest NuGet binary (http://nuget.codeplex.com/releases/view/58939)
  3. Run mono NuGet.exe. The bootstrap process completes successfully.
  4. Run mono NuGet.exe (NuGet.exe is now the name of the freshly-downloaded, bootstrapped assembly). Command fails (see attached for output)
  5. Run mono --runtime=v4.0 Command fails with a different error message (see attached for output).
Expected results:
NuGet outputs usage information.

file attachments

Closed Sep 25, 2014 at 4:52 PM by danliu
close per customer request.

comments

bvanderveen wrote Jul 9, 2011 at 10:28 PM

I'm wondering also if support for the Mono runtime is a goal of the NuGet project.

Haacked wrote Jul 11, 2011 at 4:40 PM

We've accepted patches from the mono team in the past. But we haven't gone out of our way to add Mono to our test suites.

SimonCropp wrote Aug 20, 2011 at 4:53 AM

one blocking issue was this one. it will be fixed in 2.10.5

SimonCropp wrote Aug 20, 2011 at 4:53 AM

SimonCropp wrote Aug 20, 2011 at 5:49 AM

next issue is Microsoft.Build.dll is not currently shipped with Mono
So you will need a copy of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.Build.dll in the same location as nuget.exe so mono can find it

SimonCropp wrote Aug 20, 2011 at 6:28 AM

next issue is the certificate for nuget.org seems to be invalid http://nuget.codeplex.com/workitem/1446
mono is more strict than .net about this and will throw an exception.

If the certificate error cant be fixed it can be explicitly ignored by addin this to Nuget.Program
    public static int Main(string[] args) {
        try {
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

SimonCropp wrote Aug 21, 2011 at 10:36 PM

next issue
"Directory.EnumerateFiles doe not enumerate files"
http://bugzilla.xamarin.com/show_bug.cgi?id=351

ahjohannessen wrote Sep 2, 2011 at 8:51 PM

I get the same errors as bvanderveen and wonder the same; is Mono something that you even care about when you build the core architecture.

pranavkm wrote Sep 2, 2011 at 10:12 PM

SimonCropp's sent a pull request for EnumerateFiles and 1446 is fixed.
The issue you are running into is probably related to MsBuild related assemblies not being available on Mono. I'm not entirely sure we could redistribute Microsoft.Build.dll with our executable.

Does dropping the dll allow besides nuget.exe to function correctly? I may be able to make the PackCommand lazily load support for *proj files if we find MsBuild to be available.

Haacked wrote Sep 2, 2011 at 10:18 PM

To respond to ahjohannessen's question, we're pretty much neutral to it. It's not a high priority for us to make it work on Mono, but we accept patches when it fixes issues in Mono. In fact, the mono team has submitted patches in the past and we've taken them.

ahjohannessen wrote Sep 3, 2011 at 3:32 PM

Would it be an idea to separate the core of NuGet and the command stuff into its own repo such that it would be easier to for us with Linux/OSX to start working on it?

evarlast wrote Sep 4, 2011 at 3:02 PM

I just tried with a build-today version of mono master and I got this output which makes me really think it is not something mono can fix.
[mono] ~ @ mono NuGet.exe
Method not found: 'NuGet.Commands.ProjectFactory.ResolveTargetPath'.
[mono] ~ @ mono --runtime=v4.0 NuGet.exe
Method not found: 'NuGet.Commands.ProjectFactory.ResolveTargetPath'.

dfowler wrote Sep 5, 2011 at 6:14 AM

@ahjohannessen you can certainly do that but you'd be responsible for keeping them in sync.

rolfkvinge wrote Sep 21, 2011 at 9:29 PM

I just fixed this issue in mono (master):

[mono] ~ @ mono NuGet.exe
Method not found: 'NuGet.Commands.ProjectFa​ctory.ResolveTargetPath'.

and now "mono NuGet.exe" shows the help.

royjacobs wrote Aug 1, 2012 at 3:47 PM

Under Mono 2.10.8.1 on Ubuntu 12.04 and using the NuGet build from CI (2.0.30731.25), I get this error:

"Could not load type 'NuGet.Commands.ProjectFactory' from assembly 'NuGet, Version=20.30731.25, Culture=neutral, PublicKeyToken=null'.

royjacobs wrote Aug 1, 2012 at 3:52 PM

Sorry, version should of course be 2.0.30731.25

royjacobs wrote Aug 1, 2012 at 8:39 PM

Sorry, this is fixed in trunk. Package restore doesn't seem to work properly though, but I'll add another ticket for that.

knocte wrote Dec 3, 2012 at 3:15 PM

@SimonCropp: how did you find out the problem with the certificate? Is it still invalid?

I ask because I'm getting in my box the error "WARNING: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure" when trying to restore packages, and I was wondering if it was the same issue.

Thanks

henke wrote Jan 6, 2013 at 7:08 PM

It's likely that the error message:

Could not load type 'NuGet.Commands.ProjectFactory' from assembly 'NuGet, Version=20.30731.25, Culture=neutral, PublicKeyToken=null'.

Comes from the fact that this is the beginnings of that class:

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;
using System.Xml.Linq;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Logging;
using NuGet.Common;

namespace NuGet.Commands
{
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
internal class ProjectFactory : IPropertyProvider
Indeed, that Maintainability message should NOT have been surpressed... I belive the problem here is a dependency on MsBuild -- why on earth would the command line have such a dependency?

This dependency causes these build failures:

/home/xyz/labs/nuget/src/CommandLine/CommandLine.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->
Commands/ProjectFactory.cs(9,23): error CS0234: The type or namespace name `Evaluation' does not exist in the namespace `Microsoft.Build'. Are you missing an assembly reference?
Commands/ProjectFactory.cs(10,23): error CS0234: The type or namespace name `Execution' does not exist in the namespace `Microsoft.Build'. Are you missing an assembly reference?
Commands/ProjectFactory.cs(12,23): error CS0234: The type or namespace name `Logging' does not exist in the namespace `Microsoft.Build'. Are you missing an assembly reference?
Commands/ProjectFactory.cs(52,31): error CS0246: The type or namespace name `Project' could not be found. Are you missing a using directive or an assembly reference?
Commands/ProjectFactory.cs(291,46): error CS0246: The type or namespace name `ProjectProperty' could not be found. Are you missing a using directive or an assembly reference?
Commands/ProjectFactory.cs(305,42): error CS0246: The type or namespace name `BuildResult' could not be found. Are you missing a using directive or an assembly reference?
Commands/ProjectFactory.cs(722,38): error CS0246: The type or namespace name `ProjectItem' could not be found. Are you missing a using directive or an assembly reference?
Common/MSBuildProjectSystem.cs(7,23): error CS0234: The type or namespace name `Evaluation' does not exist in the namespace `Microsoft.Build'. Are you missing an assembly reference?
Common/MSBuildProjectSystem.cs(84,29): error CS0246: The type or namespace name `ProjectItem' could not be found. Are you missing a using directive or an assembly reference?
Common/MSBuildProjectSystem.cs(89,16): error CS0246: The type or namespace name `ProjectItem' could not be found. Are you missing a using directive or an assembly reference?
Common/MSBuildProjectSystem.cs(121,24): error CS0118: `NuGet.Common.MSBuildProjectSystem.Project' is a `property' but a `type' was expected

And that's probably why a type with such dependencies cannot be loaded -- it would be missing code to call into.

henke wrote Jan 6, 2013 at 8:18 PM

Because it's always mentioned that "someone should send a pull request", here's a branch that removes the dependency while breaking the functionality itself; but it does provide interfaces that you can map onto Microsoft.Build or a simple XML writer like I did in albacore when working around the F# HintPath bug of yours.

http://nuget.codeplex.com/SourceControl/network/forks/henke/nuget?branch=strip_ms

lextm wrote Jan 27, 2013 at 10:54 AM

It is better to import necessary certificates to stop HTTPS errors, and then use Mono's own Microsoft.Build.dll (which I can find in Mono's Windows installation) instead of Microsoft's.

I managed to get the command line tool running as I posted here,

http://www.lextm.com/2013/01/how-to-use-nuget-on-mono-part-i.html

henke wrote Sep 25, 2014 at 11:24 AM

It works now, you can close this bug.