How can I call nuget restore recursively when using packages.config?

Viewed 428

I have a non-.NET-based project that I'm trying to hammer nuget into for managing the dependencies. Because of that, I have to use packages.config to define the dependencies for a project.

Right now, I've got it packing and pushing exactly as I want it, but when I restore the packages, it only restores the dependencies in the packages.config I list, none of the dependencies of that package. So, for instance, if I have an application, MyApp, with a dependency on Foo, which then has a dependency on Bar, calling nuget restore on MyApp will not put Bar into the packages folder.

According to the CLI documentation, the -Recursive flag does not work for projects using packages.config - which is a problem for me, as I need to use packages.config, as far as I can tell. Or at least, I don't really want to spend another 3 hours converting all 12 of my packages to use a different format if I can help it.

For reference, here's an example of what my files look like, currently:

MyApp's package.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="Foo" version="1.0.0.0" allowedVersions="[1.0]" />
</packages>

Foo.nuspec

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <!-- Required elements-->
        <id>Foo</id>
        <version>1.0</version>
        <description>Foo</description>
        <authors>Tesset</authors>
        <dependencies>
            <dependency id="Bar" version="[1.0]" />
        </dependencies>
    </metadata>
    <files>
        <file src=".\lib\Foo\**" target="lib\Foo" />
    </files>
</package>

Bar.nuspec

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <!-- Required elements-->
        <id>Bar</id>
        <version>1.0</version>
        <description>Bar</description>
        <authors>Tesset</authors>
    </metadata>
    <files>
        <file src=".\lib\Bar\**" target="lib\Bar" />
    </files>
</package>

And, for completeness, I'm calling nuget restore like:

nuget restore ".\MyApp\packages.config" -PackageSaveMode nuspec -OutputDirectory ".\MyApp\packages" -recursive

(Having or not having the -recursive flag makes no difference to whether Bar ends up in the packages folder)

So, is there a way in nuget to make sure Bar gets restored while leaving MyApp (and Foo) using a packages.config file? If not, then is there a way to restore the dependencies listed in the nuspec file, so I can do that recursion manually on the files nuget restore puts into .\MyApp\packages?

0 Answers
Related