Reputation:
If I want to keep backups of my code and I don't want all the libraries and nuget libraries in the backup, how do I do that?
I run clean on my solution and I noticed there are still DLL's and EXE in the bin and obj folders. Ok, I can delete those folders manually. I can delete the package folder which will remove all the nuget libraries, but if I ever want to restore, will my solution redownload all the nuget packages needed for the project? I'm afraid to test that theory and from what I read there is meta data and other things in the package folder will will cause me problems. If I zip what I have after deleting bin and obj folder, the zip is 450MB. If I go into the zip and delete the package folder, I see it is only 25MB. It seems to be all in the Package folder. From an ReactJS perspective, I can do a build and it cleans all this out and when I want to reimport for an existing project, I run a install. Is there not something like this for Visual Studio 2017? Will I be able to recover easily if I just delete the package folder before I back it up?
Upvotes: 1
Views: 4152
Reputation: 261
Why not just use some source control to do just that?
If you use Team Foundation Server with TFVC or Git it will do just that. You will have all your code under version control, without dll´s, bins, build artifacts, packages or anything. Without all those heavy, innecesary things that can be recreated by just rebuilding the solution again.
And of course you will enjoy all the advantages of having your code under source control: namely, not only having a backup of your code, but of all changes it has undergone with thus far.
Just saying.
Upvotes: 0
Reputation: 28116
If I want to keep backups of my code and I don't want all the libraries and nuget libraries in the backup, how do I do that?
Which way do you backup the code? According to your description, it seems you're trying to zip the solution and store it somewhere to do the backup. If so, you can delete the bin, obj and packages
folders before you zip the solution. (You can even delete the .vs folder)
Is there not something like this for Visual Studio 2017? Will I be able to recover easily if I just delete the package folder before I back it up?
There're two ways to manage nuget packages in VS, packages.config and PackageReference format. Since you have packages folder in your solution, I think you use packages.config
format. The info about nuget packages your project consume are defined in packages.config and xx.csproj file. After you delete the packages folder, you can easily recover the packages with the help of the packages.config file and xx.csproj file.
Import the solution which you've deleted bin, obj, packages
folders in VS, right-click the solution in Solution Explorer
and choose Restore nuget packages
option, then it will help install the packages your solution need according to your packages.config
file. So the answer is Yes for Will I be able to recover easily
.
In addition:
1.When you install one nuget package, it will firstly install it in global-packages folder, and then copy them to your solution. So in same machine, if you zip the solution before delete the packages folder in solution. When you recover, it will first look for the cache, if the cache doesn't have the required nuget packages, it will install them from package source.(like nuget.org). You need to enable these two options in VS setting.
2.If you're using PackageReference format, the packages are stored in %userprofile%\.nuget\packages
but not in your solution. And you can easily recover the packages though you zip the solution and copy it to remote server.
3.Apart from the restore nuget packages
option in VS, you can also use command-line like nuget.exe, msbuild.exe... More details see here.
Upvotes: 1