How do I import a Github library to my project? - c#

I was thinking about making a simple youtube downloading program in C# Forms. I found this library and decided to use it, although I am having some trouble importing it into my project.
I tried googling "how to import libraries to visual studio c#" but I only found c++ tutorials and the only C# I could find were outdated.
I downloaded the .zip file from github but there was no files which the VS importer could use.
I am sorry if this question is simple, but I started using Visual Studio yesterday.

You can use NuGet to import that library:
Install-Package VideoLibrary -Version 2.0.3
More info: https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio

The easiest way to incorporate libraries into your projects with Visual Studio is as NuGet Packages. Nuget packages are essentially just zip files containing the libraries themselves, meta-data, stuff to help with debugging and potentially other stuff the library might need.
Many projects hosted on GitHub will have a Nuget Package available. Visual Studio will be already set up to search for packages from the most common sources, such as Nuget.org , but sometimes you may need to add an additional package source a.k.a. "feed" to your solution. This can be done by adding a Nuget.config file in your solution directory. More info on that here.
In Visual Studio there are multiple ways to interact with Nuget. You can use Nuget packet manager GUI, which can be accessed by right-clicking on your Project or Solution in the Solution Explorer and clicking Manage NugGet Packages, or you can use the command line interface through PowerShell or the Package Manager Console in Visual Studio.

Related

SQLite in WPF application

I'm trying to use a SQLite database file inside my WPF application.
I tried searching for a proper library that wraps the entire SQLite library.
I found the following SQLite library which allows a perfect functionality that suites me.
The problem is building it.
I tried adding it in a Visual Studio as a project and compile it to get a dll file.
That didn't work so much well because of dependencies missing inside the project and sub-projects.
If anyone anticipated or experienced any hard time with this library, I would really use the help and of course appreciate it alot.
Thanks heads up :)
You should install it as a nuget package. Right click on your project -> Manage Nuget Packages -> find SQLite.Net-PCL. You don't need source code for this, only released package and that is exactly what nuget will download for you and add as a dependency.
You can also install the package with Visual Studio's Package Manager Console:
Install-Package SQLite.Net-PCL
If you want to have source code, this library is contained inside a single file, so you can just copy SQLite.cs to your project and it will work.

Cannot find Math.net in References after installing package with NuGet in Visual Studio 2015

I'm trying to use the Math.net extension for Visual Studio 2015 with C#.
Unfortunately, after installing the package with
PM> Install-Package MathNet.Numerics -Version 3.20.0
I cannot find it anywhere in the Add References menu. I searched Assemblies->Framework and Assemblies->Extensions and COM, but it's not there
I wouldn't mind the just adding the DLL to my project, but I cannot find the DLL anywhere on https://numerics.mathdotnet.com , all the links take me to the NuGet package manager.
Also, do I need to distribute the MathNet dll with my application if I add it through the package manager, or does it build internally with the application?
Sorry, new to .net library management
I see that when I ran the command line, it added a packages folder to my project folder. Which has a few different versions of the library per .net version. Which I could browse to with Add Reference->Browse->Browse
Is this the correct way about adding a third party library?

How to see source code from github in Visual Studio IDE, but compile with dlls from Nuget?

Nowadays there's a lot of great open source packages and frameworks for all sorts of uses. Let's take for example, ASP.NET Core MVC and Newtonsoft.Json.
Those are shipped in Nuget packages, which are stripped of the source code.
I think many of you can remember a lot of situations in which one would like to see the source code freely available on GitHub (to help debugguing some issue), but was forced to do one of the following:
Be lazy and just forget about it, or continue debugging your issue with a popular library treating it more like a "black box";
Go to the browser, type github.com and search the source code without the mighty advises of the Visual Studio IDE;
Spend 5 minutes, clone the repository to the local drive and look at it with IDE;
Spend even more time while compiling the source code, deinstalling all of the nuget packages of interest from your projects and instead, hooking up directly to all of the freshly compiled assemblies (which are not always one-to-one to Nuget package).
This last option is the most viable, but you're left with a lot of time spent and you can't just push this to your repository or deploy the compiled code anymore. Other developers won't find those relative paths to the dlls and customers may end up with wrong versions of nuget packages baked in the deployment package.
Is there a fifth option which has all the pros of the fourth, but none of the cons? I imagine this being done by an IDE in an isolated fasion, i.e. no modification to my .csproj and package.config files, but the "Go to definition" & "Find all references" features and debugging should work as if I'm hooked up to the real stuff.
Yes, I'm pretty lazy.
Please pack the package as symbols package and then put the PackageName.Symbols.nupkg file with the ProjectName.nupkg file on the same package server after you downloading the package source code. I’m using following steps to debug my NuGet package source code in Visual Studio IDE.
Create my NuGet package project and implement the function that I want. In your situation, you just need to download the package source code from Github.com.
Build the project in your Visual Studio IDE, it will general a dll file and a pdb file in bin\Debug folder.
Download NuGet.exe and run this command to pack the source code project to package:
NuGet Pack MyProject.csproj -Symbols
There will generate two files, one is ProjectName.symbols.nupkg and another is ProjectName.nupkg. Upload these files to your NuGet Server. And you also can put them on your local driver.
Add your NuGet Server into your Visual Studio IDE through Tools -> Options -> Package Manager Console -> Package Source.
Open your project and install the package from the added package source.
Right-click your solution, choose Properties -> Common properties -> Debug Source Files, add the path where the PackageName.Symbols.nupkg file with the ProjectName.nupkg file stored on your local machine.
Now when your start debug your project and press F11 step into one function in your installed package, it will step into then package source code.
as mentioned in one of the comments, there is a VS extension that does this:
Nuget Reference Switcher (select one that matches your VS version to install), for more info, you can read its wiki on github.
here is what I usually do:
git clone the source repository
add the open sourced .sln/.csproj to your own solution:
run nuget reference switcher extension
This is equivalent to your step 4, but a lot less work since the heavy lifting is done by the extension.

