I downloaded the Nuget package
microsoft.aspnet.webapi.5.2.0.nupkg
but there are no dlls in there. How does this nuget package work ? Was excepting dlls in side.
Whilst Microsoft.AspNet.WebApi 5.2.0 does not contain any dlls itself it depends on the Microsoft.AspNet.WebApi.WebHost NuGet package which does contain dlls. The Microsoft.AspNet.WebApi.WebHost also depends on other NuGet packages, and so on.
In the Microsoft.AspNet.WebApi.5.2.0.nupkg there is a .nuspec file which defines the dependencies:
<dependencies>
<dependency id="Microsoft.AspNet.WebApi.WebHost" version="[5.2.0, 5.3.0)" />
</dependencies>
If you install the NuGet Package Explorer it will be easier to see how this works. The NuGet Package Explorer allows you to find, download and look inside NuGet packages without having to download and unzip them manually.
Related
I am newbie in SharpDevelop and want to download Nuget packages. But I couldn't find any information about this topic on google. How to get Nuget packages in SharpDevelop?
I have taken new nuget.exe from here, put it to c:\test, in cmd -> cd c:\test I then entered nuget to get all info, and tried then nuget install Newtonsoft.Json -version 13.0.1 - getting "nuget argument can not be null or empty" - advice helped - tried ONLY nuget install Newtonsoft.Json - result "nuget unable to find package" - advice helped - I created nuget.config file with such content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
and put it near my new nuget.exe previously loaded...
PROFIT: nuget install Newtonsoft.Json - RETURNED needed nuget package's dlls of Newtonsoft (JSON.NET)...
and through (left-mouse-button in your SharpDevelop project) Referencies - AddReference -> .NET Assembly Browser -> Browse -- you can choose necessary c:\test folder (in my case) and dll version in it and add it to your project...
the oldest version (4.0) is better choice for best compatibility with both OS with NET.Framework 4.0 and OS with NET.Framework later versions as well
I am trying to run:
nuget pack project.csproj
but because of the directory structure of the project:
A\B\C\Project
it keeps saying:
NuGet.Protocol.Core.Types.FatalProtocolException: Failed to retrieve information from remote source 'A\B\Packages', which it really should be 'A\Packages'. How do I change where NuGet looks for packages while establishing dependencies.
I have tried putting a NuGet.config in both the project directory as well as the Solution (in .nuget). I added this to the file:
<config>
<add key="repositoryPath" value="A\Packages" />
</config>
in both places and it made no difference (it always says A\B\Packages).
VisualStudio 2019: Tools > Nuget Package Manager > Package Sources:
Select nuget.org and specifically unselect the others options
Add NuGet.org reference in the package source
Go to tools -> NuGet package manager-> package manager settings
Select NuGet Package manager and then Package sources
Add the following source library.
Name: NuGet.org
Source: {"\Https://api.nuget.org/v3/index.json}
The error is a bit weird, but is already mentioned here.
It looks like NuGet by default expects a packages folder at the same location as the .csproj file.
I also had a custom project structure where the .sln was located in another folder.
At least I worked around this by creating a Symbolic link like this (open cmd with admin rights):
cd <your .csproj location>
mklink /d packages "C:\path\to\actual\packages"
This way NuGet thinks the packages folder exists and should be able to create your package.
For me it worked by adding NuGet.config in solution folder.
I was facing similar issue with core 3.1 and trying to upgrade package 'Swashbuckle.AspNetCore.SwaggerGe'.I found that i was doing typo in Package source url. I have corrected it [Tools => Nuget Package manager => Package manager setting => Package Source ] and issue got resolved.
If you use packages that have Semantic Versioning 2.0.0, please make sure that you are using the V3 feed, https://api.nuget.org/v3/index.json, in the NuGet configuration.
The issue may be caused by the way the nuget looks for the packages folder. It looks for a .sln file by traversing up the directory structure. If, in your case, directory A\B contains a .sln file then nuget will assume the packages folder would also be there.
On OSX you can add a symlink to trick nuget into building.
Run the following in the project folder to make nuget read from the parent (solution) directory that have a packages folder:
ln -s ../packages packages
In my case, I unchecked ALL the package sources except the one that I needed which was NuGet.org from NuGet Package Manager >> Package Sources. After this, the NU1301 error was gone.
In the case of Rider IDE another problem could cause this error:
if you configure your NuGet sources in the project let the Username and Password in the Rider Ui empty and instead add manually this section (packageSourceCredentials) to your NuGet.Config in the project folder:
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="YourNuget" value="<your_nuget_url>" />
</packageSources>
<packageSourceCredentials>
<YourNuget>
<add key="Username" value="<Username>" />
<add key="ClearTextPassword" value="<Password>" />
</YourNuget>
</packageSourceCredentials>
</configuration>
I cannot get nuget pack X.csproj to recognize package dependencies in a project. Amazingly, when packaging, the diagnostic message “Found packages.config. Using packages listed as dependencies” is printed, but in the end the <dependencies/> tag in the .nuspec file inside the package is empty.
The packages.config for the project does indeed contain references:
<packages>
<package id="SmartAction.Logger" version="1.0.2.0" targetFramework="net40" />
<package id="SmartAction.Pervasive" version="1.0.1.0" targetFramework="net40" />
</packages>
To narrow the problem down, I removed my own parallel .nuspec file, and mostly all switches from the nuget pack command:
> nuget pack libToneDetection.csproj -prop Configuration=Release
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Attempting to build package from 'libToneDetection.csproj'.
Packing files from '[snip]\Core\ToneDetection\libToneDetection\bin\Release'.
Found packages.config. Using packages listed as dependencies
Successfully created package '[snip]\Core\ToneDetection\libToneDetection\SmartAction.Audio.ToneDetection.1.0.0.0.nupkg'.
NuGet Version: 3.3.0.212
The only difference I can spot with this project is that its name is different from package name (I am trying to maintain them in sync but this is older stuff I am repackaging).
I doubt I had ever seen this before. I am finding questions on SO from people trying to prevent references in packages.config from becoming dependencies of the package, but none from those trying, like me, to beat the reverse problem. Help!
Addendum. I copied the project out of the solution with other projects to a temporary directory and rebuilt the package from there. Now one of the two dependencies from packages.config was added to the package:
<dependencies>
<dependency id="SmartAction.Logger" version="1.0.2.0" />
</dependencies>
Thinking of the differences between the two, the SmartAction.Logger package depends on SmartAction.Pervasive. But the package I am compiling really uses both.
To me, either behavior looks incorrect. Am I hitting a nuget bug, or a cryptic complex feature?
Xref: Opened https://github.com/NuGet/Home/issues/1867
I want to use nuget.exe (version 2.5) in my CI build pipeline to install a package which has dependency to another package.
I have following nuspec file.
<?xml version="1.0"?>
<package>
<metadata>
<id>A</id>
<dependencies>
<dependency id="B" version="1.0.0.1" />
</dependencies>
</metadata>
<files>
<file src="A.dll" target="lib" />
</files>
</package>
and similar for B.
and my packages.config file which I used to install is:
<packages>
<package id="A" version="1.0.0.1" allowedVersions="[1,2)"/>
</packages>
and I run following command:
NuGet.exe install packages.config -ExcludeVersion -Outputdir libs -source http://get.nuget.mydomain
I get output:
Successfully installed 'A 1.0.0.1'.
but do not get my dependency B installed.
But if put B separately in packages.config file, I get both A and B getting installed. I expected B to be installed when we install A as it is a dependency of A.
We do not put dlls in GAC (so I believe dependency resolution should not be a problem).Also I have opened A.nupkg and checked that is has dependency listed there.
Also when I install A from with in visual studio editor B also gets installed.(which is what should happen).
How do I use nuget.exe and install dependency B when i install A only (put A only in packages.config).
thanks
This is not possible. The behavior of the packages.config file is by design. Only things specified in the packages.config are installed, not their dependencies. All dependencies must be explicitly specified as well.
If you look at the source code you will see that nuget.exe install packages.config (http://nuget.codeplex.com/SourceControl/latest#src/CommandLine/Commands/InstallCommand.cs) uses PackageExtractor.InstallPackage (http://nuget.codeplex.com/SourceControl/latest#src/CommandLine/Common/PackageExtractor.cs):
public static void InstallPackage(IPackageManager packageManager, IPackage package)
{
var uniqueToken = GenerateUniqueToken(packageManager, package.Id, package.Version);
// Prerelease flag does not matter since we already have the package to install and we ignore dependencies.
ExecuteLocked(uniqueToken, () => packageManager.InstallPackage(package, ignoreDependencies: true, allowPrereleaseVersions: true));
}
Note the hard call to ignoreDependencies: true
I am creating a Class Library that builds 2 dlls into a NuGet package. It has a few references to dlls that currently do not have a NuGet package to be referenced from.
How should I make my NuGet package dependent on those dlls that are currently unavailable via NuGet?
If I bundle them up as well, what happens if a project that already has a reference to these dlls, pulls down my NuGet package, what happens to that reference?
Should I just create a NuGet package for each dll reference and make my NuGet package dependent on these?
You can bundle the DLLs into your NuGet package with no ill effects. A project that already has those DLLs in some /libs (or whatever) folder will continue to reference them from there. Assemblies in your NuGet package will reference the bundled DLLs that are pulled into /packages.
In your nuspec file, use the <file> element to include the internal DLLs, as such:
<package>
<metadata>
...
</metadata>
<files>
<file src="PATH_TO_BIN\DependencyOne.dll" target="mylibs" />
<file src="PATH_TO_BIN\DependencyTwo.dll" target="mylibs" />
</files>
</packages>
This will result in the following file structure when the NuGet package is pulled:
PATH_TO_PROJECT/packages/YOUR_NUGET_PACKAGE/mylibs/DependencyOne.dll
PATH_TO_PROJECT/packages/YOUR_NUGET_PACKAGE/mylibs/DependencyTwo.dll
The target attribute can specify any arbitrary path relative to your package root.