I accidentally missed to upload to source control NuGet packages.config file and it got deleted somehow:(
Is there any way to recreate it?
An easier way will be just go to Nuget and reinstall the packages. It will create the package.config file
It's kind of tricky to do it in an automated way. Easiest is to simply re-create the packages.config
manually, added entries for each directory in the packages
dir. For example, I have the following dirs in my packages directory:
Microsoft.Bcl.1.1.3
Microsoft.Bcl.Async.1.0.16
Microsoft.Net.Http.2.2.15
Newtonsoft.Json.5.0.8
repositories.config
WindowsAzure.MobileServices.1.0.2
WPtoolkit.4.2013.08.16
If I were to re-create the packages.config, I could simply take the directory name, separate the version number and create a line for each package like:
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="wp71" />
adding the targetFramework
attribute to whatever target that project was using.
Then wrap all of those <package>
elements with
<?xml version="1.0" encoding="utf-8"?>
<packages>
<!--...-->
</packages>
Resulting in something like this:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="wp71" />
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="wp71" />
<package id="Microsoft.Net.Http" version="2.2.15" targetFramework="wp71" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="wp71" />
<package id="WindowsAzure.MobileServices" version="1.0.2" targetFramework="wp71" />
<package id="WPtoolkit" version="4.2013.08.16" targetFramework="wp71" />
</packages>
Why not use the console-manager?
For restoring you van both use the NuGet package manager as the console.
Restore packages using Package Restore
Some things only work with the console??(?correct?)
Micrsoft Docs: How to reinstall and update packages
Ref.: Why, when and how to reinstall NuGet packages after upgrading a project
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.