none
How to add a nuget package dependency to a vs nuget package? RRS feed

  • Question

  • Hello Everyone!

    I have very simple question.

    I am developing a nuget package using Visual Studio 2013 and C#. I want to add Bootstrap and JQuery as a dependency. How to I do that?

    Thanks,

    Hakan

    Thursday, April 9, 2015 11:05 AM

Answers

  • Hello Eric,

    Thank you for your answer. I see that you are trying to help. But I am trying to achieve my goal :) Since begining I knew that difference between vs packages and nuget packages. I have already a couple of nuget packages at gallery.

    Anyway, I found a solution for this right inside nuget.org. I will try it when I will have time.

    //ID of the package to be looked up
    string packageID = "EntityFramework";
    		
    //Connect to the official package repository
    IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
    
    //Initialize the package manager
    string path = <PATH_TO_WHERE_THE_PACKAGES_SHOULD_BE_INSTALLED>
    PackageManager packageManager = new PackageManager(repo, path);
            
    //Download and unzip the package
    packageManager.InstallPackage(packageID, SemanticVersion.Parse("5.0.0"));

    Link is: http://blog.nuget.org/20130520/Play-with-packages.html

    I will write results.

    Hakan

    Monday, April 13, 2015 7:15 AM

All replies

  • The Nuspec Reference contain information on creating the package files.  Specifically: http://docs.nuget.org/create/nuspec-reference#specifying-dependencies

    Eric

    • Proposed as answer by EWoodruff Thursday, April 9, 2015 4:22 PM
    Thursday, April 9, 2015 4:22 PM
  • Thank you for your answer.

    But how am I going to debug the project in this case? And I dont see a .nuspec file in Visual studio. Also If you are familiar with Visual studio package development, you would know that there is a file "source.extension.vsixmanifest". There we can specify dependencies. It was actually what I am asking.

    Friday, April 10, 2015 7:52 AM
  • If you found the solution, please share it here so other users can benefit out of it.

    Thank you.


    Fouad Roumieh

    Friday, April 10, 2015 8:18 AM
  • Visual Studio packages are not NuGet packages.  The dependencies defined in source.extension.vsixmanifest are references to other Visual Studio packages, not NuGet packages.  The two are completely different.

    Just taking a guess here but if you're developing a Visual Studio package to deploy a project template, my assumption would be that you'd add the NuGet packages to your project template and make sure the packages.config file is included as part of that project file set.  When a new project is created from the template, Visual Studio should download and install the NuGet packages automatically if package restore is enabled when the new project is built.

    Eric

    Friday, April 10, 2015 4:57 PM
  • Hello Eric,

    Thank you for your answer. I see that you are trying to help. But I am trying to achieve my goal :) Since begining I knew that difference between vs packages and nuget packages. I have already a couple of nuget packages at gallery.

    Anyway, I found a solution for this right inside nuget.org. I will try it when I will have time.

    //ID of the package to be looked up
    string packageID = "EntityFramework";
    		
    //Connect to the official package repository
    IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
    
    //Initialize the package manager
    string path = <PATH_TO_WHERE_THE_PACKAGES_SHOULD_BE_INSTALLED>
    PackageManager packageManager = new PackageManager(repo, path);
            
    //Download and unzip the package
    packageManager.InstallPackage(packageID, SemanticVersion.Parse("5.0.0"));

    Link is: http://blog.nuget.org/20130520/Play-with-packages.html

    I will write results.

    Hakan

    Monday, April 13, 2015 7:15 AM
  • Hi Hakan,

    We can add the dependencies as dependency tag in .nuspec file. It can automatically resolves the nugets from nuget.org.

    <dependencies>
          <dependency id="bootstrap"/>
          <dependency id="jQuery"/>
    </dependencies>



    - Abbas K

    Monday, April 13, 2015 7:31 AM