C# Universal App: add github repository as dependency - c#

we are developing a SDK. We want developers being able to integrate this SDK into their projects. I know that in Visual Studio it is possible to create a new project as class library to later integrate the .dll file.
But is there any other possibility than integrating the .dll or adding the classes manually? Something like a dependency on a Github repository maybe?
Thank you!

You have options:
Make a nuget for your SDK
Open source your SDK on GitHub, write a readme, let developer pull your repo and add to their project manually
(NOT RECOMMEND) make an extension and let developer download it. Or provide a .dll file for them to add to their projects.
The reason I dont recommend making an extension is: It makes CI and testing a lots harder. You cant easily install dependency extension on CI environment.

Related

How can I programmatically find a DLL restored by Nuget?

After a user does a dotnet add package <SomePackage>, the DLL will be installed to a path similar to:
C:\Users\USER\.nuget\packages\SomePackage\1.0.2\lib\netstandard2.0\SomePackage.dll
How can I find this path programmatically? I see there's some information in the obj/project.assets.json that I could parse, and also an interesting DependencyContextJsonReader class under the dotnet github organization.
However, there's no documentation or discussions about this that I can find, and I'm not sure if that's because I'm taking the wrong approach.
Some background:
I'm writing a tool that can scaffold C# projects. It uses a combination of the dotnet command line tools, and the Roslyn Workspace APIs to interact with the generated project. I'd now like to allow the user to install Nuget packages into this generated solution. I invoke dotnet add package SomePackage which works fine, and now I'd like to add the DLL to the Roslyn Project object using the AddReferences API, which requires the actual DLL.
I found a way to do this using the nuget client libraries.
Essentially, rather than shelling out to the dotnet add package command, I can use the NuGet client libraries directly from my application to install packages. I then have access to the full path via the PackagePathResolver.GetInstalledPath method.
Martin Björkström's post, Revisiting the NuGet v3 Libraries, goes into much more detail, and a fully working code sample from Martin is available in this gist.

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.

Roslyn with .NET core on linux: How can I load an external project?

First of all, I don't know much about Roslyn. I went through a few tutorials hot to generate code and how to parse a string containing code.
So far, everything is clear to me.
Here is my question:
I'm using dotnet core 1.0.1 on Linux.
I created a new project with some interfaces defining some properties.
What I want to do is to create a program in which I can load the project, run trough the interfaces (*.cs files) and generate some code.
My problem is, I don't know how to load/open a c# project with Roslyn.
The tutorials I found are using a windows environment. These samples doesn't work on my environment because there are some dependencies to MSBuild or Visual Studio. I read and tried some things about the AdhocWorkspace, but I didn't manage to open an existing solution this way.
Can anyone give me a hint how to start?
Is it possible to open/load a project (*.csproj) and run through all *.cs-files?
Thanks in advance.
Currently, there is no good way to open .Net projects using Roslyn on .Net Core.
See this issue on the Roslyn repo, where the recommended solution is to use code from the Omnisharp project.

Share code between multiple .NET Core projects

I would like to know how I can share c# source codes between two (or more) .NET Core projects (commandline projects!).
As far as I understand, I can not link to source files in different directories in xproj/project.json based projects. I noticed that it now seems to be recommended to create nuget packages for everything. But is it really necessary for me to setup a private repository and create a nuget package only to be able to share some common source units?
VS2015 contains a template for .NET Core library which may be suitable for building a shared lib. Is it possible to link this lib to a project without a nuget package?
.NET Core Library is an excellent solution for you.
Do it the same way as in standard C# solution - just create the project and reference this project or add a reference to DLL file.
You don't need to use a Nuget, for your own purpose. Nuget packages could be useful to distribute your dll outside.
Clarification:
I miss one point - I'm using VS2015, but I have included Class Library project in my solution, and I'm referencing by project, not by DLL file, and this works fine in ASP.Net Core.
I also have a different project, where referencing DLL file directly working fine, but this is the previous version of ASP.NET app (not Core) - seems NET Core doesn't support this way like as the previous version (yet?).
Sorry for confusing you, sometimes it's too many technologies ;)
So could you just include ClassLibrary project into solution with your project and refer it as a project?
I have achieved this by using source control to branch from my commonly used projects in each new solution, and again merging back to the master branch if I make any changes.
Alternatively, baring in mind that NuGet is only an archived collection of files, you could keep this NuGet package locally, or even create a Template for Visual Studio that has the common libraries by default.
There are a wide range of possibilities that are down to your preference, and current environment state (I.E: Able to setup Source Control, or a package repository).

How to install lastfm plugin for c# in .net framework

still newbie on C#.
i never installed a plugin, on my .net framework but i would like to build an application communicating with lastfm webservices.
so i went in the api lastfm page and i downloaded the lastfm c# plugin here.
now i have one zip with the plugin inside.
i don't know how to install it before to include it in my new project.
how can i do?
thank you in advance
If you only want the binaries and not the source then make sure to download the binaries download - otherwise you will need to build the source yourself.
Extract the zip file and inside you will find a dll called lastfm-sharp. I recommend moving this to a lib directory in your project. Then you need to add a reference to to your project which is explained here.

Categories

Resources