Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 2.7 KB

use-custom-nuget-feed.md

File metadata and controls

64 lines (51 loc) · 2.7 KB
title titleSuffix services ms.service ms.component author ms.author ms.date ms.topic description keywords manager
How to use a custom NuGet feed in Azure Dev Spaces | Microsoft Docs
Azure Dev Spaces
azure-dev-spaces
azure-dev-spaces
azds-kubernetes
johnsta
johnsta
05/11/2018
article
Use a custom NuGet feed to access and use NuGet packages in an Azure Dev Space.
Docker, Kubernetes, Azure, AKS, Azure Container Service, containers
ghogen

Use a custom NuGet feed in an Azure Dev Space

A NuGet feed provides a convenient way to include package sources in a project. Azure Dev Spaces will need to be able to access this feed in order for dependencies to be properly installed in the Docker container.

Set up a NuGet feed

To set up a NuGet feed:

  1. Add a package reference in the *.csproj file under the PackageReference node.

    <ItemGroup>
        <!-- ... -->
        <PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0" />
        <!-- ... -->
    </ItemGroup>
  2. Create a NuGet.Config file in the project folder.

    • Use the packageSources section to reference your NuGet feed location. Important: The NuGet feed must be publicly accessible.
    • Use the packageSourceCredentials section to configure username and password credentials.
    <packageSources>
        <add key="Contoso" value="https://contoso.com/packages/" />
    </packageSources>
    
    <packageSourceCredentials>
        <Contoso>
            <add key="Username" value="[email protected]" />
            <add key="ClearTextPassword" value="33f!!lloppa" />
        </Contoso>
    </packageSourceCredentials>
  3. If you're using source code control:

    • Reference NuGet.Config in your .gitignore file so you don't accidentally commit credentials to your source repository.

    • Open the azds.yaml file in your project, and locate the build section, and insert the following snippet to ensure that the NuGet.Config file will be synced to Azure so that it used during the container image build process. (By default, Azure Dev Spaces does not synchronize files that match .gitignore and .dockerignore rules.)

      build:
      useGitIgnore: true
      ignore:
      - “!NuGet.Config”

Next steps

Once you have completed the above steps, the next time you run azds up (or hit F5 in VSCode or Visual Studio), Azure Dev Spaces will synchronize the NuGet.Config file to Azure, which is then utilized by dotnet restore to install package dependencies in the container.