Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run NuGet on Mono 2.10.9?

Tags:

nuget

mono

I have tried to get NuGet running on Mono 2.10.9 (Mac), but with no luck.

I want to install Nancy from the NuGet repository:

mono --runtime=v4.0 /usr/local/bin/NuGet.exe install Nancy -Version 0.11.0

But, end up with this error message:

Missing method System.Security.Cryptography.CryptoConfig::get_AllowOnlyFipsAlgorithms() in assembly /Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/4.0/mscorlib.dll, referenced in assembly /usr/local/bin/NuGet.exe
Method not found: 'System.Security.Cryptography.CryptoConfig.get_AllowOnlyFipsAlgorithms'.

I can list the repositories without problems.

mono --runtime=v4.0 /usr/local/bin/NuGet.exe list Nancy

I have tried to add Microsoft.Build.dll to the same path as NuGet.exe (a tip from a site. I can't remember where).

I end up with this error:

Invalid type Microsoft.Build.Evaluation.Project for instance field NuGet.Common.MSBuildProjectSystem:<Project>k__BackingField
Could not load type 'NuGet.Common.MSBuildProjectSystem' from assembly 'NuGet, Version=2.0.30619.9000, Culture=neutral, PublicKeyToken=null'.

Any suggestions on how I can get NuGet.exe running on Mono (Mac)?

like image 343
Fossmo Avatar asked Jul 02 '12 21:07

Fossmo


2 Answers

I'm afraid you can't do that with the version of Mono you have installed. That particular release (2.10.9) did not include the static property:

System.Security.Cryptography.CryptoConfig.AllowOnlyFipsAlgorithms

which seems to be required by NuGet.exe "install" feature. The "list" command probably works because it doesn't make use of the cryptography assemblies (in .NET assemblies are lazily loaded, only when executing code requires them).

On a positive note, it seems like in the github version of Mono the CryptoConfig class was updated with this property, as you can see here:

Current mono CryptoConfig.cs source, on master branch

This shows the change should have been included in the 2.10.9 release:

History of changes on mono's CryptoConfig.cs

The AllowOnlyFipsAlgorithms property was added on May 2nd 2011, a full year ago, and yet it's not in the current stable release!!! Which is weird...

You could try downloading the alpha release (Mono 2.11.2) and see what that does for you.

P.S. I've looked at the sources for the 2.11.2 alpha version and it looks like this property is included in this build, so give it a try. Hope this helps.

like image 180
Fengari Avatar answered Oct 05 '22 04:10

Fengari


There are several steps you need,

  1. Install all mono assemblies (so as to get WindowsBase).
  2. Import certificates.
  3. Get Microsoft.Build.dll.

Then you should be able to run NuGet. I documented more details here,

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

like image 27
Lex Li Avatar answered Oct 05 '22 04:10

Lex Li