Package Restore via msbuild not pulling package sources from Nuget.Config

Jan 20, 2012 at 5:24 PM

I figured out how to add package sources to the Nuget.Config by looking at the source code https://gist.github.com/1643659

When I test my package source config via the command line in the .nuget directory everything looks great: nuget sources

When building via visual studio or via msbuild on the command line I am getting errors that my local packages cannot be found.

Should package restore (nuget install via msbuild) be honoring the Nuget.Config local to Nuget.exe?

 

 

Jan 20, 2012 at 5:28 PM
I know that it honors what is in the nuget.targets file that is by the nuget.exe within the .nuget folder.

 <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
        <PackageSources>http://www.myget.org/F/somecustomfeed/</PackageSources>
____
Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder


On Fri, Jan 20, 2012 at 12:24 PM, KevM <notifications@codeplex.com> wrote:

From: KevM

I figured out how to add package sources to the Nuget.Config by looking at the source code https://gist.github.com/1643659

When I test my package source config via the command line in the .nuget directory everything looks great: nuget sources

When building via visual studio or via msbuild on the command line I am getting errors that my local packages cannot be found.

Should package restore (nuget install via msbuild) be honoring the Nuget.Config local to Nuget.exe?

Read the full discussion online.

To add a post to this discussion, reply to this email (nuget@discussions.codeplex.com)

To start a new discussion for this project, email nuget@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jan 20, 2012 at 5:32 PM
The other location should likely also work, but may be a bug or something that is not intended for package restore at this time.
Jan 20, 2012 at 5:35 PM

Thanks that helped it is honoring my local package source.

Sadly now it does not find the official Nuget package source now.

Jan 20, 2012 at 5:39 PM

What package sources are you setting in your nuget.config? It now only searches among those.

Jan 20, 2012 at 5:42 PM
Add it at the end with a ";" in between the sources. Or try commas if that doesn't work.

Jan 20, 2012 at 5:47 PM

Here is my Nuget.Config whose package sources are not honored by msbuild or VS

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageSources>
    <add key="nuget" value="http://go.microsoft.com/fwlink/?LinkID=206669" />
    <add key="dovetail_sdk" value="c:\Program Files\Dovetail Software\fcSDK" />
  </packageSources>
</configuration>

This works when CWD is the same as nuget.exe but not from msbuild or VS. Out of curiousity is this a bug? Is the intent of Nuget.Config being "shipped" when Package Restore is turned on that it is a place for these changes?

Here is how my sources look when CWD is the same as Nuget.exe:

kmiller@KEVIN /c/projects/bt/source/.nuget (master)
$ nuget sources
Registered Sources:

  1.  nuget [Enabled]
      http://go.microsoft.com/fwlink/?LinkID=206669
  2.  dovetail_sdk [Enabled]
      c:\Program Files\Dovetail Software\fcSDK

I followed Rob's suggestion and got half way there with this change to my Nuget.targets file: 

<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<PackageSources>"c:\Program Files\Dovetail Software\fcSDK"</PackageSources>

This works for my local packages but cannot find the public (official) nuget sourced packages. I cannot figure out how to define multiple sources with the <PackageSources> in Nuget.targets

Kevin

Jan 20, 2012 at 5:51 PM
Edited Jan 20, 2012 at 5:51 PM

Commas do not work. 

Thankfully, semicolons do. So I have something up and going.

<PackageSources>"c:\Program Files\Dovetail Software\fcSDK";"http://go.microsoft.com/fwlink/?LinkID=206669"</PackageSources>

So where we ended up is the question...

What is the intent of Nuget.Config? Should the .nuget/Nuget.Config settings be pulled in by the msbuild task?

Jan 20, 2012 at 5:53 PM

The fact that .nuget\nuget.config settings is not pulled in by msbuild task maybe a bug. I'll investigate. Thanks for reporting.

Jan 20, 2012 at 5:54 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.