143

I have an assembly that I have made which is very specific to my team at my company. I want to be able to use NuGet to make this assembly avaiable to other projects that my team and similar teams at my company are working on. However, the assembly isn't really code that I want to share with the world.

I know with Maven, you can create local repositories and source packages from a local repo. Does NuGet support similar functionality? Is there a way with NuGet to specify either a local repository or to have private packages?

5 Answers 5

114

Yes! You can host your own NuGet server!

The easiest way is creating a shared folder on your server and referencing that as your Nuget Server.

You can find more information about how to do that at: Hosting Your Own NuGet Feeds

5
  • 4
    At the link above, scroll down to the 'Creating Remote Feeds' section if you are looking to create an actual server, accessible via HTTP, to host your assemblies. Commented Jan 25, 2013 at 18:31
  • 7
    Although this is probably the easiest way, it means you have to share the folder with everyone, and anyone with access could (accidently or not) temper with its content. A better way (yet simple way) is to create your own server using NuGet.Server and to host is in IIS or Azure. You will then be able to push packages using an API key and anyone can subscribe to the feed. Here is an easy guide to create your own NuGet server. Commented Mar 13, 2015 at 9:27
  • I had the same problem. and found the following: Scott: hanselman.com/blog/… also: nicolaiarocci.com/… Commented Apr 10, 2018 at 12:11
  • And how-to use internal Nuget feeds with Azure Devops ?
    – Kiquenet
    Commented May 18, 2021 at 9:31
  • 1
    @Kiquenet use 'dotnet nuget add source --name "XXX" "YYY.net/nuget"' command before 'dotnet restore'
    – Alex xelA
    Commented Feb 15, 2022 at 9:16
24

Another option for hosting your own NuGet server is to use JetBrains TeamCity as a build server. The setup is described here.

The Team City server acts as a NuGet repository that would/could/should only be accessible within your company.

Based on your usage, there are free versions of the software.

It has some nice options such as the ability to publish a new NuGet version on demand, with each new continuous integration build, etc. One of the most useful bits (as with all NuGet server implementations) is that it will keep dozens of older versions of your assemblies so if you have one project that needs to reference the newest version, and another project that needs to reference an older version, everything will work out.

1
  • 2
    Altough you're correct, TeamCity has very little to do with NuGet per say, and there's other options for a NuGet server (which is what he is asking for). TeamCity is rather a continous integration server that happens to have a built-in NuGet server.
    – Jim Aho
    Commented Mar 22, 2018 at 16:25
15

Check out the ProGet free edition; we built it exactly for this purpose. It takes much less time to setup and offers many features above and beyond those offered by the standard NuGet server, such as multiple feeds, feed aggregation, and additional repository types (npm, Bower, etc.)

If you want to pay for the enterprise version, you also get the ability to use LDAP for authentication, and the ability to filter feeds by name/license from connected feeds (i.e. NuGet's official feed).

3

Yes, you can have local feeds. It's dead-simple to set up, take a look here.

MyGet is popular for hosting private feeds. It's not free, but take a look at their pricing and maybe it suits you well!

1
  • 4
    This is July 2023 and MyGet has been down for 3 consecutive days. Do yourself a favor, don't use it.
    – Catinodeh
    Commented Jul 27, 2023 at 21:07
1

Use a github action to publish it in the github nuget:

step 1. Update your package version inside the *.csproj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>      
    <Version>1.0.0</Version>        <-- Very important!!!
    <Authors>Team-Bolivia</Authors>
    <Company>Bolivia-Tech</Company>
    <Description>Library to bla bla bla..</Description>
    <RepositoryUrl>https://github.com/<owner|org>/<project_name></RepositoryUrl>
  </PropertyGroup>

</Project>

step 2. Create the action:

name: Publish Bolivia Package
runs-on: ubuntu-latest
permissions:
  contents: read
  packages: write # permission for the github token
steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-dotnet@v3
    with:
      dotnet-version: '3.1.x' # No change it
      source-url: https://nuget.pkg.github.com/<owner|organization>/index.json
    env:
      NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
  - name: Build project
    run: dotnet build --configuration Release
  - name: Create the package
    run: dotnet pack --configuration Release
  - name: Publish the package to GPR
    run: dotnet nuget push bin/Release/*.nupkg

Not the answer you're looking for? Browse other questions tagged or ask your own question.