Where to find documentation of all supported nuget framework names - nuget

When building a nuget package with folder lib\i-made-this-up\, nuget Pack will output the following message:
The folder 'i-made-this-up' under 'lib' is not recognized
as a valid framework name or a supported culture identifier.
Folder lib\net40-wpf\ does not output this message so apparently it is a valid framework name. My questions is: how is net40-wpf defined? I expected it to be on this page but it isn't:
https://docs.nuget.org/create/enforced-package-conventions
Do I miss something? Or is there a better source of documentation?

You have the main documentation link for the NuGet target frameworks:
https://docs.nuget.org/create/enforced-package-conventions
Unfortunately it is out of date and is missing newer target frameworks that NuGet supports.
A few more target frameworks are mentioned in the following blog post:
http://blog.nuget.org/20150729/Introducing-nuget-uwp.html
Currently the best place is the NuGet source code. For NuGet v2 the known target frameworks are defined in the VersionUtility class:
https://github.com/NuGet/NuGet2/blob/2.8.6/src/Core/Utility/VersionUtility.cs
For NuGet 3 the list of target frameworks is defined in the FrameworkConstants class:
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Frameworks/FrameworkConstants.cs
NuGet 3 also has a set of runtime identifiers which are defined in a NuGet package so it is extensible.

Related

Trying to install package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references

I used NuGet Package Explorer (for the first time) to create a .nupkg to share with others. I have one DLL that targets NetStandardLibrary 2.0,
But when I try to add the package I receive the following error:
Could not install package 'iCANMVCSDK 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', 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 thought that by using NETStandard 2.0 it could be installed in any .NET app. I also tried adding additional assemblies:
I rebuild, repackage, and I still get the same error. What am I missing?
I tried editing the project file like this:
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
When I try to build after adding net472, I receive the following error:
The type or namespace name 'Http' does not exist in the namespace 'System.Net'
What really makes no sense to me is that I can add the DLL directly into the project (the one that targes NET 4.72) and it works as expected. The problem is when attempting to install it as a NuGet package.

Accessing local built DLL in Visual Studio Code project

So i got roslyn built on my Mac OSX in a folder
dotnet/roslyn/Binaries/Debug/csccore
Here is the list of files I get
CommonNetCoreReferences_DoNotUse.dll*
CommonNetCoreReferences_DoNotUse.pdb*
Microsoft.CodeAnalysis.CSharp.dll*
Microsoft.CodeAnalysis.CSharp.pdb*
Microsoft.CodeAnalysis.CSharp.xml*
Microsoft.CodeAnalysis.dll*
Microsoft.CodeAnalysis.pdb*
Microsoft.CodeAnalysis.xml*
Microsoft.DiaSymReader.Native.amd64.dll*
Microsoft.DiaSymReader.Native.x86.dll*
Microsoft.Win32.Primitives.dll*
Microsoft.Win32.Registry.dll*
System.AppContext.dll*
System.Collections.Concurrent.dll*
System.Collections.Immutable.dll*
System.Collections.dll*
System.ComponentModel.DataAnnotations.dll*
System.Console.dll*
System.Core.dll*
System.Diagnostics.Debug.dll*
System.Diagnostics.FileVersionInfo.dll*
System.Diagnostics.Process.dll*
System.Diagnostics.StackTrace.dll*
System.Diagnostics.Tools.dll*
System.Diagnostics.Tracing.dll*
System.Dynamic.Runtime.dll*
System.Globalization.Calendars.dll*
System.Globalization.Native.dylib*
System.Globalization.dll*
System.IO.Compression.Native.dylib*
System.IO.Compression.dll*
System.IO.FileSystem.Primitives.dll*
System.IO.FileSystem.Watcher.dll*
System.IO.FileSystem.dll*
System.IO.Pipes.dll*
System.IO.dll*
System.Linq.Expressions.dll*
System.Linq.dll*
System.Native.a*
System.Native.dylib*
System.Net.Http.Native.dylib*
System.Net.NameResolution.dll*
System.Net.Primitives.dll*
System.Net.Sockets.dll*
System.Net.dll*
System.Numerics.dll*
System.ObjectModel.dll*
System.Private.CoreLib.dll*
System.Private.CoreLib.ni.dll*
System.Private.Uri.dll*
System.Reflection.Emit.ILGeneration.dll*
System.Reflection.Emit.Lightweight.dll*
System.Reflection.Emit.dll*
System.Reflection.Extensions.dll*
System.Reflection.Metadata.dll*
System.Reflection.Primitives.dll*
System.Reflection.TypeExtensions.dll*
System.Reflection.dll*
System.Resources.ResourceManager.dll*
System.Runtime.Extensions.dll*
System.Runtime.Handles.dll*
System.Runtime.InteropServices.RuntimeInformation.dll*
System.Runtime.InteropServices.dll*
System.Runtime.Loader.dll*
System.Runtime.Numerics.dll*
System.Runtime.Serialization.dll*
System.Runtime.dll*
System.Security.Claims.dll*
System.Security.Cryptography.Algorithms.dll*
System.Security.Cryptography.Cng.dll*
System.Security.Cryptography.Csp.dll*
System.Security.Cryptography.Encoding.dll*
System.Security.Cryptography.Native.dylib*
System.Security.Cryptography.OpenSsl.dll*
System.Security.Cryptography.Primitives.dll*
System.Security.Cryptography.X509Certificates.dll*
System.Security.Principal.Windows.dll*
System.Security.Principal.dll*
System.ServiceModel.Web.dll*
System.ServiceModel.dll*
System.Text.Encoding.CodePages.dll*
System.Text.Encoding.Extensions.dll*
System.Text.Encoding.dll*
System.Text.RegularExpressions.dll*
System.Threading.Overlapped.dll*
System.Threading.Tasks.Extensions.dll*
System.Threading.Tasks.Parallel.dll*
System.Threading.Tasks.dll*
System.Threading.Thread.dll*
System.Threading.ThreadPool.dll*
System.Threading.dll*
System.Windows.dll*
System.Xml.Linq.dll*
System.Xml.ReaderWriter.dll*
System.Xml.Serialization.dll*
System.Xml.XDocument.dll*
System.Xml.XPath.XDocument.dll*
System.Xml.XPath.dll*
System.Xml.XmlDocument.dll*
System.Xml.dll*
System.dll*
corerun*
csc*
csc.cmd
csc.exe*
csc.exe.config*
csc.pdb*
csc.xml*
libclrjit.dylib*
libcoreclr.dylib*
libdbgshim.dylib*
libmscordaccore.dylib*
libmscordbi.dylib*
libsos.dylib*
mscorlib.dll*
mscorlib.ni.dll*
pbcopy
sosdocsunix.txt*
Now how do i get it using in Visual Studio Code?
How do i refer local DLLs?
.Net Core projects can reference dependencies in two ways:
NuGet packages
project-to-project references
Notably, directly referencing assemblies is missing.
This means you have two options:
Build Roslyn NuGet packages, put them into a directory and configure that directory as a package source using NuGet.Config for your .Net Core project. Then reference the packages normally.
Make the relevant Roslyn projects part of your solution using global.json and then reference them as projects using "target": "project" instead of specifying a version of the package in project.json.

