How do I uninstall a nuget package that is not available? - nuget

I have moved my project to a new machine and do not have access to an old nuget package called SBD.Common that was stored locally on the old machine.
I want to uninstall the package from the project
When I use Manage Nuget Packages for solution I can see that the package is installed but not available in this source.
When I click the Uninstall button I get an error
An error occured while trying to restore the packages" Unable to find version '1.0.0' of 'SBD.Common'
c:\Program files(x86)\Microsoft SDKS\NugetPackages\:Package 'SBD.Common.1.0.0' is not found on source 'C:\Program Files(x86)\Microsoft SDKs\NuGetPackages\'
https://api.nuget.org/v3/index.json:Package 'SBD.Common.1.0.0' is not found
How do I tell my project that I don't want to restore this package without gaining access to the package?
Here is my Nuget.Config at C:\Users\MyName\AppData\Roaming\NuGet
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
<add key="Microsoft and .NET" value="true" />
</disabledPackageSources>
<packageRestore>
<add key="enabled" value="False" />
<add key="automatic" value="False" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
I am using Nuget version 3.4.4.1321

the problem was that I had the files listed in packages.config

Related

Why can't Visual Studio restore NuGet packages from Azure DevOps artifact feed

I am setting up Visual Studio 2022 Community Edition on a new workstation. I have instructions for connecting to an Azure DevOps artifact feed that worked on my previous workstations. Despite following the same instructions, I can't restore NuGet packages from the Azure DevOps artifact feed.
I configure the artifact feed manually by editing %APPDATA\NuGet.config and adding an element to the packageSources element just below the entry for nuget.org.
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="azure-devops-feed" value="https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json" protocolVersion="3" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
Note the protocolVersion="3" on the new element; this is needed because Visual Studio 2022 was using protocol version 2 which is not supported by the artifact feed.
When I try to run the build, I get the output
NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json.
I opened https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json in an Incognito tab in my browser to verify that, once I authenticated using the same Windows account that I use to log in to Visual Studio, the index.json is accessible and contains the expected contents.
Update
This was solved by copying the NuGet.config file from my old workstation. The only difference is that the protocolVersion="3" attribute was removed from the private feed element. When I was setting this up previously I had to add that attribute, as otherwise Visual Studio used Protocol Version 2 which got 404 errors.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="azure-devops-feed" value="https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/xxxxxxxxxxxxxx/_packaging/xxxxxxxxxxxxxx-feed/nuget/v3/index.json.
The cause of the issue is that the Private Nuget source miss Credentials in Nuget.config file.
To solve this issue, you can use the following command to add the Credentials to the Nuget.config file.
nuget sources update -name azure-devops-feed -username 123 -password <PAT>
Then you can check if the Nuget.config file has added the Credentials.
For example:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
<add key="test1" value="https://pkgs.dev.azure.com/xx/xx/_packaging/xx/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<test1>
<add key="Username" value="123" />
<add key="Password" value="based64PAT" />
</test1>
</packageSourceCredentials>
</configuration>
For more detailed info, you can refer to this doc: packageSourceCredentials

Local copy of nuget.exe unable to find any packages on nuget.org

I've been using this SO answer and this Powershell script to transform .NET config files.
The gist of the script is that it downloads a local version of nuget.exe, then uses this to download NuGet packages which will be used for the XDT transformations.
My problem is that when it invokes a line to download a NuGet package I'm told that the package cannot be found. For example...
Unable to find version '3.1.0' of package 'Microsoft.Web.Xdt'.
...even though nuget.org clearly states that this is valid - link. I've tried it with other packages and their publicly-stated versions, and receive the same message.
Another point to be aware of is that we have our own private NuGet feed. When I run the Powershell script it will also attempt to search that feed, which I don't want it to do, so I have added a nuget.config file in the same directory as the Powershell script (I've also tried it in the same directory as the local nuget.exe) in which I have disabled our custom NuGet source...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
<add key="DevOps" value="true" />
</disabledPackageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Other than that <disabledPackageSources /> section the rest of this nuget.config was copied from my machine-level nuget.config.
Can anyone explain why this local instance of nuget.exe is unable to find any packages from nuget.org?

VSO Build not able to download packages

