Simplest way to pull a Microsoft DLL into a VS project? - nuget

I need to download Microsoft.IdentityModel.Clients.ActiveDirectory.dll v3.19.8.16603 into my .NET project. I would have thought this is a simple task, but I'm running into one problem after another, and I fear these are all noob problems. I have tried 3 different approaches:
APPROACH #1
VS2019 - NuGet Package Manager -> Manage NuGet Packages for Solution
Why "No packages found"? I know it exists.
APPROACH #2
VS2019 - NuGet Package Manager -> Package Manager Console
PM> Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 3.19.8
Result:
Attempting to gather dependency information for package 'Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.8' with respect to project '_JunkTest', targeting '.NETFramework,Version=v4.7.2'
Install-Package : Package 'Microsoft.IdentityModel.Clients.ActiveDirectory 3.19.8' is not found in the following primary source(s): 'C:\Program Files (x86)\DevExpress
21.2\Components\System\Components\Packages,C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'. Please verify all your online package sources are available (OR)
package id, version are specified correctly.
At line:1 char:1
+ Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Vers ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
APPROACH #3
VS2019 - Developer Command Prompt
dotnet add package Microsoft.IdentityModel.Clients.ActiveDirectory --version 3.19.8
Result:
Determining projects to restore...
Writing C:\Users\<redacted>\AppData\Local\Temp\tmpF88E.tmp
info : Adding PackageReference for package 'Microsoft.IdentityModel.Clients.ActiveDirectory' into project 'D:\Dev\Git\_JunkTest\_JunkTest.csproj'.
error: Error while adding package 'Microsoft.IdentityModel.Clients.ActiveDirectory' to project 'D:\Dev\Git\_JunkTest\_JunkTest.csproj'. The project does not support adding package references through the add package command.
In actuality, I don't even need a reference to that DLL in this project. I just need the DLL along with any of its dependencies so I can copy them into some other projects I have, but I don't want to muddy those by nugetting directly in. Or at least I want to figure it out in this junk project first. I'm really just looking for the easiest way to download the DLL(s).
https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/

Related

NuGet: Restoring packages for... An item with the same key has already been added

I keep getting the following response when trying to install EF 6.4.4 (or any other!!) NuGet package to a project:
PM> Install-Package EntityFramework -Version 6.4.4
Install-Package : The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing
methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support
Services.
At line:1 char:1
+ Install-Package EntityFramework -Version 6.4.4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], PSInvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Any help is highly appreciated.
NuGet: Restoring packages for… An item with the same key has already
been added
Please try these:
Suggestion
1) clean all nuget caches or delete any nuget caches under C:\Users\xxx(current user name)\.nuget\packages
2) make sure that you can access the Internet and turn off any firewall or any antivirus software
Also, you can try to check if you can access the package under Manage Nuget packages by right-click on your project
3) close VS, delete .vs hidden folder under Solution folder, bin and obj folder, then delete nuget.config file under C:\Users\xxx(current user name)\AppData\Roaming\NuGet and then restart your project to test again.
Also, please enable nuget.org package source and disable the others under Tools-->Options-->Nuget Package Manager--> Package Sources
Enable nuget.org and disable others.
Run update-package -reinstall under Package Manager Console
Last, choose the nuget.org as package source and the right target project and then install EntityFramework to test again.
In addition, please try to create a new project and then install that package in it to check if the issue occurs only on your current project.

Install-Package : '7.0.4-IR19' is not a valid version string. Error

