# Private nuget repo script

**URL:** <https://discuss.bitrise.io/t/private-nuget-repo-script/437>\
**Category:** Builds\
**Tags:** step\
**Created:** [January 25, 2017, 5:44pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437 "2017-01-25T17:44:46Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 25, 2017, 5:44pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/1 "2017-01-25T17:44:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 5:46pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/2 "2017-01-25T17:46:39Z")

</div>

What was the script you added?

---

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 25, 2017, 6:06pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/3 "2017-01-25T18:06:45Z")

</div>

```
#!/bin/bash
set -ex

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

```

I also tried with the username/password arguments

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 6:54pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/4 "2017-01-25T18:54:51Z")

</div>

@godreikrisztian do you have an idea?

---

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 25, 2017, 7:56pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/5 "2017-01-25T19:56:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 7:57pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/6 "2017-01-25T19:57:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 7:59pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/7 "2017-01-25T19:59:48Z")

</div>

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

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

```auto
                             \n ...

```

Repeated in an infinite loop.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 8:31pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/10 "2017-01-25T20:31:13Z")

</div>

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](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:

```auto
NuGet Version: 2.12.0.0

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

```

If I run `nuget sources` :

```auto
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** :

```auto
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.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 8:51pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/11 "2017-01-25T20:51:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 9:13pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/12 "2017-01-25T21:13:30Z")

</div>

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

```auto
#!/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?

---

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 25, 2017, 9:25pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/13 "2017-01-25T21:25:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 25, 2017, 9:45pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/14 "2017-01-25T21:45:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 25, 2017, 9:51pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/15 "2017-01-25T21:51:27Z")

</div>

Glad to hear that, Happy Building! 😉

---

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 26, 2017, 2:37am UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/16 "2017-01-26T02:37:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mleatherb](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mleatherb](https://discuss.bitrise.io/u/mleatherb)\
**Post date:** [January 26, 2017, 12:12pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/17 "2017-01-26T12:12:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![godreikrisztian](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/godreikrisztian/32/22_2.png) [@godreikrisztian](https://discuss.bitrise.io/u/godreikrisztian)\
**Post date:** [January 26, 2017, 1:31pm UTC](https://discuss.bitrise.io/t/private-nuget-repo-script/437/18 "2017-01-26T13:31:38Z")

</div>

Hi @mleatherb,

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

```auto
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?
