nuget command not found

I am doing the CI using Jenkins for my app.

section_print "Restoring nuget packages"
nuget restore $SOLUTION_FILE

section_print "Building $CONFIGURATION"
/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool -v build "--configuration:$CONFIGURATION|$DEVICE" $SOLUTION_FILE || fail "Build failed"

The above bash script is working till nuget restore $SOLUTION_FILE. Then i got error 'nuget command not found'. Please need help on this!

Note : I have followed this link

Answers

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    It would seem that you do not have "nuget" installed in your command line environment on your build agent. On a Mac with Xamrin , the "nuget" command is in the Mono framework. I have to assume you have the Mono framework installed, but if not install it. If it is installed, log in to the Mac as the user that Jenkins is using and open Terminal and check your $PATH. Simply enter into the Terminal:

    echo $PATH

    and you should get output like the following:

    /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/mysql/bin:/usr/local/mysql/support-files

    Your output may be very different, but what you want to look for is this:

    /Library/Frameworks/Mono.framework/Versions/Current/Commands

    If the above is not present in the output from echo $PATH, then open your .bash_profile in a text editor (I use nano form the command line) and add that to your path. Do the following in Terminal to do this:

    cd
    nano .bash.profile

    This opens your .bash_profile file in the nano editor. Go to an empty line in that file and add the following text:

    export PATH="/Library/Frameworks/Mono.framework/Versions/Current/Commands:$PATH:"

    When done press CTRL-o to save the file and CTL-x to exit the nano editor. The changes are not loaded yet so either close and re-open Terminal or enter:

    source .bash_profile

    to load the change.

  • Thanks @Jon Goldberger for your response. Yes. It is installed properly. Please look at the below output

    $ echo $PATH
    /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

    Though i got the same error nuget: command not found. Even i tried the below one

    /Library/Frameworks/Mono.framework/Versions/4.6.2/lib/mono/nuget/NuGet.exe restore solutionname.sln

    but not working

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @Moorthyv

    You said you were working from this link: http://www.itworksonmymachine.net/2015/02/12/jenkins-ci-xamarin-ios-xamarin-test-cloud-testflight-part-2/

    Can you go over our guide on using Jenkins with Xamarin?
    https://developer.xamarin.com/guides/cross-platform/ci/jenkins_walkthrough/

    @VinayahamoorthyViswanathan

    This won't work:

    /Library/Frameworks/Mono.framework/Versions/4.6.2/lib/mono/nuget/NuGet.exe restore solutionname.sln
    

    because NuGet.exe has to be run under mono. Try:

    mono /Library/Frameworks/Mono.framework/Versions/4.6.2/lib/mono/nuget/NuGet.exe restore solutionname.sln
    
  • @JGoldberger Thanks!!

    i have tried

    mono /Library/Frameworks/Mono.framework/Versions/4.6.2/lib/mono/nuget/NuGet.exe restore solutionname.sln

    But getting "mono: command not found" error.

    Also i have tried this one https://developer.xamarin.com/guides/cross-platform/ci/jenkins_walkthrough/

    With this approach, Packages not getting downloaded and getting are you missing an assembly reference error

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @VinayahamoorthyViswanathan

    Well that is very odd. If you have /Library/Frameworks/Mono.framework/Versions/Current/Commands in your $PATH as noted, then the mono command (and the nuget command) should be found.

    Are you certain you are logging in to the mac build agent using the correct user, i.e. the same user that you used the echo $PATH command on that showed that /Library/Frameworks/Mono.framework/Versions/Current/Commands is in your $PATH? If that is correct, can you post the directory listing for /Library/Frameworks/Mono.framework/Versions/Current/Commands?

    In Terminal:

    1. cd /Library/Frameworks/Mono.framework/Versions/Current/Commands
    2. ls -la

    This will provide a list of what is in that directory. There should be a bunch of symlinks in that directory including one for mono:

    lrwxr-xr-x    1 root  admin    48 Sep 30 09:59 mono -> /Library/Frameworks/Mono.framework/Commands/mono
    

    and one for nuget:

    lrwxr-xr-x    1 root  admin    49 Sep 30 09:59 nuget -> /Library/Frameworks/Mono.framework/Commands/nuget
    

    Might also be good to make sure you actually have a mono version installed. In Finder, navigate to /Library/Frameworks/Mono.framework/Versions and in there you should see Current and then one or more versions of mono. The folder name for the versions of mono is just the mono version number, so on my end I only have Mono 4.8.0 so in that directory I see Current and 4.8.0.

    It might not be a bad idea to re-install Mono on your Mac. You can get the pkg installer for the latest version of mono from:
    http://www.mono-project.com/download/

Sign In or Register to comment.