I have the following nuget.config file and bellow is the file content
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="Packages" />
</config>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
<packageSources>
<!-- Ditch all the Global NuGet package sources we only want a
single private NuGet repo for this project -->
<clear />
<add key="private="private" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources>
<add key="nuget.org" value="false" />
</disabledPackageSources>
</configuration>
All the packages which exist in the private feed are restored but the same is not happening with the ones in nuget.org:
From VSO build output
Feeds used:
C:\Users\buildguest\AppData\Local\NuGet\Cache
private
https://www.nuget.org/api/v2/
...
Restoring NuGet package AutoMapper.5.2.0.
WARNING: Unable to find version '5.2.0' of package 'AutoMapper'.
This is happening during the NuGet restore step in VSO.
Use NuGet.Protocol.Core.v3 feed protocol with
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
instead of
<add key="nuget.org" value="https://nuget.org/api/v2/" />
enter image description here
Inside Nuget.config put the bellow code.
<configuration>
<packageRestore>
<add key="enabled" value="True"/>
<add key="automatic" value="True"/>
</packageRestore>
</configuration>

Nuget Package Manager combining local and external servers

Hoping for a little help here. I've a custom built dll which has a dependency on EntityFramework. I've deployed the custom build dll to our local nuget server. However I have not deployed EntityFramework. That is available on the external nugget servers.
When I attempt to install my custom build dll using the Nuget Solution Manager, I get the following error:
Attempting to resolve dependencies for package 'CustomBuilt.dll.2016.10.10.6' with DependencyBehavior 'Lowest'
Unable to resolve dependency 'EntityFramework.dll'. Source(s) used: 'LocalServer', 'NugetAlt1', 'NugetAltHttps', 'nuget.org', 'Microsoft and .NET'.
The url's for external Servers are:
NugetAlt1: http://packages.nuget.org/v1/FeedService.svc/
NugetAltHttps: https://www.nuget.org/api/v2/
nuget.org: https://api.nuget.org/v3/index.json
Microsoft and .Net: https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/
I am using VS2015. I've also tried with VS2013.
Also I've added a nuget.config file to the solution. Still getting the error:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="LocalServer" value="http://localserver:8089/nuget" />
<add key="NugetAlt1" value="http://packages.nuget.org/v1/FeedService.svc/" />
<add key="NugetAltHttps" value="https://www.nuget.org/api/v2/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
Any thoughts/ideas?
Kind Regards,
Fiona
I finally found it.. The problem was in the nuspec file that I was using to generate the package. The id of my dependencies was incorrect.
I specified the following:
<dependencies>
<dependency id = "EntityFramework.dll" version = "6.0.0.0" />
</dependencies>
This is incorrect. The package name of EF is EntityFramework not EntityFramework.dll
This is how it should be specified:
<dependencies>
<dependency id = "EntityFramework" version = "6.0.0.0" />
</dependencies>

Can you restore packages in a VSTS feed that belongs to another VSTS account?

My company has many Visual Studio Team Services accounts. We have one for our internal development, and one for each of our clients. We're hosting our internal nuget libraries in our internal development account (https://{dev-account}.visualstudio.com/DefaultCollection), and I want to restore packages when running a build in a client's account (https://{client-account}.visualstudio.com/DefaultCollection).
I set up the repository using bootstrap tools, and in my VSTS build I added a Batch Script build step the executes init.cmd. That works fine, however, the next step is NuGet Package Restore where it can't find the packages in the dev account's NuGet feed:
2016-03-22T23:34:37.5398840Z Please provide credentials for:
https://{dev-account}.pkgs.visualstudio.com/DefaultCollection/_packaging/{my-feed}/nuget/v3/index.json
2016-03-22T23:34:37.5408842Z UserName: Password: WARNING: Unable to
find version '1.9.0.10' of package '{my-package}'.
This makes sense, because the feed is in a separate VSTS account and the build agent doesn't have permission to access the feed.
Is there anyway around this? I'm aware of MyGet, which offers free public feeds, but I'd like to use VSTS, if possible.
I'm not thrilled with this solution, but it works. You can store credentials for a package source in nuget.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<clear />
<add key="repositoryPath" value="packages" />
</config>
<packageSources>
<!-- When <clear /> is present, previously defined sources are ignored -->
<!-- Remove this tag or un-comment the nuget.org source below to restore packages from nuget.org -->
<!-- For more info, see https://docs.nuget.org/consume/nuget-config-file -->
<clear />
<add key="vss-package-management" value="https://www.myget.org/F/vss-package-management/api/v2" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="{dev-account}" value="https://{dev-account}.pkgs.visualstudio.com/DefaultCollection/_packaging/{feed}/nuget/v3/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSourceCredentials>
<{dev-account}>
<add key="Username" value="username" />
<add key="ClearTextPassword" value="password" />
</{dev-account}>
</packageSourceCredentials>
</configuration>