XML comments in NuGet package - nuget

How do I publish the xml-comments with my assemblies in a NuGet Package so that consumers can see class / method comments?

You should be able to add the xml files to the NuGet package alongside your assemblies. Then these comments should be found by Visual Studio and displayed in its intellisense windows.
One example NuGet package that does this is AvalonEdit.

Related

How to read docs inside a NuGet package?

I have a library for Impinj (OctaneSDK). I can't seem to find the documentation. Using NuGet Package Explorer I DO see that there is a folder in the NuGet package called "Docs" that has a bunch of html file that looks like docs.
Is there a way to read docs packaged inside a NuGet package?
Edit - Using VS 2022 if that helps.

Nuget install failed: the package does not contain any assembly references or content files that are compatible with that framework

If I understand Scott Hanselman's post here correctly then I should be able to reference a .net standard library from a framework 4.7.2 solution.
I want to use Nuget to install such a reference.
I am using Azure DevOps Artifacts for the Nuget package. When I push my .net standard solution I can see that the package does create and that the Nuget install command is
Install-Package SBD.Standard -version 2.0.0-CI-etc
However when I try this at the PM console for my framework 4.7.2 project I get
Could not install package 'SBD.Standard 2.0.0-etc'. 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
moreover I do not see SBD.Standard as an avialable package in the relevant feed from within VS2019 -> Manage nuget packages for solution.
I think I need packages.config
I was able to create a new 4.7.2 project and add the nuget package that used .net standard 2.0 (but not 2.1)
When I tried to add the nuget package I got a dialog asking me to select the Nuget package manager format
so I chose Packages.config and that worked.
I am not sure I have it right. I solved my problem but am not sure whether this was it after all. SInce PackageReference is more recent it should work.
Some additional explanations for this issue.
There is an issue for NuGet restore when you using new SDK-based project type or PackageReference in the .net framework:
https://github.com/NuGet/Home/issues/5461
https://github.com/dotnet/sdk/issues/1755
When we use packages.config projects or non-SDK based project type, NuGet do not check compatibility during install/restore.
So, to resolve this issue, we need make sure the referenced project is an old style csproj or use packages.config.
That the reason why the packages.config works for you.
Hope this helps.

Adding references on Visual Studio Code from VSTS

I've got a private package stored on a feed in VSTS (Visual Studio Team Services). I want add it on a .NET Core project that I'm developing in Visual Studio Code.
Checking VSTS documentation, to add a package from private source it's necessary use the NuGet CLI, because .NET doesn't have support for private repositories (or at least I suppose it, because Microsoft recommend us to use NuGet CLI instead).
Using NuGet CLI, the command to add a package is NuGet install. But it downloads all packages, with .nupck, DLL files, a large, etc... (i.e., various XML files). And it doesn't add the necessary references to the project. Using .NET CLI to add the package, it adds the references in the .csproj file (project file), and it works as usual.
Is there a command that reproduces exactly the same behaviour like if we add package on Visual Studio, or Visual Code using .NET add package CLI?
If not, what I should do? Should I extract the DLL file and reference it manually in the .csproj file? If there's any update, how can I know it (in Visual Studio the NuGet UI shows me updates, but in Visual Studio Code, after adding a reference manually...)
There is no way to add a NuGet package into a project through Visual Studio Code nor through NuGet CLI.
And for the command nuget install (same function as nuget restore), it only downloads NuGet packages from the specified feed, but it does not make any changes for the project. You can also refer to the post How to install a NuGet package on the command line to a Visual Studio project.
The workarounds to add NuGet packages to project are as below:
Add packages in Visual Studio
You can open your project in Visual Studio, and then add NuGet packages through Visual Studio.
Manually change project file
If you have not Visual Studio installed. You can also manually change related files.
Such as add the private feed into nuget.config file, and then change .csproj file with the lines like:
<ItemGroup>
<PackageReference Include="xxx" Version="xxx" />
</ItemGroup>
Add packages by the dotnet add package command
You can also use dotnet add package command to add NuGet packages into your project:
dotnet add [<PROJECT>] package <PACKAGE_NAME> [-v|--version]

Download Nuget Packages Without VS/NuGet Package Manager

