All Projects → TanukiSharp → MinimalNugetServer

TanukiSharp / MinimalNugetServer

Licence: MIT license
A minimal but cross-platform implementation of a NuGet server, running on .NET Core

Programming Languages

C#
18002 projects
shell
77523 projects

Projects that are alternatives of or similar to MinimalNugetServer

Json
A really simple C# JSON Parser in 350 lines
Stars: ✭ 202 (+339.13%)
Mutual labels:  nuget
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+441.3%)
Mutual labels:  nuget
junit.testlogger
JUnit test logger for vstest platform
Stars: ✭ 61 (+32.61%)
Mutual labels:  nuget
Linqpad.queryplanvisualizer
SQL Server and PostgreSQL query execution plan visualizer for LINQPad
Stars: ✭ 209 (+354.35%)
Mutual labels:  nuget
Templates
.NET project templates with batteries included, providing the minimum amount of code required to get you going faster.
Stars: ✭ 2,864 (+6126.09%)
Mutual labels:  nuget
vscode-npm-gui
vscode nuget package manager gui https://marketplace.visualstudio.com/items?itemName=aliasadidev.nugetpackagemanagergui
Stars: ✭ 36 (-21.74%)
Mutual labels:  nuget
Sleet
A static nuget feed generator for Azure Storage, AWS S3, and more.
Stars: ✭ 201 (+336.96%)
Mutual labels:  nuget
Xamarin.Forms.MultiSelectListView
☑️ Select multiple rows in a listview with xamarin.forms
Stars: ✭ 61 (+32.61%)
Mutual labels:  nuget
Sharpcaster
Chromecast C# SDK for Windows, Windows Phone, .NET 4.5.1, Xamarin.iOS and Xamarin.Android platforms.
Stars: ✭ 245 (+432.61%)
Mutual labels:  nuget
bUnit
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
Stars: ✭ 857 (+1763.04%)
Mutual labels:  nuget
Typeahead
Typeahead control for Blazor applications
Stars: ✭ 226 (+391.3%)
Mutual labels:  nuget
Mond
A scripting language for .NET Core
Stars: ✭ 237 (+415.22%)
Mutual labels:  nuget
Community.VisualStudio.Toolkit
A community toolkit for writing Visual Studio extensions
Stars: ✭ 23 (-50%)
Mutual labels:  nuget
Watsontcp
WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
Stars: ✭ 209 (+354.35%)
Mutual labels:  nuget
Krypton-Toolkit-Suite-Extended-NET-5.470
An extension to the Krypton Toolkit suite of controls for .NET framework 4.7
Stars: ✭ 51 (+10.87%)
Mutual labels:  nuget
Log4net.elasticsearch
log4net appender to ElasticSearch
Stars: ✭ 202 (+339.13%)
Mutual labels:  nuget
yavdb
Yet Another Vulnerability Database
Stars: ✭ 14 (-69.57%)
Mutual labels:  nuget
mathcore
Advanced .NET math library (.NET Standard).
Stars: ✭ 24 (-47.83%)
Mutual labels:  nuget
c4sharp
C4Sharp (C4S) is a .net library for building C4 Model diagrams.
Stars: ✭ 159 (+245.65%)
Mutual labels:  nuget
GenuineChannels
Collection of custom .NET Remoting channels
Stars: ✭ 29 (-36.96%)
Mutual labels:  nuget

Overview

This is a minimal implementation of a NuGet server.

It supports API v2 for most of usages with dotnet restore and Visual Studio package manager (search packages, find package versions, etc...), and it also supports v3 with dotnet restore only, no Visual Studio support for v3 APIs.

It basically works the same as if you were using a shared folder as package source. Thus, all .nupkg files in the root directory (and sub directories) are treated as a flat collection of package file.

This server provides us a standard way to access our internally developped packages.

Note before getting started

Since it is developped for .NET Core runtime, it is possible to build and run it virtually everywhere .NET Core runs.

However, all the following instructions are written considering a Windows and Linux workstation to build and generate a publishable, and Linux machine as an hosting server.

Also, please understand that this is a very simple and naive implementation, that could be suited for individuals or small organizations.

See the section Future works at the bottom of this document for more details.

The problem it solves

