Private nuget repo script

I’ve added a script to my build definition to connect to our feed, but this is causing the builds to hang indefinitely and the log is empty.

What was the script you added?

#!/bin/bash
set -ex

nuget sources add -Name CompanyName -Source companyname.visualstudio.com 

I also tried with the username/password arguments

@godreikrisztian do you have an idea?

Would you like me to kick off a build and let it run for you?

Not required, we just found that your build went over the build log limits - it generated well over a GB worth of new lines O_O

I wonder why nuget sources .. might have an effect like this…

For the record, the last lines of the log are all:

                             \n                    ...

Repeated in an infinite loop.

btw it seems the issue is related to a NuGet bug, which seemes to be fixed in newer versions: https://github.com/NuGet/Home/issues/1893

The NuGet version which ships with Xamarin is an older one, affected by this bug.

I just confirmed this on my Mac, where I have:

NuGet Version: 2.12.0.0

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

If I run nuget sources :

nuget sources
Registered Sources:

  1.  https://www.nuget.org/api/v2/ [Enabled]
      https://www.nuget.org/api/v2/

but if you redirect it into e.g. a file, the command will start to print newlines in an infinite cycle :

nuget sources > test.log

Bitrise of course have to redirect the standard output to be able to collect your build’s logs, so the same issue happens there.

@mleatherb Did you try to run the same command locally, on your Mac? (nuget sources add ...)

A quickfix script, which downloads a newer NuGet version, and runs the sources command with that version:

#!/bin/bash
# fail if any commands fails
set -e
# debug log
set -x

# download url from: https://dist.nuget.org/index.html
nuget_download_url='https://dist.nuget.org/win-x86-commandline/v3.4.4/NuGet.exe'
# a local path where NuGet.exe will be stored
nuget_local_path='/tmp/NuGet.exe'
# mono's path
mono_path='/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono'

# download NuGet.exe
wget -q -O "${nuget_local_path}" "${nuget_download_url}"

# run through mono
${mono_path} ${nuget_local_path}

# e.g. to run "nuget sources":
${mono_path} ${nuget_local_path} sources

# add source example
${mono_path} ${nuget_local_path} sources add -Name CompanyName -Source companyname.visualstudio.com

This configuration does not overwrite the NuGet version used by Xamarin, so it should be “safe” as the newer NuGet version will only be used in this Script step.

Can you please try this @mleatherb and let us know how it goes?

Yes, I got an error about the name. I think I resolved that issue and I’m running a build right now

1 Like

I was able to solve it. It was an issue with the naming of the feed I was connecting to.

1 Like

Glad to hear that, Happy Building! :wink:

So I got it partially working. The source adds successfully, but now restore is failing saying it can’t find the packages.
I’ve checked the feed and the packages are in fact there. Local restore works fine and finds the packages. Can’t really see what error is getting kicked back when trying to restore those specific packages.

I think I have an idea of what is happening. It looks like the restore step is not restoring the package from the added feed in the step prior, but from the main nuget feed. I was able to sorta get around it. Now it tries to download all the packages from both feeds. Is this an issue with the step or nuget?

Hi @mleatherb,

nuget restore should print the used Feeds, something like this:

Feeds used:
/Users/vagrant/.nuget/packages/
https://www.nuget.org/api/v2/ 

which Feeds presents in your Nuget Restore step’s log?

Does your project contain nuget.config files? If yes, could you please share the relevant (which is in your repo root, or in the project’s dir, which you want to build) one?

1 Like