Reputation: 3892
Normally, we get our Nuget.config from users\[loggedinuser\AppData\Roaming\Nuget
but we have a case where a specific project where we need a use a different project specific config file. Where do I place the config file in this case?
I am using .net core SDK 1.0.4 and .net code.
The build script does this:
cd src\SFMC.Adapter.Service
dotnet restore
dotnet build
Can I pass an argument into dotnet restore
to indicate the location of the config?
Upvotes: 7
Views: 22172
Reputation: 161
I know it is a rather old post, but I was struggling with it as well and had a hard time finding the correct documentation. I eventually found that you can execute the command below to add a new nuget config to the location where you are.
dotnet new nugetconfig
This will use the dotnet cli to use the nugetconfig template (that appeared to be installed by default) to generate a correct file
Upvotes: 12
Reputation: 118937
From the Nuget docs:
Project-specific
NuGet.Config
files located in any folder from the solution folder up to the drive root. These allow control over settings as they apply to a project or a group of projects.
So you can put a Nuget config file alongside the project file to give that project a specific configuration.
Upvotes: 6
Reputation: 15203
Assuming your project structure looks like:
Project/
└── src
├── SFMC.Adapter.Client
├── SFMC.Adapter.Service
│ ├── Program.cs
│ └── Project.csproj
└── SFMC.Adapter.Service.Test
You can add a Nuget file anywhere within the project tree. Where you place it will affect which projects see it by default. dotnet restore
will search for all Nuget.config
files up the directory tree to add any sources it finds.
If you place it next to Service.cs
, it will only be picked up by SFMC.Adapter.Service
. If you place it under src
it will be picked up and used by SFMC.Adapter.Service
, SFMC.Adapater.Service.Test
and SFMC.Adapter.Client
.
See NuGet configuration docs for more details.
Upvotes: 14