Can't install nugget package I made because package is not found - visual-studio

I created a nugget package that contains 5 dll that I want to use as dependencies for some projects. I created a package source to C:\Users\fernane\Desktop\test via Visual Studio so I can select and install my packages from that directory. The package named test 1.4.0.nupkgis in that folder.
The problem I have is that when I try to install said package (test), I get the following error :
Package 'test 1.4.0' is not found in the following primary source(s): 'C:\Users\fernane\Desktop\test'. Please verify all your online package sources are available (OR) package id, version are specified correctly.
I created the package using Nuget Package Explorer.
ID of the package : test
Version : 1.4.0
My question is the following : Why do I get this error and how can I install my package?
Thank you and have a nice day.

My question is the following : Why do I get this error and how can I install my package?
Make sure you've "all" source selected in Package Manager Console and then try update-package command:
Alternatively, you can install that package via Manage NuGet Package UI, Right click your project->Select Manage NuGet Package->change the Package Source to your local feed->find the pacage, install it:

Related

VisualStudio nuget: Unable to resolve dependency 'Microsoft.Graph.Auth'

When attempting to install a package that has a dependency to Microsoft.Graph.Auth, the nuget package manager in VisualStudio errors with this message:
Unable to resolve dependency 'Microsoft.Graph.Auth'. Source(s) used: 'nuget.org'
No other information is provided.
I can successfully install the Microsoft package manually, however.
The package that depends on the Microsoft package has this in its .nuspec, so as far as I can tell, it should work:
<dependency id="Microsoft.Graph.Auth" version="1.0.0-preview.7" />
I can find it by checking Include prerelease option.
As Per the doc Microsoft.Graph.Auth is deprecated and no longer maintained , either you can try by suggested alternative package Azure.Identity or try by installing via the NuGet package manager console.
NuGet\Install-Package Microsoft.Graph.Auth -Version 1.0.0-preview.7
Thanks

Removing a NuGet package that isn't in my project?

I keep getting this warning in my VS2015 solution:
Some NuGet packages were installed using a target framework different from the current target framework and may need to be reinstalled.
The thing is, there are no NuGet packages in my solution. I had one, but I removed it, but I still get this.
Any ideas?
Removing a NuGet package that isn't in my project?
It seems that you have not properly removed that NuGet package.
To resolve this issue, please try to reinstall this package, then uninstall it.
Detailed:
Open the the Package Manager Console by Tools->NuGet Packager Manager->Package Manager Console, and type following command line to reinstall nuget package:
Update-Package -reinstall
After the re-installation is complete, type following command line to uninstall the package in the Package Manager Console:
Uninstall-Package <PackageID>
With this way, the nuget package will be moved from your project. If you have installed that package for multiple project in the solution, please use the uninstall command line for different default project in the Package Manager Console window:
Hope this helps.

How to resolve Nuget Package Version and Path in Pre-Build Event of a Project?

I have a NuGet Package containing content files that is referenced in my project. When getting latest on a new machine, the build fails because NuGet Restore doesn't copy content files. So what I want to do is this:
In PreBuild
If my Content file doesn't exist,
run this nuget Command: "Update-Package My.Nuget.Sources -reinstall"
I'm struggling with determining path differences due to versioning of the Nuget files and getting access to nuget. How do I actually generate the SourceOnlyNugetVersion and NugetPath variables below?
if not exist "$(ProjectFolder)App_Packages\My.NuGet.Sources.$(SourceOnlyNugetVersion?)\somefile.cs" (
"$(NugetPath)nuget.exe" Update-Package My.NuGet.Sources -reinstall
)
How to resolve Nuget Package Version and Path in Pre-Build Event of a Project?
If you want to reinstall package automatically in Pre-build event, I am afraid you can`t achieve it currently.
We could use the command Update-Package -Id <package_name> –reinstall to reinstall the packages to your project in the Package Manager Console, but it is impossible to automate that.
If you want to automate it in the build event, you have to call the NuGet CLI rather than Package Manager Console. Because NuGet CLI does not modify a project file or packages.config; in this way it's similar to restore in that it only adds packages to disk but does not change a project's dependencies. See NuGet CLI reference.
The operation Install packages on NuGet CLI:
Conversely, operation Install packages on Package Manager:
Installs a package and its dependencies into a project.
So we could not use NuGet CLI to reinstall NuGet packages for project.
Besides, we could not use the Package manager console powershell outside visual studio, because package manager console is providing is access to visual studio objects.
https://github.com/NuGet/Home/issues/1512
Similarly, we could not use Package manager console in the build event, build events are run by MSBuild so it needs to work when the build is run from the command line.
So it seems impossible to automate reinstall NuGet packages, or the alternative approach would be to write a console app that uses NuGet.Core.dll to do the same thing that the PowerShell script is doing.

OpenSSL Nuget package not installing in VS 2015

I am trying to install the OpenSSL Nuget package in VS 2015.
I get the error:
Attempting to gather dependencies information for package 'openssl.1.0.2.1' with respect to project 'BLL', targeting '.NETFramework,Version=v4.5'
Package 'openssl' is not found in the following primary source(s): 'https://api.nuget.org/v3/index.json'. Please verify all your online package sources are available.
========== Finished ==========
I also tried running
Install-Package openssl
from the Package Manager Console, but it did not work. It downloaded the "openssl.1.0.2.1.nupkg" file to my packages directory, but there are no other files.
Has anyone else run into this?
The OpenSSL package used for C++ project. And I get the same issue with you when installing the version 1.0.2.1. Then I download the OpenSSL package to local and open it with NuGet Package Explorer, I don't find any content files in this package.
I have submit this issue to OpenSSL package. Please add your comments to this feedback and please waiting response from the owner patiently.
https://github.com/openssl/openssl/issues/1865
But when install the OpenSSL package 1.0.2, it doesn't get any error. So I suggest you install the version 1.0.2 in your project.

NuGet package without assemblies complains about lack of assemblies

I'm creating a content-only NuGet package (e.g. no DLLs, just text files in this case). When I install the package, I get this error message:
Install-Package : Could not install package 'CodeGenerator.Templates.EF6-CQRS-Aurelia 1.0.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or
content files that are compatible with that framework. For more information, contact the package author.
This is all true, but I don't want to target any framework for this package -- how can I accomplish this?
The package is here: https://www.nuget.org/packages/CodeGenerator.Templates.EF6-CQRS-Aurelia
I had the same problem but with only a build target (and no assemblies).
Just adding an empty lib folder to my root package directory fixed it.
(Maybe a bug in NuGet. I have submitted an issue.)

Resources