<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # GitLab NuGet Repository > 原文:[https://docs.gitlab.com/ee/user/packages/nuget_repository/](https://docs.gitlab.com/ee/user/packages/nuget_repository/) * [Setting up your development environment](#setting-up-your-development-environment) * [macOS support](#macos-support) * [Enabling the NuGet Repository](#enabling-the-nuget-repository) * [Adding the GitLab NuGet Repository as a source to NuGet](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget) * [Add NuGet Repository source with NuGet CLI](#add-nuget-repository-source-with-nuget-cli) * [Add NuGet Repository source with Visual Studio](#add-nuget-repository-source-with-visual-studio) * [Add NuGet Repository source with .NET CLI](#add-nuget-repository-source-with-net-cli) * [Uploading packages](#uploading-packages) * [Upload packages with NuGet CLI](#upload-packages-with-nuget-cli) * [Upload packages with .NET CLI](#upload-packages-with-net-cli) * [Install packages](#install-packages) * [Install a package with NuGet CLI](#install-a-package-with-nuget-cli) * [Install a package with .NET CLI](#install-a-package-with-net-cli) # GitLab NuGet Repository[](#gitlab-nuget-repository-premium "Permalink") [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/20050) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.8. 使用 GitLab NuGet 存儲庫,每個項目都可以擁有自己的空間來存儲 NuGet 軟件包. GitLab NuGet 存儲庫可用于: * [NuGet CLI](https://docs.microsoft.com/en-us/nuget/reference/nuget-exe-cli-reference) * [.NET Core CLI](https://docs.microsoft.com/en-us/dotnet/core/tools/) * [Visual Studio](https://visualstudio.microsoft.com/vs/) ## Setting up your development environment[](#setting-up-your-development-environment "Permalink") 您將需要[NuGet CLI 5.2 或更高版本](https://www.nuget.org/downloads) . 早期版本尚未針對 GitLab NuGet 存儲庫進行測試,因此可能無法正常工作. 如果您具有[Visual Studio](https://visualstudio.microsoft.com/vs/) ,則可能已經安裝了 NuGet CLI. 或者,您可以使用[.NET SDK 3.0 或更高版本](https://dotnet.microsoft.com/download/dotnet-core/3.0) ,該版本將安裝 NuGet CLI. 您可以通過以下方法確認已正確安裝[NuGet CLI](https://www.nuget.org/) : ``` nuget help ``` 您應該看到類似以下內容: ``` NuGet Version: 5.2.0.6090 usage: NuGet <command> [args] [options] Type 'NuGet help <command>' for help on a specific command. Available commands: [output truncated] ``` ### macOS support[](#macos-support "Permalink") 對于 macOS,您還可以使用[Mono](https://www.mono-project.com/)運行 NuGet CLI. 對于 Homebrew 用戶,請運行`brew install mono`來安裝 Mono. 然后,您應該能夠從[NuGet CLI 頁面](https://www.nuget.org/downloads)下載 Windows C#二進制文件`nuget.exe`并運行: ``` mono nuget.exe ``` ## Enabling the NuGet Repository[](#enabling-the-nuget-repository "Permalink") **注意:**僅當您的 GitLab 管理員[啟用了對 Package Registry 的支持時,](../../../administration/packages/index.html)此選項才可用. 啟用 NuGet 存儲庫后,默認情況下它將可用于所有新項目. 要為現有項目啟用它,或者要禁用它: 1. 導航到項目的**"設置">"常規">"可見性,項目功能,權限"** . 2. 找到"軟件包"功能并啟用或禁用它. 3. 單擊**保存更改**以使更改生效. 然后,您應該能夠在左側欄中看到" **程序包和注冊表"**部分. ## Adding the GitLab NuGet Repository as a source to NuGet[](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget "Permalink") 您將需要以下內容: * 您的 GitLab 用戶名. * 個人訪問令牌或部署令牌. 對于存儲庫身份驗證: * 您可以將范圍設置為`api`來生成[個人訪問令牌](../../../user/profile/personal_access_tokens.html) . * 您可以生成[令牌部署](./../../project/deploy_tokens/index.html)與范圍設置為`read_package_registry` , `write_package_registry` ,或兩者兼而有之. * 您的來源的合適名稱. * 您的項目 ID,可以在項目的主頁上找到. 您現在可以使用以下方法向 NuGet 添加新的源: * [NuGet CLI](#add-nuget-repository-source-with-nuget-cli) * [Visual Studio](#add-nuget-repository-source-with-visual-studio). * [.NET CLI](#add-nuget-repository-source-with-net-cli) ### Add NuGet Repository source with NuGet CLI[](#add-nuget-repository-source-with-nuget-cli "Permalink") 要將 GitLab NuGet 存儲庫添加為帶有`nuget`的源: ``` nuget source Add -Name <source_name> -Source "https://gitlab-instance.example.com/api/v4/projects/<your_project_id>/packages/nuget/index.json" -UserName <gitlab_username or deploy_token_username> -Password <gitlab_personal_access_token or deploy_token> ``` Where: * `<source_name>`是所需的源名稱. 例如: ``` nuget source Add -Name "GitLab" -Source "https://gitlab.example/api/v4/projects/10/packages/nuget/index.json" -UserName carol -Password 12345678asdf ``` ### Add NuGet Repository source with Visual Studio[](#add-nuget-repository-source-with-visual-studio "Permalink") 1. Open [Visual Studio](https://visualstudio.microsoft.com/vs/). 2. 打開" **文件">"選項"** (Windows)或" **Visual Studio">"首選項"** (Mac OS). 3. 在**NuGet**部分中,打開**Sources** . 您將看到所有 NuGet 來源的列表. 4. Click **Add**. 5. 填寫以下字段: * **名稱** :源的期望名稱 * **位置** : `https://gitlab.com/api/v4/projects/<your_project_id>/packages/nuget/index.json` : `https://gitlab.com/api/v4/projects/<your_project_id>/packages/nuget/index.json` * 將`<your_project_id>`替換為您的項目 ID. * 如果您具有自行管理的 GitLab 安裝, `gitlab.com`使用您的域名替換`gitlab.com` . * **用戶**名:您的 GitLab 用戶名或部署令牌用戶名 * **密碼** :您的個人訪問令牌或部署令牌 [![Visual Studio 添加 NuGet 源](https://img.kancloud.cn/09/97/0997897a5b1287c30e9419bea6344f43_959x705.png)](img/visual_studio_adding_nuget_source.png) 6. Click **Save**. [![Visual Studio NuGet source added](https://img.kancloud.cn/ed/49/ed4951ecabdd6bbf868fd7d3dcc47af1_960x704.png)](img/visual_studio_nuget_source_added.png) 如有任何警告,請確保**Location** , **Username**和**Password**正確. ### Add NuGet Repository source with .NET CLI[](#add-nuget-repository-source-with-net-cli "Permalink") 要將 GitLab NuGet 存儲庫添加為.NET 的源, `nuget.config`在項目的根目錄中創建一個名為`nuget.config`的文件,其內容如下: ``` <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="gitlab" value="https://gitlab-instance.example.com/api/v4/projects/<your_project_id>/packages/nuget/index.json" /> </packageSources> <packageSourceCredentials> <gitlab> <add key="Username" value="<gitlab_username or deploy_token_username>" /> <add key="ClearTextPassword" value="<gitlab_personal_access_token or deploy_token>" /> </gitlab> </packageSourceCredentials> </configuration> ``` ## Uploading packages[](#uploading-packages "Permalink") 上載套件時,請注意: * 允許的最大大小為 50 MB. * 如果您多次上傳具有相同版本的相同程序包,則每次連續上傳都將保存為單獨的文件. 安裝軟件包時,GitLab 將提供最新文件. * 將軟件包上傳到 GitLab 時,它們不會立即顯示在項目的軟件包 UI 中. 處理包裹最多可能需要 10 分鐘. ### Upload packages with NuGet CLI[](#upload-packages-with-nuget-cli "Permalink") 本部分假定您的項目已正確構建,并且已經[使用 NuGet CLI 創建了 NuGet 軟件包](https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package) . 使用以下命令上傳軟件包: ``` nuget push <package_file> -Source <source_name> ``` Where: * `<package_file>`是您的軟件包文件名,以`.nupkg`結尾. * `<source_name>`是[安裝過程中使用](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget)的[源名稱](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget) . ### Upload packages with .NET CLI[](#upload-packages-with-net-cli "Permalink") 本節假定您的項目已正確構建,并且已經[使用.NET CLI 創建了 NuGet 軟件包](https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package-dotnet-cli) . 使用以下命令上傳軟件包: ``` dotnet nuget push <package_file> --source <source_name> ``` Where: * `<package_file>`是您的軟件包文件名,以`.nupkg`結尾. * `<source_name>`是[安裝過程中使用](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget)的[源名稱](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget) . 例如: ``` dotnet nuget push MyPackage.1.0.0.nupkg --source gitlab ``` ## Install packages[](#install-packages "Permalink") ### Install a package with NuGet CLI[](#install-a-package-with-nuget-cli "Permalink") **警告:**默認情況下, `nuget`檢查的官方消息`nuget.org`第一. 如果您在 GitLab NuGet 存儲庫中擁有與`nuget.org`的軟件包同名的軟件包, `nuget.org`必須指定源名稱,否則將安裝錯誤的軟件包. 使用以下命令安裝最新版本的軟件包: ``` nuget install <package_id> -OutputDirectory <output_directory> \ -Version <package_version> \ -Source <source_name> ``` Where: * `<package_id>`是軟件包 ID. * `<output_directory>`是將在其中安裝軟件包的輸出目錄. * `<package_version>` (可選)是軟件包版本. * `<source_name>` (可選)是源名稱. ### Install a package with .NET CLI[](#install-a-package-with-net-cli "Permalink") **Warning:** If you have a package in the GitLab NuGet Repository with the same name as a package at a different source, you should verify the order in which `dotnet` checks sources during install. This is defined in the `nuget.config` file. 使用以下命令安裝最新版本的軟件包: ``` dotnet add package <package_id> \ -v <package_version> ``` Where: * `<package_id>`是軟件包 ID. * `<package_version>` (可選)是軟件包版本.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看