11

I have a library that comes from a private nuget feed. I have the url and credentials for that but dont know how to connect to the feed properly with visual studio code. I am using dotnetcore framework.

I created a Nuget.Config file in the root of my console application with the feed url and username and password but this didn't seem to pick up the packages from that feed when imputting them in the project.json. Even doing a restore would produce errors.

Does anyone have an example of how they would set up a project to do this? I know it is not normal to have the Nuget.Config file in the project but this is a test project so would not live there once the project got past proof of concept.

My nuget.config looked like this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="CustomRepo" value="https://nuget.feed/nuget/" />
    </packageSources>

    <!-- Used to store credentials -->
    <packageSourceCredentials>
        <CustomRepo>
            <add key="Username" value="something" />
            <add key="ClearTextPassword" value="thepassword" />
        </CustomRepo>
    </packageSourceCredentials>

      <!-- Used to disable package sources  -->
    <disabledPackageSources />
</configuration>
Matt
  • 487
  • 1
  • 6
  • 16
  • Where is the solution file in relation to the NuGet.Config file? – Matt Ward Feb 15 '17 at 18:20
  • I dont have a solution file for this. Just rolling with the project.json file that dotnetcore supports. – Matt Feb 15 '17 at 19:50
  • Possible duplicate of [Add custom package source to Visual Studio Code](https://stackoverflow.com/questions/41358490/add-custom-package-source-to-visual-studio-code) – Tomino Jun 08 '17 at 10:10
  • For anyone wondering why the credentials have to be in clear text (which defeats the whole purpose of having credentials in the first place, since this config file will also go into source control). **This is an open issue in dotnet / nuget cli.** Ref github issue # [5909](https://github.com/NuGet/Home/issues/5909) & [1851](https://github.com/NuGet/Home/issues/1851) – Naren Apr 30 '20 at 16:51

1 Answers1

1

Apoligies this is now resolved and working with the nuget.config file in the root folder. I dont know what I did. Only thing I did was re-type the whole xml but dont know what what would have done. Anyway it is working which is great.

Matt
  • 487
  • 1
  • 6
  • 16