code.gitea.io/gitea@v1.22.3/docs/content/usage/packages/nuget.en-us.md (about)

     1  ---
     2  date: "2021-07-20T00:00:00+00:00"
     3  title: "NuGet Package Registry"
     4  slug: "nuget"
     5  sidebar_position: 80
     6  draft: false
     7  toc: false
     8  menu:
     9    sidebar:
    10      parent: "packages"
    11      name: "NuGet"
    12      sidebar_position: 80
    13      identifier: "nuget"
    14  ---
    15  
    16  # NuGet Package Registry
    17  
    18  Publish [NuGet](https://www.nuget.org/) packages for your user or organization. The package registry supports the V2 and V3 API protocol and you can work with [NuGet Symbol Packages](https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg) too.
    19  
    20  ## Requirements
    21  
    22  To work with the NuGet package registry, you can use command-line interface tools as well as NuGet features in various IDEs like Visual Studio.
    23  More information about NuGet clients can be found in [the official documentation](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools).
    24  The following examples use the `dotnet nuget` tool.
    25  
    26  ## Configuring the package registry
    27  
    28  To register the package registry you need to configure a new NuGet feed source:
    29  
    30  ```shell
    31  dotnet nuget add source --name {source_name} --username {username} --password {password} https://gitea.example.com/api/packages/{owner}/nuget/index.json
    32  ```
    33  
    34  | Parameter     | Description |
    35  | ------------- | ----------- |
    36  | `source_name` | The desired source name. |
    37  | `username`    | Your Gitea username. |
    38  | `password`    | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. |
    39  | `owner`       | The owner of the package. |
    40  
    41  For example:
    42  
    43  ```shell
    44  dotnet nuget add source --name gitea --username testuser --password password123 https://gitea.example.com/api/packages/testuser/nuget/index.json
    45  ```
    46  
    47  You can add the source without credentials and use the [`--api-key`](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push) parameter when publishing packages. In this case you need to provide a [personal access token](development/api-usage.md#authentication).
    48  
    49  ## Publish a package
    50  
    51  Publish a package by running the following command:
    52  
    53  ```shell
    54  dotnet nuget push --source {source_name} {package_file}
    55  ```
    56  
    57  | Parameter      | Description |
    58  | -------------- | ----------- |
    59  | `source_name`  | The desired source name. |
    60  | `package_file` | Path to the package `.nupkg` file. |
    61  
    62  For example:
    63  
    64  ```shell
    65  dotnet nuget push --source gitea test_package.1.0.0.nupkg
    66  ```
    67  
    68  You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
    69  
    70  ### Symbol Packages
    71  
    72  The NuGet package registry has build support for a symbol server. The PDB files embedded in a symbol package (`.snupkg`) can get requested by clients.
    73  To do so, register the NuGet package registry as symbol source:
    74  
    75  ```
    76  https://gitea.example.com/api/packages/{owner}/nuget/symbols
    77  ```
    78  
    79  | Parameter | Description |
    80  | --------- | ----------- |
    81  | `owner`   | The owner of the package registry. |
    82  
    83  For example:
    84  
    85  ```
    86  https://gitea.example.com/api/packages/testuser/nuget/symbols
    87  ```
    88  
    89  ## Install a package
    90  
    91  To install a NuGet package from the package registry, execute the following command:
    92  
    93  ```shell
    94  dotnet add package --source {source_name} --version {package_version} {package_name}
    95  ```
    96  
    97  | Parameter         | Description |
    98  | ----------------- | ----------- |
    99  | `source_name`     | The desired source name. |
   100  | `package_name`    | The package name. |
   101  | `package_version` | The package version. |
   102  
   103  For example:
   104  
   105  ```shell
   106  dotnet add package --source gitea --version 1.0.0 test_package
   107  ```
   108  
   109  ## Supported commands
   110  
   111  ```
   112  dotnet add
   113  dotnet nuget push
   114  dotnet nuget delete
   115  ```