1

I am wondering how to specify the nuget local server for single solution i don't want to add this on the visual studio level. So when we push the code to bitbucket and wants bamboo to use that source for nuget, which we want to specify somewhere in the solution.

Nuget local source

The above link i think proposing some solution to my problem. But I have tried the NuGet.config file but it is still using the default nuget source. And i am not sure where to put that NuGet.targets file.

May be i might be wrong some where. Can please someone guide me? Is it possible or not. and what should i do. Thanks.

Community
  • 1
  • 1

1 Answers1

1

You can specify NuGet sources in the NuGet.Config file. This file is part of the solution and the configuration is also used on your build server so it does not depend on whatever settings you have in Visual Studio.

First step is to enable NuGet package restore (which you probably already have). Right-click on the solution in Solution Explorer and select Enable NuGet Package Restore. This will add a .nuget folder in the solution and in this folder you will find the file NuGet.Config.

NuGet solution folder

Then you need to modify the NuGet.Config file by adding your local NuGet repository:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
    <add key="Local package source" value="http://server/NuGet.Server/nuget/" />
  </packageSources>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
</configuration>

You need to adjust the value attribute of the local package source to point to your local NuGet server.

Martin Liversage
  • 104,481
  • 22
  • 209
  • 256
  • What is the difference between to provide packagesources in NuGet.Config and Nuget.targets? – Ali Raza Iftikhar Jul 02 '15 at 07:13
  • You are not supposed to modify `NuGet.targets`. It contains the msbuild "source code". The `NuGet.config` contains the configuration values that you modify. – Martin Liversage Jul 02 '15 at 07:18
  • Okay so what is happening when i change sources in NuGet.targets then it works fine but when i specify it in the NuGet.Config and i build my solution it doesn't work as expected. – Ali Raza Iftikhar Jul 02 '15 at 07:33
  • @Davidrocky: You build system executes NuGet.exe and you need to ensure that it uses the correct configuration. You can try to turn on logging in your build system and also verify that there is no local configuration override on your build system. – Martin Liversage Jul 02 '15 at 08:01