none
VS2015 NuGet still looks at packages.config even if exclude from project?

    Question

  • Q1: One of the our modified project has a packages.config file in its directory. When we 'exclude from project' the packages.config, it still grabs the package. I guess my expectation from VS2015 IDE is it would integrate with NuGet and not download the package. Or does NuGet simply ignore exclude setting from VS?

    Q2: To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.' However I need a fast way to easily allow NuGet to download missing packages or not for some projects (on a project level); what is a simple way (without having to delete the packages.config and recreate each time)?

    Monday, August 22, 2016 5:00 PM

Answers

  • Hi J_msdn,

    >> Q1

    I get the same result when I exclude the packages.config from my project. The project should restore the packages that installed based on the packages.config file no matter it include in project or not. As long as this file stored in project folder, the project will restore the packages that listed in this file. If you  don't want restore the packages, I'm afraid that you need to delete the packages.config file from the project folder.

    >> Q2

    If you want to restore the packages for assigned project, please try with following steps.

    1. Uncheck 'Allow NuGet to download missing packages during build.'
    2. Open Package Manager Console window.
    3. Type command "Update-Package -Project YourProjectName"

    Above steps could help us restore the packages based on the project that you assigned in command.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 23, 2016 9:06 AM
    Moderator
  • Hi J_msdn,

    >> Does that sound about right?

    First you need to Uncheck 'Allow NuGet to download missing packages'. If you check this option in Visual Studio settings, when your build your solution, it will restore all packages for all projects under the solution. Then you can custom a pre-build or create a custom script to remove/restore packages based on the packages.config file in every project.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by J_msdn Wednesday, August 24, 2016 3:24 PM
    Wednesday, August 24, 2016 5:33 AM
    Moderator

All replies

  • Hi J_msdn,

    >> Q1

    I get the same result when I exclude the packages.config from my project. The project should restore the packages that installed based on the packages.config file no matter it include in project or not. As long as this file stored in project folder, the project will restore the packages that listed in this file. If you  don't want restore the packages, I'm afraid that you need to delete the packages.config file from the project folder.

    >> Q2

    If you want to restore the packages for assigned project, please try with following steps.

    1. Uncheck 'Allow NuGet to download missing packages during build.'
    2. Open Package Manager Console window.
    3. Type command "Update-Package -Project YourProjectName"

    Above steps could help us restore the packages based on the project that you assigned in command.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 23, 2016 9:06 AM
    Moderator
  • Thanks Weiwei. Just so I get this right as I am new at this and I am starting to read docs.nuget.org and its FAQ to learn more, my example scenario:
    I have a solution X it has project A,B,C,D,E,F,G,H. For solution X I want to allow NuGet to download missing packages for A,B,E,F,H only.
    I also have a sln Y it has project A,B,C,D,E,F,I,J,K,L. For soln Y I want to allow NuGet to download missing packages for A,C,E,I only.
     
    First 'Allow NuGet to download missing packages'. Then one way to do this is customize a pre-build/script to remove or restore packages.config respectively for the affected projects (depending if I want to disallow or allow downloading for particular project). Does that sound about right?
    Tuesday, August 23, 2016 6:56 PM
  • Hi J_msdn,

    >> Does that sound about right?

    First you need to Uncheck 'Allow NuGet to download missing packages'. If you check this option in Visual Studio settings, when your build your solution, it will restore all packages for all projects under the solution. Then you can custom a pre-build or create a custom script to remove/restore packages based on the packages.config file in every project.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by J_msdn Wednesday, August 24, 2016 3:24 PM
    Wednesday, August 24, 2016 5:33 AM
    Moderator