DEV Community

Kamu
Kamu

Posted on

How to use a private NuGet server (feed) on App Center

I would want to make private NuGet packages referred, and I surveyed it. I wrote down the result here in case I forgot.

Repository

https://github.com/muak/AppCenterPrivateNugetSample

Entire the repository isn't concerned with this article so much, but I hope this will help you with how to write Nuget.config.

Procedures

  1. By some means, arrange a server in order to put your private Nuget package.
    • Buy a MyGet license.
    • Use VSTS private feed.
    • Using VPS or cloud service, construct a server by myself.
  2. Put a Nuget.config file in the same folder as .sln.
  3. Setting environment variables on App Center.

1. Nuget server

It is OK to skip over this section.

First of all, I tried to use MyGet. But I gave up it because of using private feed in MyGet is not free.

Secondly, I tried to construct a nuget server using nuget.service package. But I gave up it because it did not correspond to ASP.NET core.

Then, I searched "nuget linux" with Google and hit the following site.

https://github.com/Daniel15/simple-nuget-server

And I found the docker image which corresponds to this.

https://github.com/rolfwessels/docker-simple-nuget-server

I tried to use it.

But it didn't work well. So I forked those projects and did trial and error.
The result is the following links.
Though I registered docker hub and that is available, it is just a suggestion because I hardly know docker knowledge.

https://hub.docker.com/r/kamu/docker-simple-nuget-server/

https://github.com/muak/simple-nuget-server
https://github.com/muak/docker-simple-nuget-server

2. Nuget.config

Create a Nuget.config file in the same folder as .sln and write as the following code.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget" value="https://www.nuget.org/api/v2" />
    <add key="MyNuget" value="https://mynuget.com" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSourceCredentials>
    <MyNuget>
      <add key="Username" value="%private_nuget_user%" />
      <add key="ClearTextPassword" value="%private_nuget_pass%" />
    </MyNuget>
  </packageSourceCredentials>
</configuration>
Enter fullscreen mode Exit fullscreen mode

https://intercom.help/appcenter/build/how-to-restore-a-private-nuget-feed

Though I referred from this, I changed default feed URL to VS for Mac default URL because it didn't work for some reason.

Add a private nuget server key-value (name / URL) to packageSources, and add the same name item as added key to packageSourceCredentials. and add user and password item there.
Parts of between % are environment variables which are set in AppCenter. Not to mention, they can be written directly there too.

3. Settings on App Center

All you have to do is register environment variables corresponding to the Nuget.config on App Center.

If build success, the following log will begin to be output soon.

But if any settings were made mistake, the following error messages will be displayed and it will take a long time to build.

"Unable to load the service index for source…"
"Package 'something' is not found on source…"

If these messages were shown, you should cancel the build since it will be failed.

Top comments (2)

Collapse
 
unreachablecode profile image
Charlie Finlayson

Does this mean my project is no longer using the PackageReference feature of .NET Standard? Or are they both used in tandem to reference packages?

Collapse
 
muak_x profile image
Kamu

It hasn't an effect on the PackageReference feature.
This article describes how to the referenced NuGet server is added.