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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With