

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搭配 NuGet 使用 CodeArtifact
<a name="using-nuget"></a>

這些主題說明如何使用 CodeArtifact 來使用和發佈`NuGet`套件。

**注意**  
AWS CodeArtifact 僅支援 [NuGet.exe 4.8 版和更新版本。](https://docs.microsoft.com/en-us/nuget/release-notes/nuget-4.8-rtm)



**Topics**
+ [搭配 Visual Studio 使用 CodeArtifact](nuget-visual-studio.md)
+ [搭配 nuget 或 dotnet 使用 CodeArtifact](nuget-cli.md)
+ [NuGet 套件名稱、版本和資產名稱標準化](nuget-name-normalization.md)
+ [NuGet 相容性](nuget-compatibility.md)

# 搭配 Visual Studio 使用 CodeArtifact
<a name="nuget-visual-studio"></a>

 您可以使用 CodeArtifact 登入資料提供者，在 Visual Studio 中直接使用 CodeArtifact 套件。登入資料提供者可簡化在 Visual Studio 中 CodeArtifact 儲存庫的設定和身分驗證，並可在 中使用[AWS Toolkit for Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)。

**注意**  
 AWS Toolkit for Visual Studio 不適用於 Visual Studio for Mac。

若要搭配 CLI 工具設定和使用 NuGet，請參閱 [搭配 nuget 或 dotnet CLI 使用 CodeArtifact](nuget-cli.md)。

**Topics**
+ [使用 CodeArtifact 登入資料提供者設定 Visual Studio](#nuget-vs-cred-provider)
+ [使用 Visual Studio Package Manager 主控台](#built-in-nuget-terminal-vs)

## 使用 CodeArtifact 登入資料提供者設定 Visual Studio
<a name="nuget-vs-cred-provider"></a>

CodeArtifact 登入資料提供者可簡化 CodeArtifact 和 Visual Studio 之間的設定和持續身分驗證。CodeArtifact 身分驗證字符的有效期最長為 12 小時。為了避免在 Visual Studio 中工作時手動重新整理權杖，憑證提供者會在目前的權杖過期之前定期擷取新的權杖。

**重要**  
若要使用登入資料提供者，請確定任何現有的 AWS CodeArtifact 登入資料都已從您的`nuget.config`檔案清除，這些登入資料可能已手動新增，或執行 `aws codeartifact login`來設定 NuGet。

**在 Visual Studio 中使用 CodeArtifact 搭配 AWS Toolkit for Visual Studio**

1.  AWS Toolkit for Visual Studio 使用下列步驟安裝 。工具組與使用下列步驟的 Visual Studio 2017 和 2019 相容。 AWS CodeArtifact 不支援 Visual Studio 2015 和更早版本。

   1.  Toolkit for Visual Studio for Visual Studio 2017 和 Visual Studio 2019 分佈在 [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017) 中。您也可以使用 **Tools** **≫ Extensions and Updates **(Visual Studio 2017) 或 **Extensions** **≫ Manage Extensions** (Visual Studio 2019)，在 Visual Studio 中安裝和更新工具組。

   1.  安裝工具組後，從**檢視**功能表中選擇 **AWS Explorer** 來開啟工具組。

1. 遵循*AWS Toolkit for Visual Studio 《 使用者指南*》中的提供登入 AWS 資料中的步驟，以您的登入資料設定 Toolkit for Visual Studio。 [AWS](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/credentials.html)

1. （選用） 設定您要搭配 CodeArtifact 使用的 AWS 設定檔。如果未設定，CodeArtifact 將使用預設設定檔。若要設定設定檔，請前往**工具 > NuGet 套件管理員 > 選取 CodeArtifact AWS 設定檔**。

1. 在 Visual Studio 中將 CodeArtifact 儲存庫新增為套件來源。

   1. 在 **AWS Explorer** 視窗中導覽至您的儲存庫，按一下滑鼠右鍵並選取 `Copy NuGet Source Endpoint`。

   1. 使用**工具 > 選項**命令並捲動至 **NuGet Package Manager**。

   1. 選取**套件來源**節點。

   1. 選取 **＋**，編輯名稱，並將步驟 3a 中複製的儲存庫 URL 端點貼到**來源**方塊中，然後選取**更新**。

   1. 選取新新增套件來源的核取方塊以啟用它。
**注意**  
建議您將 **NuGet.org** 的外部連線新增至 CodeArtifact 儲存庫，並在 Visual Studio 中停用 **nuget.org** 套件來源。使用外部連線時，從 **NuGet.org** 擷取的所有套件都會存放在 CodeArtifact 儲存庫中。如果 **NuGet.org** 無法使用，您的應用程式相依性仍然可用於 CI 組建和本機開發。如需外部連線的詳細資訊，請參閱 [將 CodeArtifact 儲存庫連接至公有儲存庫](external-connection.md)。

1. 重新啟動 Visual Studio 以使變更生效。

設定之後，如果您已新增外部連線，則 Visual Studio 可以使用 CodeArtifact 儲存庫、其任何上游儲存庫或 [NuGet.org](https://www.nuget.org/) 的套件。如需有關在 Visual Studio 中瀏覽和安裝 NuGet 套件的詳細資訊，請參閱 *NuGet 文件*[中的使用 NuGet 套件管理員在 Visual Studio 中安裝和管理套件](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio)。

## 使用 Visual Studio Package Manager 主控台
<a name="built-in-nuget-terminal-vs"></a>

Visual Studio Package Manager 主控台不會使用 CodeArtifact 登入資料提供者的 Visual Studio 版本。若要使用它，您必須設定命令列登入資料提供者。如需詳細資訊，請參閱「[搭配 nuget 或 dotnet CLI 使用 CodeArtifact](nuget-cli.md)」。

# 搭配 nuget 或 dotnet CLI 使用 CodeArtifact
<a name="nuget-cli"></a>

您可以使用 `nuget`和 等 CLI 工具`dotnet`，從 CodeArtifact 發佈和使用套件。本文件提供有關設定 CLI 工具以及使用這些工具來發佈或取用套件的資訊。

**Topics**
+ [設定 nuget 或 dotnet CLI](#nuget-configure-cli)
+ [從 CodeArtifact 取用 NuGet 套件](#nuget-consume-cli)
+ [將 NuGet 套件發佈至 CodeArtifact](#nuget-publish-cli)
+ [CodeArtifact NuGet 登入資料提供者參考](#nuget-cred-provider-reference)
+ [CodeArtifact NuGet 登入資料提供者版本](#nuget-cred-provider-history)

## 設定 nuget 或 dotnet CLI
<a name="nuget-configure-cli"></a>

您可以使用 CodeArtifact NuGet 登入資料提供者、 或手動設定 nuget AWS CLI或 dotnet CLI。強烈建議使用登入資料提供者設定 NuGet，以簡化設定和持續身分驗證。

### 方法 1：使用 CodeArtifact NuGet 登入資料提供者設定
<a name="nuget-configure-cli-cred-provider"></a>

CodeArtifact NuGet 登入資料提供者使用 NuGet CLI 工具簡化 CodeArtifact 的身分驗證和組態。CodeArtifact 身分驗證字符的有效期最長為 12 小時。為了避免在使用 nuget 或 dotnet CLI 時手動重新整理權杖，登入資料提供者會在目前的權杖過期之前定期擷取新的權杖。

**重要**  
若要使用登入資料提供者，請確定任何現有的 AWS CodeArtifact 登入資料都已從您的`nuget.config`檔案清除，這些登入資料可能已手動新增或執行 `aws codeartifact login`來設定 NuGet。

**安裝和設定 CodeArtifact NuGet 登入資料提供者**

------
#### [ dotnet ]

1. 使用下列`dotnet`命令，[從 NuGet.org 下載最新版本的 AWS.CodeArtifact.NuGet.CredentialProvider 工具。](https://www.nuget.org/packages/AWS.CodeArtifact.NuGet.CredentialProvider)

   ```
   dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider
   ```

1. 使用 `codeartifact-creds install`命令將登入資料提供者複製到 NuGet 外掛程式資料夾。

   ```
   dotnet codeartifact-creds install
   ```

1. （選用）：設定您要搭配登入資料提供者使用的 AWS 設定檔。如果未設定，登入資料提供者將使用預設設定檔。如需 AWS CLI 設定檔的詳細資訊，請參閱[具名設定檔](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)。

   ```
   dotnet codeartifact-creds configure set profile profile_name
   ```

------
#### [ nuget ]

執行下列步驟，使用 NuGet CLI 從 Amazon S3 儲存貯體安裝 CodeArtifact NuGet 登入資料提供者並進行設定。登入資料提供者將使用預設 AWS CLI 設定檔，如需設定檔的詳細資訊，請參閱[具名設定檔](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)。

1. 從 Amazon S3 儲存貯體下載最新版本的 [CodeArtifact NuGet 登入資料提供者 (codeartifact-nuget-credentialprovider.zip)](https://a.co/dbGqKq7)。

   若要檢視和下載舊版，請參閱 [CodeArtifact NuGet 登入資料提供者版本](#nuget-cred-provider-history)。

1. 解壓縮檔案。

1. 將 **AWS.CodeArtifact.NuGetCredentialProvider** 資料夾從 **netfx** 資料夾複製到 Windows `%user_profile%/.nuget/plugins/netfx/` 或 Linux 或 MacOS `~/.nuget/plugins/netfx` 上的 。

1. 在 Windows `%user_profile%/.nuget/plugins/netcore/`或 `~/.nuget/plugins/netcore` Linux 或 MacOS 上**，將 AWS.CodeArtifact.NuGetCredentialProvider** 資料夾從 **netcore** 資料夾複製到 。

------

建立儲存庫並設定登入資料提供者之後，您可以使用 `nuget`或 `dotnet` CLI 工具來安裝和發佈套件。如需詳細資訊，請參閱[從 CodeArtifact 取用 NuGet 套件](#nuget-consume-cli)及[將 NuGet 套件發佈至 CodeArtifact](#nuget-publish-cli)。

### 方法 2：使用登入命令設定 nuget 或 dotnet
<a name="nuget-configure-login"></a>

中的 `codeartifact login`命令會將儲存庫端點和授權字符 AWS CLI 新增至 NuGet 組態檔案，讓 nuget 或 dotnet 連線到 CodeArtifact 儲存庫。這將修改位於 的使用者層級 NuGet 組態，`%appdata%\NuGet\NuGet.Config`適用於 Windows 和 `~/.config/NuGet/NuGet.Config` `~/.nuget/NuGet/NuGet.Config` Mac/Linux。如需 NuGet 組態的詳細資訊，請參閱[常見 NuGet 組態](https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior)。

**使用 `login`命令設定 nuget 或 dotnet**

1. 設定您的 AWS 登入資料以搭配 使用 AWS CLI，如中所述[CodeArtifact 入門](getting-started.md)。

1. 確定 NuGet CLI 工具 (`nuget` 或 `dotnet`) 已正確安裝和設定。如需說明，請參閱 [nuget](https://docs.microsoft.com/en-us/nuget/reference/nuget-exe-cli-reference) 或 [dotnet](https://docs.microsoft.com/en-us/dotnet/core/install/) 文件。

1. 使用 CodeArtifact `login`命令來擷取登入資料，以便與 NuGet 搭配使用。
**注意**  
如果您在擁有的網域中存取儲存庫，則不需要包含 `--domain-owner`。如需詳細資訊，請參閱[跨帳戶網域](domain-overview.md#domain-overview-cross-account)。

------
#### [ dotnet ]

**重要**  
**Linux 和 MacOS 使用者：**由於非 Windows 平台不支援加密，因此您擷取的憑證會以純文字形式儲存在組態檔案中。

   ```
   aws codeartifact login --tool dotnet --domain my_domain --domain-owner 111122223333 --repository my_repo
   ```

------
#### [ nuget ]

   ```
   aws codeartifact login --tool nuget --domain my_domain --domain-owner 111122223333 --repository my_repo
   ```

------

登入命令將：
+ 使用您的 AWS 登入資料從 CodeArtifact 擷取授權字符。
+ 使用 NuGet 套件來源的新項目來更新您的使用者層級 NuGet 組態。指向 CodeArtifact 儲存庫端點的來源將稱為 `domain_name/repo_name`。

呼叫 後的預設授權期間`login`為 12 小時，`login`必須呼叫 以定期重新整理字符。如需使用 `login`命令建立的授權字符的詳細資訊，請參閱 [使用 `login`命令建立的字符](tokens-authentication.md#auth-token-login)。

建立儲存庫並設定身分驗證之後`dotnet`，您可以使用 `nuget`、 或 `msbuild` CLI 用戶端來安裝和發佈套件。如需詳細資訊，請參閱[從 CodeArtifact 取用 NuGet 套件](#nuget-consume-cli)及[將 NuGet 套件發佈至 CodeArtifact](#nuget-publish-cli)。

### 方法 3：在沒有登入命令的情況下設定 nuget 或 dotnet
<a name="nuget-configure-without-login"></a>

對於手動組態，您必須將儲存庫端點和授權字符新增至 NuGet 組態檔案，以啟用 nuget 或 dotnet 連線至 CodeArtifact 儲存庫。

**手動設定 nuget 或 dotnet 以連接至 CodeArtifact 儲存庫。**

1. 使用 `get-repository-endpoint` AWS CLI 命令判斷 CodeArtifact 儲存庫端點。

   ```
   aws codeartifact get-repository-endpoint --domain my_domain --domain-owner 111122223333 --repository my_repo --format nuget
   ```

   輸出範例：

   ```
   {
      "repositoryEndpoint": "https://my_domain-111122223333.d.codeartifact.us-west-2.amazonaws.com/nuget/my_repo/"
   }
   ```

1. 使用 `get-authorization-token` AWS CLI 命令，從套件管理員取得連接至儲存庫的授權字符。

   ```
   aws codeartifact get-authorization-token --domain my_domain
   ```

   輸出範例：

   ```
   {
      "authorizationToken": "eyJ2I...viOw",
      "expiration": 1601616533.0
   }
   ```

1. 透過附加`/v3/index.json`至步驟 3 `get-repository-endpoint`中 傳回的 URL 來建立完整的儲存庫端點 URL。

1. 設定 nuget 或 dotnet 以使用步驟 1 的儲存庫端點和步驟 2 的授權字符。
**注意**  
來源 URL 必須以 結尾`/v3/index.json`，nuget 或 dotnet 才能成功連線至 CodeArtifact 儲存庫。

------
#### [ dotnet ]

   **Linux 和 MacOS 使用者：**由於非 Windows 平台不支援加密，您必須將 `--store-password-in-clear-text`旗標新增至下列命令。請注意，這會將您的密碼以純文字形式存放在您的組態檔案中。

   ```
   dotnet nuget add source https://my_domain-111122223333.d.codeartifact.us-west-2.amazonaws.com/nuget/my_repo/v3/index.json --name packageSourceName --password eyJ2I...viOw --username aws
   ```

**注意**  
若要更新現有的來源，請使用 `dotnet nuget update source`命令。

------
#### [ nuget ]

   ```
   nuget sources add -name domain_name/repo_name -Source https://my_domain-111122223333.d.codeartifact.us-west-2.amazonaws.com/nuget/my_repo/v3/index.json -password eyJ2I...viOw -username aws
   ```

------

   輸出範例：

   ```
   Package source with Name: domain_name/repo_name added successfully.
   ```
**注意**  
若要使用雙堆疊端點，請使用 `codeartifact.region.on.aws`端點。

## 從 CodeArtifact 取用 NuGet 套件
<a name="nuget-consume-cli"></a>

[使用 CodeArtifact 設定 NuGet ](https://docs.aws.amazon.com//codeartifact/latest/ug/nuget-cli.html)後，您可以取用儲存在 CodeArtifact 儲存庫或其中一個上游儲存庫中的 NuGet 套件。

若要使用 CodeArtifact 儲存庫或其中一個上游儲存庫中的套件版本，請執行下列命令，將 *packageName* 取代為您想要使用的套件名稱`nuget``dotnet`，並使用 NuGet 組態檔案中 CodeArtifact 儲存庫的來源名稱取代 *packageSourceName*。如果您使用 `login`命令來設定 NuGet 組態，來源名稱為 *domain\$1name/repo\$1name*。

**注意**  
請求套件時，NuGet 用戶端會快取該套件的哪些版本存在。由於此行為，在所需版本可用之前，先前請求的套件安裝可能會失敗。若要避免此故障並成功安裝存在的套件，您可以使用 `nuget locals all --clear`或 ，在安裝之前清除 NuGet 快取`dotnet nuget locals all --clear`，或透過提供 的 `-NoCache`選項`nuget`或 的 `--no-cache`選項，避免在 `install`和 `restore`命令期間使用快取`dotnet`。

------
#### [ dotnet ]

```
dotnet add package packageName --source packageSourceName
```

------
#### [ nuget ]

```
nuget install packageName -Source packageSourceName
```

------

**安裝特定版本的套件**

------
#### [ dotnet ]

```
dotnet add package packageName --version 1.0.0 --source packageSourceName
```

------
#### [ nuget ]

```
nuget install packageName -Version 1.0.0 -Source packageSourceName
```

------

如需詳細資訊，請參閱 ** [Microsoft 文件中的使用 nuget.exe CLI 管理套件](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-nuget-cli)或使用 [dotnet CLI 安裝和管理套件](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-dotnet-cli)。

### 從 NuGet.org 取用 NuGet 套件
<a name="nuget-consume-nuget-gallery"></a>

您可以透過 CodeArtifact NuGet 儲存庫從 [NuGet.org](https://www.nuget.org/) 使用 NuGet 套件，方法是使用 **NuGet.org** 的外部連線來設定儲存庫。從 **NuGet.org** 取用的套件會擷取並儲存在 CodeArtifact 儲存庫中。如需新增外部連線的詳細資訊，請參閱 [將 CodeArtifact 儲存庫連接至公有儲存庫](external-connection.md)。

## 將 NuGet 套件發佈至 CodeArtifact
<a name="nuget-publish-cli"></a>

[使用 CodeArtifact 設定 NuGet ](https://docs.aws.amazon.com//codeartifact/latest/ug/nuget-cli.html)後，您可以使用 `nuget`或 `dotnet`將套件版本發佈至 CodeArtifact 儲存庫。

若要將套件版本推送至 CodeArtifact 儲存庫，請在 NuGet 組態`.nupkg`檔案中，使用檔案的完整路徑和 CodeArtifact 儲存庫的來源名稱執行下列命令。如果您使用 `login`命令來設定 NuGet 組態，則來源名稱為 `domain_name/repo_name`。

**注意**  
如果您沒有要發佈的 NuGet 套件，您可以建立該套件。如需詳細資訊，請參閱 *Microsoft 文件*中的[套件建立工作流程](https://docs.microsoft.com/en-us/nuget/create-packages/overview-and-workflow)。

------
#### [ dotnet ]

```
dotnet nuget push path/to/nupkg/SamplePackage.1.0.0.nupkg --source packageSourceName
```

------
#### [ nuget ]

```
nuget push path/to/nupkg/SamplePackage.1.0.0.nupkg -Source packageSourceName
```

------

## CodeArtifact NuGet 登入資料提供者參考
<a name="nuget-cred-provider-reference"></a>

CodeArtifact NuGet 登入資料提供者可讓您輕鬆地使用 CodeArtifact 儲存庫設定和驗證 NuGet。

### CodeArtifact NuGet 登入資料提供者命令
<a name="nuget-cred-provider-reference-commands"></a>

本節包含 CodeArtifact NuGet 登入資料提供者的命令清單。這些命令必須以 做為字首，`dotnet codeartifact-creds`如下列範例所示。

```
dotnet codeartifact-creds command
```
+ `configure set profile profile`：設定登入資料提供者以使用提供的 AWS 設定檔。
+ `configure unset profile`：如果已設定，則移除已設定的設定檔。
+ `install`：將登入資料提供者複製到 `plugins` 資料夾。
+ `install --profile profile`：將登入資料提供者複製到 `plugins` 資料夾，並將其設定為使用提供的 AWS 設定檔。
+ `uninstall`：解除安裝登入資料提供者。這不會移除組態檔案的變更。
+ `uninstall --delete-configuration`：解除安裝登入資料提供者，並移除組態檔案的所有變更。

### CodeArtifact NuGet 登入資料提供者日誌
<a name="nuget-cred-provider-reference-logs"></a>

若要啟用 CodeArtifact NuGet 登入資料提供者的記錄，您必須在環境中設定日誌檔案。登入資料提供者日誌包含有用的偵錯資訊，例如：
+ 用於進行連線的 AWS 設定檔
+ 任何身分驗證錯誤
+ 如果提供的端點不是 CodeArtifact URL

**設定 CodeArtifact NuGet 登入資料提供者日誌檔案**

```
export AWS_CODEARTIFACT_NUGET_LOGFILE=/path/to/file
```

設定日誌檔案後，任何`codeartifact-creds`命令都會將其日誌輸出附加至該檔案的內容。

## CodeArtifact NuGet 登入資料提供者版本
<a name="nuget-cred-provider-history"></a>

下表包含 CodeArtifact NuGet 登入資料提供者的版本歷史記錄資訊和下載連結。


| 版本 | 變更 | 發佈日期 | 下載連結 (S3) | 
| --- | --- | --- | --- | 
|  1.0.2 （最新）  |  升級的相依性  |  06/26/2024  |  [下載 v1.0.2](https://d12ov9682v6hj.cloudfront.net/codeartifact-nuget-credentialprovider-v1.0.2.zip)  | 
|  1.0.1  |  新增對 net5、net6 和 SSO 設定檔的支援  |  03/05/2022  |  [下載 v1.0.1](https://a.co/cAIkhV1)  | 
|  1.0.0  |  初始 CodeArtifact NuGet 登入資料提供者版本  |  11/20/2020  |  [下載 v1.0.0](https://a.co/8b2cENb)  | 

# NuGet 套件名稱、版本和資產名稱標準化
<a name="nuget-name-normalization"></a>

CodeArtifact 會先標準化套件和資產名稱，再存放套件版本，這表示 CodeArtifact 中的名稱或版本可能與發佈套件或資產時提供的名稱或版本不同。

**套件名稱標準化：**CodeArtifact 會將所有字母轉換為小寫，以標準化 NuGet 套件名稱。

**套件版本標準化：**CodeArtifact 使用與 NuGet 相同的模式標準化 NuGet 套件版本。以下資訊來自 NuGet 文件的[標準化版本編號](https://docs.microsoft.com/en-us/nuget/concepts/package-versioning#normalized-version-numbers)。
+ 前導零會從版本編號中移除：
  + `1.00` 被視為 `1.0`
  + `1.01.1` 被視為 `1.1.1`
  + `1.00.0.1` 被視為 `1.0.0.1`
+ 版本編號的第四部分會省略零：
  + `1.0.0.0` 被視為 `1.0.0`
  + `1.0.01.0` 被視為 `1.0.1`
+ SemVer 2.0.0 建置中繼資料已移除：
  + `1.0.7+r3456` 被視為 `1.0.7`

**套件資產名稱標準化：**CodeArtifact 會從標準化套件名稱和套件版本建構 NuGet 套件資產名稱。

非標準化套件名稱和版本名稱可與 API 和 CLI 請求搭配使用，因為 CodeArtifact 會對這些請求的套件名稱和版本輸入執行標準化。例如， `--package Newtonsoft.JSON`和 的輸入`--version 12.0.03.0`會標準化，並傳回具有標準化套件名稱 `newtonsoft.json`和 版本的套件`12.0.3`。

您必須在 API 和 CLI 請求中使用標準化套件資產名稱，因為 CodeArtifact 不會在`--asset`輸入上執行標準化。

您必須在 ARNs 中使用標準化名稱和版本。

若要尋找套件的標準化名稱，請使用 `aws codeartifact list-packages`命令。如需詳細資訊，請參閱[列出套件名稱](list-packages.md)。

若要尋找套件的非標準化名稱，請使用 `aws codeartifact describe-package-version`命令。套件的非標準化名稱會在 `displayName` 欄位中傳回。如需詳細資訊，請參閱[檢視和更新套件版本詳細資訊和相依性](describe-package-version.md)。

# NuGet 相容性
<a name="nuget-compatibility"></a>

 本指南包含 CodeArtifact 與不同 NuGet 工具和版本相容性的相關資訊。

**Topics**
+ [一般 NuGet 相容性](#nuget-version-support)
+ [NuGet 命令列支援](#nuget-command-line-support)

## 一般 NuGet 相容性
<a name="nuget-version-support"></a>

AWS CodeArtifact 支援 NuGet 4.8 和更新版本。

AWS CodeArtifact 僅支援 NuGet HTTP 通訊協定的 V3。這表示不支援某些依賴通訊協定 V2 的 CLI 命令。如需詳細資訊，請參閱 [nuget.exe 命令支援](#nuget-command-support) 一節。

AWS CodeArtifact 不支援 PowerShellGet 2.x。

## NuGet 命令列支援
<a name="nuget-command-line-support"></a>

AWS CodeArtifact 支援 NuGet (`nuget.exe`) 和 .NET Core (`dotnet`) CLI 工具。

### nuget.exe 命令支援
<a name="nuget-command-support"></a>

由於 CodeArtifact 僅支援 NuGet HTTP 通訊協定的 V3，因此針對 CodeArtifact 資源使用時，下列命令將無法運作：
+ `list`： `nuget list`命令會顯示來自指定來源的套件清單。若要取得 CodeArtifact 儲存庫中的套件清單，您可以從 CLI AWS 使用 [列出套件名稱](list-packages.md)命令。