Google Cloud build and private Nuget repository

Viewed 355

I have a private NuGet repository created with BaGet. My software is hosted in Google Cloud where there is also the Git repository with my code. I have some Cloud build triggers that run the build in the cloud and automatically deploy the applications. I have created some NuGet package with my projects and now I need to change the reference from code (project reference) to NuGet package reference in my private repository. Locally all works, but now I need to do the same in my Google Cloud build trigger and I don't know where I can specify the reference to my private repository. My build script is a yaml file but inside I don't have a reference to the standard NuGet repository and I don't know how I can specify an additional NuGet package repository for some libraries.

1 Answers

NuGet reads configuration from nuget.config files. In fact, it reads from multiple config files. So you can commit a nuget.config to your source code repository, and therefore anyone else who clones your repo (even a CI agent) doesn't need to be configured, it "Just Works".

The part of the config that's relevant to your question is the <packageSources> section, so a minimal config with only package sources defined is:

<configuration>
  <packageSources>
    <!-- make sure other nuget.config files don't add unexpected sources -->
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="private" value="https://my-server/index.json" />
  </packageSources>
</configuration>
Related