Use a .nuspec file/script to automatically install nuget packages into a new project

前端 未结 2 1369
长情又很酷
长情又很酷 2021-01-26 13:47

I am trying to automate the process of installing nuget packages into new visual studio projects. My idea is to reduce the time it takes to source all the packages via the nuget

2条回答
  •  遥遥无期
    2021-01-26 14:42

    Nuget already supports automation of installation and we can use nuget commandline to achieve this

    Everytime you add a nuget package in Visual Studio,it gets add to a file called packages.config file.

    E.g. will look like this

    
    
        
      
      
      
      
       
      
    
    

    Every project you have in your solution will have packages.config file. You can go to the parent folder of all the projects and simply run comand 'nuget restore', it will get all the packages for you.

    For this to work, nuget.exe needs to be downloaded separately .More details on the nuget command line can be found here and here's the commandline reference

    Edit:

    Thanks @Martin Ullrich pointing out.Just to be clear, The above method will not add the references to project file automatically,it will only get the packages to the packages folder.In VS2017,the support is there which @Martin's answer addresses.

    Hope this helps!

提交回复
热议问题