I want to add UmbracoCMS nuget with Package Manager Console(Install-Package UmbracoCms). But i can't ...
Attempting to resolve dependency 'Lucene.Net (≥ 2.9.4.1 && < 3.0.0)'.
Attempting to resolve dependency 'SharpZipLib (≥ 0.86.0)'.
Attempting to resolve dependency 'MySql.Data (≥ 6.9.8 && < 7.0.0)'.
Install-Package : '7.0.4-IR19' is not a valid version string.
Parameter name: version
At line:1 char:16
+ Install-Package <<<< UmbracoCms
+ CategoryInfo : NotSpecified: (:) [Install-Package], ArgumentException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I'm not exactly sure what is causing your problem, but I might have an alternate way of setting things up that could help you. When we nuget our umbraco sites, we only nuget the UmbracoCms.Core package. This gives us all the dlls and references we need. It also makes it a lot easier for us to upgrade umbraco. The UmbracoCms.Core nuget package is something that you would already get automatically as a dependency by nugetting the whole UmbracoCms package.
We then take a zip of the version of umbraco we want and manually merge that into the project using a tool like BeyondCompare. We like to handle the rest of the files outside of nuget because sometimes those other files require special care when merging during an upgrade.

Not finding PowerShell packages in Nexus OSS when the RequriedModules Attribute has a value in the Module Manifest

I have been working on setting up a DevOps stack (source control, ci, package management) for our powershell modules. I was playing with nexus OSS as a PM solution. I am able to use the Publish-Module cmdlet to add modules to the nuget feed, as well as use Install-Module to install them from the same feed. I started playing around with dependencies, the RequiredModules key in the Module Manifest. And if I put a module in there, then publish it to the nexus (the dependent package needs to published first) it will complete, and I can go to the web interface and see the pkg in the feed, and see the other pkg as a dependency. But when I then use Install-Module I keep getting an error
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'MyModule'.
Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.1.0\PSModule.psm1:1826 char:21
+ ... $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
now, if I remove the required module value from the manifest, it works again. I went ahead and put up ProGet, and I do not have this issue, I can install the main package and the dependent one comes along too. Thanks for any help or ideas!

NuGet install-package failing

I'm attempting to install xunit version 2.1.0.. However I'm getting the following exception:
Install-Package : Exception 'System.AggregateException' thrown when trying to add source 'https://api.nuget.org/v3/index.json'. Please verify all your o
nline package sources are available.
At line:1 char:16
+ Install-Package <<<< xunit -Version 2.1.0
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Any ideas on whats going wrong? Sadly google is not giving me anything helpful..
It is an old question, but it just happened to me, and the solution may help others: In my case it was due to a package source that was not available anymore and I needed to remove it from the NuGet Package manager configuration:
Tools -> NuGet Package Manager -> Package Manager Settings -> go to Package Sources and remove the source that is generating the problem.
And be aware of the fact that this server is not responding! If it is one server of your own, it would be good for you to check what is happening with it. ;)

NuGet Pack .nuspec file returns "The replacement token 'version' has no value."

This is the error I got while trying to pack a project in Visual Studio 2013:
PM> NuGet Pack C:\ITVizion\RTVizion\ITVizion.RTVizion.Service\ITVizion.RTVizion.Service.nuspec -Prop Configuration=Release
Attempting to build package from 'ITVizion.RTVizion.Service.nuspec'.
NuGet : The replacement token 'version' has no value.
At line:1 char:1
+ NuGet Pack C:\ITVizion\RTVizion\ITVizion.RTVizion.Service\ITVizion.RTVizion.Serv ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (The replacement...' has no value.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
What's wrong with this?
I found the problem:
Make sure you fill your project Assembly Information page.
You can access it right clicking your project in Visual Studio Solution Explorer. Select Application tab => Assembly Information... button.
In case anyone else has a similar error message, and finds that the error message does not go away even if the information is indeed specified in the Assembly Information, I figured out a fix. I don't see this documented in anyone else's answers, and note that this in fact contradicts what the docs say.
Once you've created SomeProject.nuspec with the various $id$, $author$, etc replacement tokens plus any any custom replacement values, the docs instruct you to then place SomeProject.nuspec** into the same directory as SomeProject.csproj, and run
nuget.exe pack SomeProject.csproj -Build
This did not work for me - I got errors about replacement tokens with no value.
However, what did work for me is to call
nuget.exe pack -Build
in the same directory as the nuspec and csproj files, without specifying which csproj or nuspec file to use. This successfully created the nupkg file with the replacement tokens appropriately substituted based on what I specified in the nuspec!
Hopefully this information will be useful to someone else out there!