Install nuget package without content folder - nuget

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.

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.

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.

Can I change Nuget package place?

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.

How to create a solution-level NuGet package?

How do I create a solution-level NuGet package. That is, one that does not touch any projects, and is listed in .nuget\packages.config (not in any project-level packages.config files).
For example, psake and RavenDB.Server are solution-level NuGet packages.
I can't find anything in the docs for .nuspec files or nuget.exe that says anything about solution-level packages. I can't find anything special in the build processes of those two projects when they call nuget pack. In fact, I can't find a single search result at all about creating solution-level packages.
I found a brief comment from Phil Haack. It's from an issue on CodePlex:
We already support this. Just don't put any content in the /Content
folder nor in the /Lib folder. If your package only has contents in
the /Tools folder, the package will not get installed in the project.
Haven't had a chance to test this out, but it sounds like what you're looking for. A quick peek into the RavenDB.Server package (rename .nupkg to .zip) reveals a setup that is consistent with what Phil said in his comment. No content folder, no lib folder. Lots of files. The files are not in a /tools folder, so I think it's safe to presume that's not a requirement.