I have a nuget package http://www.nuget.org/packages/Tavis.UriTemplates/ that has the following nuspec file,
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Tavis.UriTemplates</id>
<version>0.4</version>
<authors>Darrel Miller</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<title>URI Template resolution library</title>
<description>Implementation of RFC 6570</description>
<tags>http</tags>
<releaseNotes>Added PCL version</releaseNotes>
<projectUrl>https://github.com/tavis-software/UriTemplates</projectUrl>
</metadata>
<files>
<file src="Packages\temp\UriTemplates\lib\Net35\*.*" target="lib\Net35" />
<file src="Packages\temp\UriTemplates\lib\portable\*.*" target="lib\Portable-Net40+WinRT45+WP71+sl4" />
</files>
</package>
If I install this package in a project that is .net40 or .net45 it selects the .net 35 DLL. Anyone have any idea why it doesn't select the PCL library?
NuGet treats PCL assemblies as less compatible than assemblies that target a specific version of the .NET framework.
For your NuGet package you can either add a .NET 4.0 and a .NET 4.5 assembly or remove the .NET 3.5 assembly.
Looking at the NuGet source code, in the VersionUtility class, a PCL assembly's weighting will be halved compared to an assembly that references the full version of .NET.
// we divide by 2 to ensure Portable framework has less compatibility value than specific framework.
return GetCompatibilityBetweenPortableLibraryAndNonPortableLibrary(projectFrameworkName, packageTargetFrameworkName) / 2;
With your NuGet package, even though the PCL assembly's compatiblity is higher based on the value returned from the GetCompatibilityBetweenPortableLibraryAndNonPortableLibrary method, the division by two makes the .NET 3.5 assembly more compatible.
Related
I had to package a portable version of Newtonsoft.Json as an internal NuGet package under a different name (Newtonsoft.SL5.Json). The reason is that we are building into a shared bin directory and I do not want the Silverlight version to overwrite the full .NET version. (Yes, we still have Silverlight and yes the portable Json.Net version is not good enough for non Silverlight code we have)
The package file name is Newtonsoft.SL5.Json.8.0.1.19229.nupkg
Inside it there is Newtonsoft.SL5.Json.nuspec
Inside it there is lib\sl5\Newtonsoft.SL5.Json.dll
The nuspec file content is:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Newtonsoft.SL5.Json</id>
<version>8.0.1.19229</version>
<authors>Newtonsoft</authors>
<owners>Newtonsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Json.NET Portable .NET 4.0</description>
<copyright>Copyright © James Newton-King 2008</copyright>
</metadata>
</package>
Now something I am doing wrong, because as a result, when adding the dependency in Visual Studio, the reference it produces is:
<Reference Include="Newtonsoft.SL5.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.SL5.Json.8.0.1.19229\lib\sl5\Newtonsoft.SL5.Json.dll</HintPath>
<Private>True</Private>
</Reference>
And of course, there is no such assembly Newtonsoft.SL5.Json. It should be Newtonsoft.Json.
So, I am doing something wrong. How should I change the NuGet package so that it uses the correct assembly name, i.e. Newtonsoft.Json? Because even though I changed the file name, the assembly name is still the same.
while adding reference IDE takes .dll files that are included in the package (lib/{platform}/). If you rename those files added and packaged in nupkg file -> those should be added in element.
I did a search on NuGet and couldn't find a Lightspeed NuGet package.
I have pro license for Lightspeed 5 so I have all the binaries I need to use Lightspeed in a non-ASP.Net 5 code.
However, it is my understanding that ASP.Net 5 doesn't allow you to allow you to reference DLLs directly, you have to create a NuGet package first.
So, I created a NuGet package of my POCO objects, DB context and Lightspeed references and added it to a .Net Framework 4.5 console application; it added the appropriate references (NuGet spec I used is show below).
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$id$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright 2015</copyright>
<references>
<reference file="$id$.dll" />
<reference file="Mindscape.LightSpeed.dll" />
<reference file="Mindscape.LightSpeed.Linq.dll" />
</references>
</metadata>
<files>
<file src="..\Mindscape.Lightspeed\Mindscape.LightSpeed.dll" target="lib\net45\Mindscape.LightSpeed.dll" />
<file src="..\Mindscape.Lightspeed\Mindscape.LightSpeed.Linq.dll" target="lib\net45\Mindscape.LightSpeed.Linq.dll" />
</files>
</package>
However, this didn't work as expect when I tried to add this package to my to my ASP.Net 5 website (package added but using statement causes a compiler error).
Does anyone know a work-around to get Lightspeed working with ASP.Net 5?
Ideally Mindscape would publish a NuGet package.
Turns out the have their own NuGet feed that is listed in the "Keys" section of your subscription
Let's say I create a new class library project. I add the Entity Framework 6.1 NuGet package to it, then create a new NuGet package from the class library project with nuget pack MyProject.csproj. I get a nice npkg with a depedency to Entity Framework 6.1.
Then, I decide to add a reference to the GraphDiff NuGet package which has a dependency to EntityFramework >= 6.0, the resulting class library npkg has only a dependency to GraphDiff and a note that it may have sub-dependencies, but nothing about it being Entity Framework and especially version 6.1.
Problems arise when I include the class library npkg into a project: Entity Framework 6.0 gets installed while it should have installed 6.1.
Is there a way around this?
I get this with NuGet.exe 2.8.50926.602
I found that I must use a nuspec file and manually specify a dependencies section, like so:
<?xml version="1.0" encoding="UTF-8"?>
<package>
<metadata>
**snip!!**
<dependencies>
<dependency id="EntityFramework" version="6.1.2" />
</dependencies>
</metadata>
</package>
I haven't been able to change anything working with the nuget project's packages.config file.
There's some valuable information about version dependency on Rick Strahl's web log
I'm attempting my first NuGet package, and I'm running into some trouble. I have a fairly simple project, and a very simple .nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<description>$description$</description>
</metadata>
</package>
When I run NuGet pack with this command line:
NuGet.exe pack mylibrary.csproj -Verbosity detailed -Properties Configuration=Debug
I get this error:
NuGet.CommandLineException: Unable to find '#(_OutputPathItem->'%(FullPath)mylibrary.dll')'. Make sure the project has been built.
at NuGet.Commands.ProjectFactory.BuildProject()
at NuGet.Commands.ProjectFactory.CreateBuilder(String basePath)
at NuGet.Commands.PackCommand.BuildFromProjectFile(String path)
at NuGet.Commands.PackCommand.BuildPackage(String path)
at NuGet.Commands.PackCommand.ExecuteCommand()
at NuGet.Commands.Command.Execute()
at NuGet.Program.Main(String[] args)
The output files are definitely in the bin\Debug folder, but NuGet is apparently not finding them.
This apparently only happens when the .csproj file's ToolsVersion is set to 3.5 or lower. Setting ToolsVersion to 4.0 resolves the problem.
It seems that MSBuild 3.5 returns the unexpanded property value when calling _project.GetPropertyValue("TargetPath") (ProjectFactory.cs ~296), where MSBuild 4.0 returns the expanded property value.
We had the same problem. adding
-Prop Platform=AnyCPU
to the command line made it work for us.
This apparently only happens when the .csproj file's ToolsVersion is set to 3.5 or lower. Setting ToolsVersion to 4.0 resolves the problem.
I have created an issue for the NuGet project team here: https://nuget.codeplex.com/workitem/4012
This could also have the same error if the .NET Framework version is set to 4.0 for the assembly.
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.