Command line build and nuget packages

I already have a command line build working using mdtool. However, I have switched to getting my dependencies via nuget. When I launch XamStudio, it automatically downloads the nuget packages making the build successful. However, a command line build does NOT automatically download the packages from nuget servers. What command can I run to cause that to happen?


  • mattwardmattward GBMember Xamurai
    edited June 2014

    To download the NuGet packages from the command line you can use NuGet.exe. You can restore the packages using a command similar to the following if you are running on the Mac:

    mono --runtime=v4.0 nuget.exe restore YourSolution.sln

    For Windows you can use:

    nuget.exe restore YourSolution.sln

    You should be able to use the official NuGet.exe from the main NuGet codeplex site.

    If that does not work you can use the NuGet.exe that ships with Xamarin Studio which can also be downloaded separately. You will need all the binary files from GitHub (NuGet.exe, NuGet.Core.dll and Microsoft.Web.XmlTransform.dll )

    Another alternative is to use the MSBuild based package restore which would restore during the build. This has been deprecated by the NuGet team since there are problems with NuGet packages that include custom MSBuild targets. Xamarin Studio does not have a way to enable this feature so there is not an easy way to set this up on the Mac. I would recommend using NuGet.exe restore.

  • Thanks, that did the trick!

  • jeffryvujeffryvu NLMember, University

    On Mac you can just do
    nuget restore YourSolution.sln, right?

    as nuget is already in the path when you install Xamarin. So, without the .exe.

    How is that different from
    mono --runtime=v4.0 nuget.exe restore YourSolution.sln?

  • mattwardmattward GBMember Xamurai

    @JeffryvandeVuurst‌ - Correct you can just run nuget restore YourSolution.sln on the Mac.

    Recent versions of Mono (after 3.6) ship with NuGet so you do not need to use a separate download of NuGet.exe. When I posted that original comment I think mono 3.4 was the latest stable version and NuGet was yet not being included.

  • AdnanKhanAdnanKhan USMember ✭✭
    edited October 2015

    I have a test IOS 9.0 CocoSharp project and when run this command:

    nuget restore YourSolution.sln

    it gives me error any idea? Thank You
    Error reading '/....GameName.IOS/packages.config'
    I am using : nuget.exe - latest (v3.2.0)

  • mattwardmattward GBMember Xamurai
    edited October 2015

    The error does not really indicate anything apart from there being an error reading the packages.config file. Try adding the -verbosity detailed flag to the command line to get the full callstack.

    nuget restore YourSolution.sln -verbosity detailed
Sign In or Register to comment.