Nuget DLL location issues with SVN - c#

We have a .csproj that is being worked on by a number of people.
Unfortunately nuget has installed its 'packages' in different locations on each users machine, meaning when another user does an SVN 'update', their project wont compile because the .csproj file's 'hintpath' element is pointing to the dll in a different location.
Are there any other solutions to this?

Use NuGet packages restore feature and don't commit packages to source control.
This allows NuGet client application to download packages on demand. Downloaded packages will be located in solution folder, so, references to packages content will work at any machines.

Related

C# Windows forms Application Reference error in release

I have my windows forms application with WindowsAPICodePack but i don't know where should I put the package in the release folder, and without it the program just gives me an error (it's in Hungarian so I don't think anybody can understand, but it said that it can't find the windowsAPICodePack, the version number, culture and publickeytoken) on another PC, on mine it works.
Depending on if your application is using a packages.config file to manage packages or if your project is using package references (PackageReference) will determine path to solution.
When a package is installed it records the package identifier and version into the project file or packages.config file in your solution workspace.
If using a package.config to mange packages then ensure your packages are getting installed in the location as expected, possibly clearing the cache will help to ensure proper version is installed.
find out the packages folder where your application is trying to load the references.
Possibly config binding redirects.
Clear you package cache and reinstall. use the package manager ui for your ‘debug’ and ‘release’ MSBuild configs to ensure the package is being referenced correctly.
Verify your nuget.xml settings file for locations of packages
Read all the version or property values to use for your application. Ensure you are configuring the release target as expected.
Here are some links to help you config the correct setup for your approach:
Package reference via project files
if using - Packages.config settings
Config setting for Nuget
NuGet settings
Note: for simplicity if this is just a school project then just remove all NuGet packages references and find the dll . Then just add reference to dll and check the property to include in output . This will give you a simple folder with all the files needed to run your app from pen-drive

ASP.NET NuGet Package Dependency Will Not Update

I am working in an ASP.NET website (Website-A) code base which consumes an in-house NuGet package dependency.
Website-A consumes a pre-release of a NuGet dependency (Dependency-A). Opening Website-A and looking at "NuGet packages for solution" shows that Dependency-A is currently installed. Running "Restore NuGet packages" runs normally with no errors.
Rebuilding this .NET solution should result in a directory being created in one of the projects. (This directory will not be "included" in the project of Website-A, but the folder should be visible. I have clicked the "show all files" button.)
The issue is that this directory does not appear after rebuilding, nor after re-installing the dependency in NuGet package manager and then rebuilding.
We have discovered that if we manually delete the "packages" folder in the solution, and then "Restore NuGet packages", then rebuild the solution, the dependency will now create the directory like it should. It seems to need the "packages" folder to not exist in order to work like it should.
My question is: Is there something I am missing as far as a setting to automatically delete the packages folder? I would like to avoid having to manually delete this folder every time I need to update to a new pre-release of a NuGet package (we do a lot of this). I am using Visual Studio Enterprise 2017.
My question is: Is there something I am missing as far as a setting to
automatically delete the packages folder?
I'm afraid the answer is negative. AFAIK, VS doesn't have the option to delete the packages folder in Solution directory since it's not a normal way to do package update or package restore.
In addition: Do the pre-release packages have different names like packageName.1.2.0-beta1.nupkg,packageName.1.2.0-beta2.nupkg?
If your pre-release packages have different versions, and you update them using Update button in VS Package Manager UI, I think this strange issue you shouldn't encounter this issue. And if you have both projects in your local machine, it's not a good choice to develop locally with nuget packages...

Does nuget create separate packages?

I am still confused about how nuget works. I git clone a C# .sln project and from console, and I ran this nuget command:
nuget restore my_project.sln
it came to my attention that it generates two packages containing all dependencies required by my_project.
One package is located under my_project/src/packages, the other c:/users/my_user_name/.nuget/packages. While the file structures are a little different the DLL files in both packages are identical.
That confused me. Why two packages are generated by default? Where exactly does Visual studio look up for the project's dependencies?
More important, which config file should I update in order to only keep a copy of the dependencies and how can I specify the location in my file system for the packages?
Recent versions of NuGet support package references in project files.
This format will restore packages on demand, using your %USERPROFILE%.nuget folder as a cache. And your solution folder won't be "polluted" by a packages folder with binaries that you probably don't want to commit to source control.
VS2017 allows you to select "PackageReferences" or the older "Packages.Config" format when you create new projects (Tools/Options/NuGetPackageManager/General).
You probably have some projects in your solution that use the older "Packages.config" format, which stores in the packages folder in the solution directory, and newer "PackageReferences" format.
To convert the older projects to the new format, I believe you need to remove all packages from the project, then add them back again. They will be added using the default format you selected, with a prompt for confirmation if you selected "Allow format selection on first package install".

Install Nuget Packages on Machine

I've been installing Nuget packages and it seems that their just stick in the project. I've found a folder C:\Program Files (x86)\Microsoft SDKs\NuGetPackages, but its seems that it isn't updating the packges.
I recently installed sqlite and I went there to see if it made a change, but it didn't.
I also have the package that I want to install in .nupkg format or find a way to import it.
Is there a way to install NuGet Packages so that they stay on the Machine and not on the project folder it self?
This video solves my 90% of question, as I said above I have the .nupkg file, this videos helped me to install, it still won't be in the Machine. But it seems that Nuget get saved in the machine, not installed.
Install Nuget from a local source

NuGet Package Restore Issue

I need NuGet to automatically restore packages. At the moment, the referenced dlls are missing.
I have enabled package restore on my solution.
The .nuget folder is checked in.
The packages.config file is checked in for each project.
The packages folder (on solution level) is check in.
The packages folder contains folders for all the packages the solution uses with nuspec and nupkg files for each package. The dll is not checked in.
In VisualStudio the packages are installed but the reference to the dll in each project is missing (ass the dll is not checked in).
I have tried to install NuGetPowerTools. Same story.
Thanks,
There is no reason to check-in anything underneath the packages folder. Optionally, you can check in the repositories.config file but technically this is not required.
Do I get it right that you have checked-in the nuspec and nupkg files within the Packages folder? if so, delete them. These will be restored, and their presence might be causing restore failures (I don't think NuGet package restore is checking for the presence of the package contents, and rather checks for the presence of the nupkg/nuspec file in the Packages folder, skipping the package from being restored if found)
In summary, check in only:
The empty solution level packages folder (optionally the repositories.config)
.nuget folder and its contents
packages.config for every project
I have got this problem in Visual Studio 2015 Update 3.
Found a solution that worked for me:
Went in to the user profile NuGet cache
(C:\Users\<username>\.nuget\packages\), and deleted everything in
there.
I think during the restore process my cache was cleared of all DLL
files, and when I tried to install a package it was using the cache
instead of the files off of NuGet. Now that I've cleared the cache, I
can now install the NuGet packages.
This is almost the same symptoms as I had once, and then the cause was the permission level on packages.config. Deleting the file solved it for me.
I have no idea if it will help you, but have a look at the permission sets for all the files.
Same here, deleted config and re-referenced all the packages. Think it has something to do with SVN.

Categories

Resources