A csproj is referencing fo-dicom nuget package, where fo-dicom depends on fo-dicom.Desktop package (targeting netFrameowork45).
Preforming nuget restore for the project generates a warning
NU1701: Package 'fo-dicom.Desktop 4.0.8.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project
The nuspec for fo-dicom already identifies the target framework for the dependency.
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>fo-dicom</id>
<version>4.0.8.1</version>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="fo-dicom.Desktop" version="4.0.8.1" />
</group>
</dependencies>
</metadata>
</package>
The warning is only generated if nuget restore is performed using msbuild. Nuget restore from VS runs just fine. This warning in turn causes the msbuild to fail. I tried suppressing the warning but since the nuget dependency is not correctly loaded, the build fails anyway.
Why does it just occur with msbuild and not VS, and if there is a solution not to make it happen?
enter image description here
Related
I generate a NuGet that is is just a number of redist files that I want to use in one of my projects. If I install it in a C# or C++ projects, it works. But when I try to install it in a wixproj project and I get the following message:
Could not install package 'package-1.0.0'. You are trying to install this package into a project that targets 'Unsupported,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I generate the package through a TeamCity task (using NuGet 5.6.0). When trying to generate the package with a NuGet CLI 5.8.1, I get the following warning:
*WARNING: NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below:
Add a dependency group for native0.0 to the nuspec*
Looked at https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128, one of the solutions was trying a dependencies group targetFramework, (I used "native0.0") with no success. My nuspec is as follows:
<?xml version="1.0"?>
<package>
<metadata>
<id>package</id>
<version>1.0.0</version>
<authors>package</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>my package</description>
<copyright>© 2021 company, Inc</copyright>
<tags>native</tags>
</metadata>
<files>
<file src="downloads\Folder\win32.vs2017\file1.lib" target="lib\native\lib\win32.vs2017\" />
<file src="downloads\Folder\win32.vs2017\file1-debug.lib" target="lib\native\lib\win32.vs2017\" />
<file src="downloads\Folder\Include\**" target="lib\native\include\" />
<file src="build\package.props" target="build\native" />
</files>
</package>
And my props file
<Project>
<PropertyGroup>
<MyVersion>1.0.0</MyVersion>
</PropertyGroup>
</Project>
I can install other NuGet packages into wixprojects, so how I configure mine to work? Thanks.
OK I found it, the issue lies at the line
<file src="build\package.props" target="build\native" />
changing target to "build\" allows the NuGet to be loaded to any project type, included WixProj. Note that the NU5128 warning still exists though, but not an issue for me.
So embarrassing to ask something that is that well documented, but I am lost with an error which I get when I push my NuGet package:
System.AggregateException: One or more errors occurred. --->
System.Net.Http.HttpRequestException: Response status code does not
indicate success: 400 (The NuGet package contains an invalid .nuspec
file. The error encountered was: 'The target framework
Unsupported,Version=v0.0 is not supported.'. Correct the error and try again.).
I use the VSTS NuGet task to push the package to NuGet.org which delivers the aforesaid error. There's nothing customized, just the default settings:
In my nuspec file I have listed dependencies, simplified example:
<dependencies>
<group targetFramework="netcoreapp">
<dependency id="Microsoft.NETCore.App" version="2.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net462" />
<group targetFramework="netstandard1.0" />
</dependencies>
I assume my targetFramework is set incorrectly yet it is as per documentation NuGet Target Frameworks. I tried target frameworks like netstandard and netcoreapp2.0, they all cause the same problem.
My package files:
<files>
<file src="bin\MINE.Core.dll" target="lib\netcoreapp\MINE.Core.dll" />
<file src="bin\MINE.Core.NetFX.dll" target="lib\net462\MINE.Core.NetFX.dll" />
<file src="bin\MINE.Core.PCL.dll" target="lib\netstandard1.0\MINE.Core.PCL.dll" />
<file src="readme.core.txt" target="" />
</files>
If I leave the dependencies section empty (<dependencies />) everything works perfectly fine except for the package doesn't list the dependencies which I'd like to include. Also, If I don't use groups and therefore don't target frameworks, but list all dependent packages, everything works fine.
Any hint to solve this (probably silly) issue would be warmly appreciated.
The release definition isn't the problem, the build definition is. When the to be pushed NuGet package gets packed, ensure the correct NuGet version is being used.
For example, the deprecated NuGet Packager task in VSTS used to package uses internally an older version of NuGet. Therefore, replacing the VSTS task with the recommended NuGet task solves the problem and NuGet.org won't complain about incorrectly nuspec files anymore.
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.