How do I reference a UWP+NET46 portable library from a .NET 4.6 console application?

I have a portable class library project that targets .NET 4.6 and Universal Windows Platform. This class library contains just one class with the following line of code in its constructor:
Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
Now I create a new .NET 4.6 console application project in the same solution and add a project reference to the portable class library. Calling the method that houses the above line of code results in the following exception at runtime:
Could not load file or assembly 'System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
What am I doing wrong here? There are no compile-time errors or warnings.
Things I have tried: add missing(?) NuGet package manually
It seems that System.IO.FileSystem is a library delivered via NuGet, as part of the Microsoft.NETCore mega-package. Okay, perhaps I need to explicitly add this package to any project that uses my portable class library. I attempt to do so.
Could not install package 'Microsoft.NETCore.Platforms 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', 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.
No luck with this approach.
Things I have tried: create a project.json file
While there is no clear info on the web, I read a few tidbits about a new project.json based NuGet harness or build system. Just to experiment, I created the following project.json file in my console application project:
{
"dependencies": {
},
"frameworks": {
"net46": { }
},
"runtimes": {
"win-anycpu": { }
}
}
It works! The runtime error goes away! However, I soon found that this was either not the right solution or not a complete solution. I started writing some code to read configuration section values, which involved making use of the IConfigurationSectionHandler interface, and got the following compile-time error:
error CS0246: The type or namespace name 'IConfigurationSectionHandler' could not be found (are you missing a using directive or an assembly reference?)
This interface is part of the System assembly. I see a reference to this assembly, but it has a yellow exclamation mark icon, and a warning appears in the warnings window:
The referenced component 'System' could not be found.
This is where I ran out of ideas. Am I missing something totally obvious?
I have found the solution. My initial attempt was to install the Microsoft.NETCore package into the console application, resulting in the error shown in my original post.
However, if I install only the narrowly-scoped packages, e.g. System.IO.FileSystem, then I achieve success and the application works correctly. Apparently there is something special about the Microsoft.NETCore "master package" that prevents it from correctly installing into dependent projects.

Type or Namespace "Dapper" could not be found: in Hangfire Source code in Visual Studios?

I've imported the Hangfire Source code from Github into my existing VS 2013 solution. When I attempted to build all projects within my solution, I get several errors:
Error 6 The type or namespace name 'Dapper' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Jerry_Dev\Documents\GitHub\Hangfire\src\Hangfire.SqlServer\SqlServerDistributedLock.cs 20 7 Hangfire.SqlServer
In Package Manager, when I do: "Install-Package Dapper", it says
'Dapper 1.38' already installed.
Hangfire.SqlServer already has a reference to 'Dapper 1.38'.
I see Dapper dot net installed in my Manage Nuget Packages Window in my Hangfire.SqlServer project
We don't store the packages folder under source control to reduce the source code size. Hangfire uses Automatic Package Restore in Visual Studio instead of obsolete MSBuild-integrated package restore. The Automatic Restore downloads missing packages automatically on each build, but it works only with NuGet ≥ 2.7, so you have the following options:
Update NuGet to the latest version
Please see the official docs.
Run the build script
Go to the root Hangfire directory and run the build.bat file. It will automatically restore all the missing packages.

Avoid dependency of a pure code snippet package

Example:
Nuget package A is a set of code snippets (it does not contain an assembly).
Nuget package B is a normal assembly and it is using package A - just for internal means.
Question: What can I do, to avoid, that package A is also installed, when somone installes package B?
Found something in documentation of nuget:
Starting from version 2.7, the pack command will ignore entries in the packages.config file which have an attribute developmentDependency set to true and will not include that package as a dependency in the created package. For example, consider the following packages.config file in the source project
That seems to solve the problem.