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 |
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.
To set up a NuGet feed:
-
Add a package reference in the
*.csproj
file under thePackageReference
node.<ItemGroup> <!-- ... --> <PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0" /> <!-- ... --> </ItemGroup>
-
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>
- Use the
-
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 thebuild
section, and insert the following snippet to ensure that theNuGet.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”
-
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.