Currently, I am packing several files and clicking them on the NuGet channel on one of our servers using the command line tool. Instead of using the command line tool, I set up the project using Nuget.Core and was able to successfully create the package. Now I am trying to pull this package from my machine to the NuGet channel through NuGet.Core. Using a command line tool that looks like this (and I did it too):
nuget.exe push package.nupkg -ApiKey MYAPIKEY -Source http://nugetpackagefeedaddress
I want to replicate the push function using NuGet.Core. So far, I have managed to get two repositories from PackageRepositoryFactory so far, one for the local machine path and one for the package feed, and then extract the package from the local one and try and add it to the feed, like this:
var remoteRepo = PackageRepositoryFactory.Default.CreateRepository("myNugetPackagefeedUrl"); var localRepo = PackageRepositoryFactory.Default.CreateRepository(@"locationOfLocalPackage"); var package = localRepo.FindPackagesById("packageId").First(); remoteRepo.AddPackage(package);
This code causes a NotSupportedException indicate that "The specified method is not supported"
Can I push packages using NuGet.Core? and am I somewhere next to it with the above code?
Note. I know that I can wrap the nuget.exe call and call it from .NET, but I would like to either package, or click from NuGet.Core, or do this by wrapping the calls in nuget.exe than half and half
c # nuget nuget-package
rh072005
source share