Home > database >  Search disk C: or D: in Nuget.Config
Search disk C: or D: in Nuget.Config

Time:11-04

I have a following Nuget.Config file in which I specify path to nuget packages:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="SomeKey" value="D:\...\somePath" />
    </packageSources>
</configuration>

However this configuration targets disk D: directly and I would like to target disk C: or disk D:. Or if it does not find such on disk C: it would search for it on disk D:. I could not find such solution in documentation and truth be told I have never stumbled upon such solution in any path configuration in any language or framework. But it would be quite handy one. Thank you in advance

CodePudding user response:

You could simply add two package sources, one for each drive:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="SomeKey" value="D:\...\somePath" />
        <add key="SomeOtherKey" value="C:\...\somePath" />
    </packageSources>
</configuration>

Then in the NuGet package manager, you can either choose to search "All" (i.e. NuGet, SomeKey, and SomeOtherKey), or choose a specific one to search:

enter image description here

  • Related