How can I download NuGet Packages outside of visual studio? so it can be used to create offline packages.
How to download NuGet Package without Visual Studio or Nuget Package Manager:
Search your desired package at NuGet Official Site.
Copy the end of the URL of the package page.
For Example: http://nuget.org/packages/EntityFramework => Package Name is "EntityFramework"
Enter the URL: http://packages.nuget.org/api/v1/package/{Package Name}
For Example: http://packages.nuget.org/api/v1/package/EntityFramework
You can download NuGet packages outside of Visual Studio using:
NuGet Package Explorer
NuGet Package Explorer is a ClickOnce application which allows
creating and exploring NuGet packages easily. After installing it, you
can double click on a .nupkg file to view the package content. You can
also load packages directly from the official NuGet feed.
Open a package from online feed:
And export the package to the desired location:
Install the NuGet command line program:
The NuGet command line may be installed onto a machine in a few possible ways.
Direct download of the executable from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe. The executable may be placed anywhere on the file system, and in most cases should be placed in a directory that is listed in the PATH environment variable.
Install the NuGet.CommandLine package from the NuGet Visual Studio client and either move nuget.exe to a common location or execute it in the context of your project.
Install the NuGet.CommandLine Chocolatey package using the Chocolatey client. More information on Chocolatey can be found at [http://chocolatey.org].
Then run nuget install package to download and install package in the current directory.
More about the NuGet command line program:
Command Line Reference
Chrome Plugin "NuTake" provides a direct download link.
Rename extension to .zip and extract
You can download nuget packages using - vnuget.org.
On this website you can also view content of nuget package - http://vnuget.org/packages/Microsoft.AspNet.Mvc/5.2.3.
Here are a few examples that can add to DeePak's answer:
This one downloads AutoMapper from NuGet.org
nuget.exe install AutoMapper -OutputDirectory c:\Temp\LotsOfPackages -Version 6.2.2
This one downloads MyCustomPackage from an internal TFS Nuget feed
nuget.exe install MyCustomPackage -OutputDirectory c:\Temp\LotsOfPackages -Source "http://tfs.myCompany.com:8080/tfs/TFSArea/_packaging/FeedName/nuget/v3/index.json" -Version 1.0.0.2
Notes
Keep in mind that the install command will get the package in question AND all its NuGet dependencies. So, be careful about just dumping this into the directory where you running. Thus, I added OutputDirectory to the command.
For internal Nuget packages/feeds, the Source URL is available via TFS. Go to your packages tab and find your specific feed URL. If it has any spaces that have been encoded with %20, you need to replace them with spaces.
CLI command reference
Copy packages from one NuGet feed to another

nuget package inside

I understand how to build dll nuget package
I would like to build a JavaScript nuget package of my own. I would like to learn how jQuery nuget package being constructed/installed by nuget.
How do I know how jQuery (or similar nuget package) nuget package being constructed? Especially I would like to know how these *.js being copied/ installed to specific folder (scripts) of a ASP.net MVC project
Thanks
NuGet uses a convention-over-configuration approach. This is what makes it easy to inject some files (images, code, javascript, etc) into a specific folder of a target Visual Studio project.
You can simply open a .nupkg file with any zip-utility (e.g. 7zip) and extract the archive to see its contents.
A NuGet package can have 3 folders: lib, content & tools.
Anything in the content folder will be injected into the target project using the same relative path to the project root as to the content folder of the nuget package.
More info here: http://docs.nuget.org/docs/creating-packages/package-conventions
Also with respect to how jQuery or other similar Javascript libraries are packaged, here are some pointers.
The list of public jQuery/jQuery plugins that have been "NuGetified" can be see here http://nuget.org/packages?q=jquery The jQuery NuGet package page http://nuget.org/packages/jQuery has a note saying that it is maintained by the NuGet Community Packages project.
If you go to the CodePlex project at http://nugetpackages.codeplex.com/ and browse the source code, you'll find it contains a couple of sub projects. These are NuGet package projects for the respective open source (mainly Javascript) projects.
You will notice that they simply include the relevant pure Javascript packages, e.g. jquery-1.8.3.js, jquery-1.8.3.min.js, etc. in the Content/Scripts path.