If you use an internal NuGet server or just want to be explicit on the sources to use to restore package, you need to set the source in the NuGet configuration. You can use the
dotnet nuget command to manage sources:
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org dotnet nuget add source https://azureartifacts.microsoft.com/myTeam --name myTeam --username user --password pass
However, this means that every developer needs to set the source on their machine. Also, you need to configure sources on the CI machine.
Instead, you can set the configuration for your project directly in the csproj file using the
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-unstable1129" /> </ItemGroup> </Project>
If you need a more advanced NuGet configuration, you still need to use a
nuget.config file in your repository.
Do you have a question or a suggestion about this post? Contact me!