We need to self-host our internally developped packages, and prior this implementation, we were using a samba shared folder, hosted on a Linux machine.

The main problem it solves is that we can finally get rid of the the samba shared folder, which has never worked correctly and has always been a pain in the butt, even with Windows clients, and now we have a very standard and very reliable way to access our packages through an HTTP interface.

It seems for the moment the only available implementations of NuGet server is made for Windows only, but we need to host one on a Linux machine, so .NET Core is the perfect candidate runtime for that.

How to use it

Build

First, you must make sure you have .NET Core SDK 2.0.

In a terminal, go to the directory that contains the .csproj file and run the dotnet build command.

When you build for the first time, you may get the following error:

error CS0103: The name 'GitCommitInfo' does not exist in the current context

This is because a file is generated before compilation, and is not taken into account for the build. Just run dotnet build again and the it will finally compile correctly.

Deploy

For the impatients

cd MinimalNugetServer/scripts

# === on Windows ===
#make_publishable.bat

# === on Linux ===
#./make_publishable.sh

cd ../bin/release/netcoreapp2.0/publish/
# ===== edit the configuration.json file
dotnet MinimalNugetServer.dll

Detailed explanations

For all .sh scripts you will need to run on Linux, remember that they must first be made executable by running the command chmod +x <script>. The .sh files are committed with 755 rights in the git repository.

You can use the dotnet run command to run it directly from the directory that contains the .csproj file, but you would first have to modify the default configuration.json file provided.

In the scripts directory, you can run the script make_publishable, either the .bat for Windows or the .sh for Linux (never tested on Mac).

This will make everything ready in the directory bin/release/netcoreapp2.0/publish for you to deploy to a hosting server.

Once deployed where you want to run it, execute the command ./start.sh. This will run the server and make it look for the configuration.json file.

You can also run the server giving it a specific configuration file, this way: ./start.sh <configfile>. This is very useful when you want to host different package repositories.

The start.sh script runs the server detached from the terminal that ran it, redirects all outputs to a log file, and creates a run.pid file to track the process in order to stop it more easily if needed.

Remember that if you start several instances of the server, the run.pid file of the previous instance will be overwritten.

To check the log, run the command tail -f logs/<date>/log_<time>.txt file. This will display the last few lines of the log file, and also prints the new comming log entries (watch mode).

Configuration

The configuration file is pretty much straightforward and self explanatory.

{
  "server": {
    "url": "http://*:4356"
  },
  "nuget": {
    "packages": "/absolute/path/to/packages/folder",
    "makeReadonly": true
  },
  "cache": {
    "type": "NoCacheLoadAll",
    "duration": -1
  }
}

The server section holds the configuration related to the hosting server, and for now it contains only the url key, which is where the server will listen for requests. You may not need to change this unless you want to change the port. The port has been chosen purely randomly, we call this very advanced technique to throw a shoe on the keyboard.

The nuget section holds the configuration related to the NuGet things: - packages: directory where your packages are stored. - makeReadonly: if true, will call chmod 555 <filename> on each .nupkg each time they are processed. (ignored on Windows)

The cache section contains the cache strategy settings:

  • type: the type of cache strategy.
    • NoCacheLoadAll: does not use cache, all files are loaded in memory. (this is the default, and the fallback if setting is incorrect)
    • NoCacheLoadNothing: does not use cache, never prefetch files and load from file each time a file is requested.
    • Cache: does not fetch any file, but caches them when they are first accessed.
  • duration: used only by the Cache strategy, sets the sliding expiration time of each cache entries, in secconds.

Runtime

On the client side, you have to add the following package source to your nuget.config file, either manually or through Visual Studio:

  • http://<host>:4356/v2/ to use the v2 API (good support)
  • http://<host>:4356/v3/ to use the v3 API (dotnet restore only)

Warning: the terminating slash symbol (/) in the URL is very important, do not omit it!

From the server point of view, it does not support publishing APIs, as a shared folder would. To add new packages, you have to copy them manually to the packages directory on your hosting machine.

The server uses a FileSystemWatcher to detect new files, files removed and files renamed, and will reprocess the whole packages collection for future incomming requests.

Future works

Improvements could be:

  • Reprocessing only the necessary items (a bit more tricky)
  • Better support of the v3 API once documented by the NuGet team
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].