How to view the source code from downloaded packages in Visual Studio - c#

I am working on TOTP and have downloaded a package in Visual Studio 2013 by:
Tools --> Library Package Manager --> Manage Nuget Package Packages
However there seems to be no documentation for this downloaded package. So is there anyway I can view all the code and implementation in this package in order for me to know how to use the classes in the package?
After including the package:
using Albireo.Otp;
using Albireo.Base32;
I can go to the definition from the classes within the package by
right clicking the class --> Go To Definition.
But is there a way to view all the files and implementations from this downloaded package?

For that specific library, the source is at https://github.com/kappa7194/otp
To answer your question, You can either use Assembly Explorer or Object Browser in VS.
Go to Solution Explorer -> Open references --> Right click on the referenced library
Im using VS 2016 not sure if VS 2013 has that feature.

Related

Visual Studio References versus Dependencies, Assemblies, and Packages

In Visual Studio 2019, in a .NET Framework (not .NET Core) console application project, how do I add NuGet packages so that they show up in the "Packages" section of a "Dependencies" instead of just as "References" with other assemblies? That is, I'd like to get this (which is from a Microsoft example app)...
... instead of this (which is what I have in my app after adding Newtonsoft.Json and MSAL using the NuGet package manager tool) ...
Notice, in my app, there is a "References" section but no "Dependencies" section, and the packages are mashed in with the other references. The only thing I could find to try was to right-click on References then select the "Migrate packages.config to PackagesReference", which yielded this ...
(StackOverflow bug? When I try to add a third image, it shows some totally random image in a different language. What the picture shows, though I can't get it to add, is the same "References" section except that the Json and MSAL references have a different icon.)
... which is closer (the packages are now "references", I guess) but there is still no Dependencies section with partitioned Assemblies and Packages subsections.
Assuming the MS example is doing it "right" and that I am doing it "wrong", how do I get from where I am to where they are?
Ah! I think I found the answer at Visual Studio 2017 References vs Dependencies. It appears I need to use a different project type if I want the newer style project file.

Install a Nuget package in Visual Studio Code for Unity

I want to save my level files to .json files in the Unity assets folder. Due to the limited features of JsonUtility I want to use Json.NET. I use Linux so I can't access Visual Studio and use Visual Studio Code instead. I wanted to add the package to my Unity project and took the guide from here
Install a Nuget package in Visual Studio Code
First I used this command in the terminal
dotnet add package Newtonsoft.Json
but I got this error
error: Error while adding package 'Newtonsoft.Json' to project
'/.../myUnityProject/Assembly-CSharp.csproj'. The project does not
support adding package references through the add package command.
After that I installed the Nuget extension and installed Newtonsoft.Json#12.0.2 to my project. I was prompted to run dotnet restore to be able to use the package.
After doing so I got this error
MSBUILD : error MSB1011: Specify which project or solution file to use
because this folder contains more than one project or solution file.
So what is the correct way to install third party tools using Visual Studio Code with Unity?
Unfortunately, due to Unity3D's heavy-handed manipulation of SLN files, it is not possible to use NuGet packages within a Unity project.
In the case of Newtonsoft.Json, it is available on the Asset Store for free, you can install from there.
Other packages can be used manually by downloading the .nupkg file from the NuGet website, extracting the DLLs for .NET 4.x, and placing them in your project's Assets folder.
If the library contains native code, you might not be able to use it on every platform, however. But if you get per-platform DLLs, you can set them up in the Unity editor to only be used for the correct platforms.

Can I configure Visual Studio to allow debug step into NuGet packages?

I am using a NuGet package in an internal project. (The NuGet package is EPPlus, fwiw.)
Is there a way to configure Visual Studio to allow debug step into the NuGet package?
I'm using VS Community Edition 2019 (v16.2.0), and the EPPlus NuGet package (v4.5.3.2)
I've found a number of posts about how to clonethe NuGet package and then either rebuild it from scratch, or include it in an existing VS project, and then trace into it, but that is not generally useful. (And can be a rathole unless the NuGet project is well maintained and well designed.)
I'm looking for something closer to how debug symbol files can be installed to allow stepping into Windows API code.
Is there something similar for refernced NuGet packages? Is it as simple as asking the NuGet package maintainer to checking the pdb files along with their source?

Nuget Packages are missing in Visual Studio

I have been using xamarin studio, it works fine when I download a sample project from mvvmcross. It compiles and deploys the device perfectly.
But when I open the project in the visual studio, there are a lot of missing packages for some reasons. Is there a way of handling ? I am using Nuget 2.8 in Visual studio 2013
When I open Nuget as follows, there is a button to restore the missing packages. I clicked on it.
Then it is attempting to download the missing packages, and then it realizes there are dependencies as follows:
Then I am attempting to download the dependency manually as follows but it shows the packages has already downloaded but I am still seeing the missing packages in the solution, nothing is affected.
Therefore I am getting hundreds of errors as follows:
When I take a look at the property of missing packages, I see as follows
You should update your NuGet Package Manager extension in Visual Studio and then try restoring the packages again.
The restore error MvvmCross.Binding already has a dependency defined for MvvmCross.Core is caused by an old version of the NuGet package manager extension not recognising the newer target frameworks that the MvvmCross.Binding NuGet package is using in its group dependencies. This bug has been fixed in a newer version of the NuGet Package Manager.
If you search for the 'already has a dependency defined' error message you will find several cases of this, such as this StackOverflow question, for example:
Can not install NuGet package
Right click on the solution in solution explorer and choose 'restore nuget packages'

Adding a NuGet package to a project without Visual Studio

I'm trying to automate adding NuGet packages to project on a remote server that doesn't have Visual Studio (nor any build servers) installed. I do know how to use NuGet.exe from my C# code, but this executable only downloads packages and doesn't do any other required work (adding references, executing ps scripts etc). What do I do in order to fully install a package?
Note: I don't need to update a package for my own app, I need to add a package to an arbitrary .csproj file on the server. I'm building a Web-based .Net IDE, and need my users to be able to add packages to their projects.
I see two possibilities: one is using some kind of functionality not present in NuGet.exe, but ratherin some other library (maybe a VS addin), but I don't know where to look for it. The other is to simulate some kind of NuGet Powershell console and send commands to it, but again, I don't know how to do that.
You might want to consider SharpDevelop.
Installing NuGet Packages outside of Visual Studio an article about the functionality you are trying to achieve (written by Matt Ward, one of the project contributors) says:
Since NuGet uses PowerShell the simplest approach was to extend the
existing PowerShell cmdlets included with SharpDevelop. Now you can
write a few lines of PowerShell script to install a NuGet package into
a project that has never had a NuGet package before, have the project
itself updated and any package PowerShell scripts run. All this from
the command line without Visual Studio open.
Just to add an additional answer in-line with Alex's post about SharpDevelop, you have a couple different options.
Use Nuget.exe (Related Blog post)
NuGet Addin for MonoDevelop and Xamarin Studio (see GitHub)
ASP.NET Pages using WebMatrix (see this video)
All of this info is from the Nuget FAQ.

Categories