The namespace RDotNet could not be found

I'm trying to use R with C#. I'm using Unity and MonoDevelop on the C# side and I've R version 3.2.1. I've tried my best to follow instructions here: http://jmp75.github.io/rdotnet/getting_started/
But I'm stuck. Here's what I've done
download nuget.exe, put it in a folder already in PATH.
open CMD.exe
run nuget install R.NET.Community
If I try to reinstall R.NET.Community with the same command above, I got the message that it is already installed (which is good I guess).
My question : what now? I tried to run the RDotNet namespace, but it's not recognized. Obviously I need to set up something else, but I do not know where and what. Any lead would be appreciated!
I wouldn't expect just running the nuget install to add a reference into your project - the nuget installer is basically just downloading the package for you.
You could manually add a reference in your project to the relevant assembly file (.dll) that has been downloaded. However, it would be better to use a package manager within MonoDevelop. If you're using MonoDevelop 3.x or 4.5, you should use the NuGet MonoDevelop add-in and use that to manage the NuGet packages for your project. MonoDevelop 5.x has a NuGet package manager built in, apparently.

Nuget version not correct?

I have a project that i cannot compile. When i try to do so I get the following error:
The 'Microsoft.Bcl.Build 1.0.14' package requires NuGet client version '2.8.1' or above, but the current NuGet version is '2.7.41115.310'.
Normally this would be simple. After searching I found this guide:
http://www.daimto.com/package-requires-nuget-client-version-x/
That explains how I can upgrade my Nuget client version. However, when i follow those steps, I find that I am already using the latest version of Nuget: 2.8.5
For some reason however, Visual Studio 2013 Ultimate is using an older version, and I don't understand why.
My install of Visual Studio Ultimate 2013 is a fresh install, after unninstalling Visual Studio for Web Express 2012. The previous version was giving me a considerable amount of problems and so I deleted it and moved on to 2013. I wonder if some cofig files were passed through, but I cant be sure.
How can I fix this problem?
From Tools → Extensions and Updates → Installed, uninstall “NuGet Package Manager” and install it again.
So, after searching around I found no answers, so I decided to look into the project folders. It happens that I have the main version of NuGet.exe, 2.8.5 in main folder, but the project was nowhere near that main folder.
This way, when I downloaded the project it simply used the NuGet version pulled from TFS (or so I assume), and that was the problem - that verison was Nuget.exe 2.7.4.
After replacing the "Nuget.exe" files (found in /.nuget folder of the project) the project finally compiled and everythign started working again.
You can also try update Nuget Package Manager directly from Tools > Extensions and Updates
In my case, a pending update of Visual Studio fixed the nuget version.
The update was the "Update 5" for VisualStudio 2013.
The update was listed under the menu Tools → Extensions and Updates, on the tab Updates.
I was getting this error from a recently cloned branch, but (in contrast to the above solution) found that my Nuget version in the project directory was the same as that in my solution directory.
I solved this by right clicking on the solution and Managing Nuget Packages for the solution. The Nuget dialog that popped up said that packages were missing and asked me to restore them. Once downloaded, the project built successfully.
I had the same issue when trying to install System.Net.Http and it said the nuget version needed to be version 3.0 or above. I tried few things but in the end, used Tools and Manage Nuget Packages and did a search and tried to install it from there when it said exactly the same thing - wrong version of nuget, but it popped up with an upgrade Nuget button too!
Hope this helps someone
Simply reinstall nuget in visual studio

Categories

Resources