Article version: Enterprise Server 2.22
- Install Local Nuget Package Cli
- Dotnet Cli Nuget
- Dotnet Cli Update Nuget Package
- Install Nuget Package Dotnet Cli Linux
- Install Nuget Package Dotnet Cli Installer
The answers above are good, but insufficient if you have more than 1 project (.csproj) in the same folder. First, you easily add the 'PackageReference' tag to the.csproj file (either manually, by using the nuget package manager or by using the dotnet add package command). An introduction to installing and using NuGet packages with cross-platform.NET CLI. We will walk through an example of converting a mascot object to a JSON string and cover how to search for, install.
Article version: Enterprise Server 2.22
You can configure the dotnet
command-line interface (CLI) to publish NuGet packages to GitHub Packages and to use packages stored on GitHub Packages as dependencies in a .NET project.
GitHub Packages is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 2.22, and GitHub One.
In this article
Note: GitHub Packages is currently in beta for GitHub Enterprise Server 2.22. To join the beta for your your GitHub Enterprise Server instance, use the sign-up form.
Note: This package type may not be available for your instance, because site administrators can enable or disable each supported package type. For more information, see 'Configuring packages support for your enterprise.'
Authenticating to GitHub Packages
You need an access token to publish, install, and delete packages. You can use a personal access token to authenticate with your username directly to GitHub Packages or the GitHub API. When you create a personal access token, you can assign the token different scopes depending on your needs.
To authenticate to GitHub Packages using a GitHub Actions workflow, you must use GITHUB_TOKEN
.
Authenticating with a personal access token
You must use a personal access token with the appropriate scopes to publish and install packages in GitHub Packages. For more information, see 'About GitHub Packages.'
To authenticate to GitHub Packages with the dotnet
command-line interface (CLI), create a nuget.config file in your project directory specifying GitHub Packages as a source under packageSources
for the dotnet
CLI client.
Install Local Nuget Package Cli
You must replace:
USERNAME
with the name of your user account on GitHub.TOKEN
with your personal access token.OWNER
with the name of the user or organization account that owns the repository containing your project.HOSTNAME
with the host name for your GitHub Enterprise Server instance.
If your instance has subdomain isolation enabled:
If your instance has subdomain isolation disabled:
Authenticating with the GITHUB_TOKEN
If you are using a GitHub Actions workflow, you can use a GITHUB_TOKEN
to publish and consume packages in GitHub Packages without needing to store and manage a personal access token. For more information, see 'Authenticating with the GITHUB_TOKEN
.'
Publishing a package
You can publish a package to GitHub Packages by authenticating with a nuget.config file.
Dotnet Cli Nuget
Publishing a package using a nuget.config file
When publishing, you need to use the same value for OWNER
in your csproj file that you use in your nuget.config authentication file. Specify or increment the version number in your .csproj file, then use the dotnet pack
command to create a .nuspec file for that version. For more information on creating your package, see 'Create and publish a package' in the Microsoft documentation.
Authenticate to GitHub Packages. For more information, see 'Authenticating to GitHub Packages.'
Create a new project.
Add your project's specific information to your project's file, which ends in .csproj. You must replace:
OWNER
with the name of the user or organization account that owns the repository containing your project.REPOSITORY
with the name of the repository containing the package you want to publish.1.0.0
with the version number of the package.HOSTNAME
with the host name for your GitHub Enterprise Server instance.
Package the project.
Publish the package using the
key
you specified in the nuget.config file.
Dotnet Cli Update Nuget Package
After you publish a package, you can view the package on GitHub. For more information, see 'Viewing packages.'
Publishing multiple packages to the same repository
To publish multiple packages to the same repository, you can include the same GitHub repository URL in the RepositoryURL
fields in all .csproj project files. GitHub matches the repository based on that field.
For example, the OctodogApp and OctocatApp projects will publish to the same repository:
Install Nuget Package Dotnet Cli Linux
Installing a package
Using packages from GitHub in your project is similar to using packages from nuget.org. Add your package dependencies to your .csproj file, specifying the package name and version. For more information on using a .csproj file in your project, see 'Working with NuGet packages' in the Microsoft documentation.
Authenticate to GitHub Packages. For more information, see 'Authenticating to GitHub Packages.'
To use a package, add
ItemGroup
and configure thePackageReference
field in the .csproj project file, replacing theOctokittenApp
package with your package dependency and1.0.0
with the version you want to use:Install the packages with the
restore
command.
Further reading
- 'Deleting a package'
Help us make these docs great!
All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.
Make a contributionInstall Nuget Package Dotnet Cli Installer
Or, learn how to contribute.