

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

# 安裝 Guard for Windows
<a name="setting-up-windows"></a>

您可以透過 Cargo 或 Chocolatey AWS CloudFormation Guard 為 Windows 安裝 。

## 先決條件
<a name="w2aab8c16b5"></a>

若要從命令列界面建置 Guard，您必須安裝 Build Tools for Visual Studio 2019。

1. 從[適用於 Visual Studio 的建置工具 2019 網站下載 Microsoft Visual C\+\+ 建置工具](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019)。

1. 執行安裝程式，然後選取預設值。

## 從 Cargo 安裝 Guard
<a name="install-guard-from-cargo"></a>

Cargo 是 Rust 套件管理員。完成下列步驟以安裝 Rust，其中包含 Cargo。然後，從 Cargo 安裝 Guard。

1. [下載 Rust](https://forge.rust-lang.org/infra/other-installation-methods.html#other-ways-to-install-rustup)，然後執行 **rustup-init.exe。**

1. 從命令提示字元中，選擇 **1**，這是預設選項。

   命令會傳回下列輸出：

   ```
   Rust is installed now. Great!
       
       To get started you may need to restart your current shell.
       This would reload its PATH environment variable to include
       Cargo's bin directory (%USERPROFILE%\.cargo\bin).
       
       Press the Enter key to continue.
   ```

1. 若要完成安裝，請按 **Enter** 鍵。

1. 安裝 Cargo 後，請執行下列命令來安裝 Guard。

   ```
   cargo install cfn-guard
   ```

   *結果*：您已成功安裝 Guard。

   1. （選用） 若要確認 Guard 的安裝，請執行下列命令。

     ```
     cfn-guard --version
     ```

     命令會傳回下列輸出：

     ```
     cfn-guard 3.1.2
     ```

## 從 Chocolatey 安裝 Guard
<a name="install-guard-from-chocolatey"></a>

Chocolatey 是 Windows 的套件管理員。完成下列步驟以安裝 Chocolatey。然後，從 Chocolatey 安裝 Guard。

1. 遵循本指南安裝 [Chocolatey](https://chocolatey.org/install)

1. 安裝 Chocolatey 後，請執行下列命令來安裝 Guard。

   ```
   choco install cloudformation-guard
   ```

   *結果*：您已成功安裝 Guard。

   1. （選用） 若要確認 Guard 的安裝，請執行下列命令。

     ```
     cfn-guard --version
     ```

     命令會傳回下列輸出：

     ```
     cfn-guard 3.1.2
     ```