Can I change Nuget package place? - nuget

When I Enable nuget package restore, the nuget folder always in the diretory which the .sln file in.
but what I want to achieve is:
nuget folder in mysolution sub folder, How can I do that?

The nuget folder location is hard coded as $(solutionDir)\.nuget. There is no way to change it.

Related

How to update / reinstall executable stored in NuGet

I would like to use NuGet to avoid adding a 3rd party executable to git repository.
I have a NuGet package with executable published to our NuGet source. Package contents:
content\SetupFiles\bigexecutable.exe
I've added the NuGet reference to the project in which I want to use the executable. It properly adds the
SetupFiles\bigexecutable.exe
to the project directory during the NuGet package installation. But if I delete the file from the project directory it is not replaced during the build.
Is it possible that NuGet would verify if the package contents are present before the build and reinstalled the package if something is missing?
Your .exe is being added to the project since you are including it in the Content directory. NuGet will not restore items into the project. It will only restore items into the packages directory.
An alternative would be to create a tools NuGet package where the .exe is not added to the project but is available in a tools directory relative to the solution's directory.
The NUnit.ConsoleRunner is one example of such a NuGet package where it has all its .exe files in the tools directory. Using the tools directory does not cause NuGet to add any files to your project.

Install nuget package without content folder

I need to install a nuget package in my csproj and I would like to prevent the installation of all files contained in the "content" folder of the nuget package.
Is there any way to do it?
Yes, there is a way to do this. If you use project.json way of managing nuget dependencies, we do not modify your project, irrespective of the content in the content folder.

copy Nuget packages with my project in UWP

I have a UWP Project with some nuget packages installed, NuGet now downloads and stores a copy of the packages in a global packages folder located in my %userprofile%\.nuget\packages folder. I want to move My project into another computer, How Can I move it with packages this project needs to? I don't want to search in that folder and find the desired packages and move them too, I want the packages stick in my project
You basically don't need to do anything. As you have figured out, Nuget stores a local copy of those packages in your project, so if you open that up on a different computer, all you have to is to right-click the solution and choose "Restore NuGet Packages" to have those loaded. It will then create a global cache of packages for you.
Or are you asking how to disable the global package cache?

Create NuGet solution-level package to copy some files

I have a simple task, I want to install a nuget package to a solution and have it copy files to the folder structure but I don't want to modify the solution or projects in any signifcant way.
Currently I have a solution-level package but I can't seem to get it to copy any files anywhere. All it does currently is add a reference to .nuget\packages.config and a pointer in the solution file. This is fine, I just need it to copy files as well, the <Files> element doesn't seem to be doing it.
Solution-level packages have been deprecated as of NuGet 3 last October.
https://github.com/NuGet/Home/issues/522#issuecomment-98845250

Should config files added by NuGet package be in source control?

We have a custom NuGet package which contains a DLL and a config file. We make use of NuGet package restore so our packages are not commit in to Perforce. When the package is installed to the solution it adds a reference to the DLL and the config file is included in the root of the project. Both of these are desirable, but should the config file be checked in to source control?
Our CI environment breaks when the file is not checked in, but the package has been downloaded correctly. It looks like this is the correct NuGet behaviour, but I'm not sure what the suggested best practice it is with regards to content files and how they should be treated in version control. Do all content files added from packages need to be checked in?
NuGet package restore will only restore files into the packages directory.
Files that are copied into your project when installing a NuGet package should be checked into source control since they will not be restored.