> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Diversion と Horde のセットアップ（Windows、UE5 ソース）

> Diversion SCM を Horde に接続し、Horde CI 向けに UE5 ソースリポジトリを準備するためのクイックスタート。

<Note>Horde 連携は **[Studio](https://www.diversion.dev/pricing)** および **[Enterprise](https://www.diversion.dev/pricing)** プランで利用可能です。Diversion Horde インストールファイルのコピーを受け取るには、[お問い合わせ](mailto:support@diversion.dev) ください。</Note>

## 前提条件

* **Horde Server** および **Horde Agent** マシン（Windows）への管理者アクセス。
* Epic↔GitHub のリンクされたアカウントを通じた **GitHub 上の UE ソース** へのアクセス。

  これは Horde 全般の要件であり、Horde のビルドステップではエンジンソースと UAT や UBT などのツールへのアクセスが必要になるためです。

**このガイドは、Horde とその一般的なセットアップ手順に十分な知識があることを前提としています。**

***

## 1) Diversion をインストールしサインインする（Server + Agents）

1. Horde Server と **すべての Horde Agent** で、Diversion for Windows インストーラーを実行します。
2. Server と Agent の両方で Diversion を起動してサインインし、連携が UE5 ソースリポジトリに適切にアクセスできるようにします。

***

## 2) Diversion で UE5 ソースリポジトリを準備する（Windows）

### 2.1 Unreal Engine ソースをクローンする

GitHub アクセスの取得と UE のクローンについては、Epic の手順に従ってください:

* [UE on GitHub](https://www.unrealengine.com/en-US/ue-on-github)
* [Downloading Unreal Engine Source Code](https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine)

### 2.2 クローンした UE リポジトリから `.gitignore` ファイルを削除する

Git 固有の無視動作が Diversion の追跡と干渉しないようにするため、**UE リポジトリのルートから** 実行します。

```cmd theme={null}
for /r %f in (.gitignore) do @del "%f"
```

<Card title="推奨" icon="check" iconType="duotone" color="#0b8a42">
  `.gitignore` ファイルは、お好みの方法で削除できます（エクスプローラーの検索 + 削除、PowerShell、サードパーティツールなど）。上記の CMD ループを推奨するのは、再帰的で堅牢、Windows で扱いやすく、ネストされたフォルダーを確実に処理し、一般的な glob の癖を回避できるためです。必ず UE リポジトリのルートから実行してください。
</Card>

### 2.3 `.dvignore` を作成する（Diversion 初期化前）

UE リポジトリのルートに、このスターターで **`.dvignore`** を作成します（スタジオに合わせて調整してください）:

```ini theme={null}
# Epic's .dvignore file (converted from gitignore)
# Note: Diversion tracks directories as well as files
# - Uses same glob patterns as gitignore
# - ** pattern for recursive directory matching
# - Patterns are relative to .dvignore location

# Ignore root Visual Studio solution files only
*.sln

.p4sync.txt

# Visual Studio temp files
*.suo
*.opensdf
*.sdf

# Engine DerivedDataCache
/Engine/DerivedDataCache/*
**/DerivedDataCache/Boot.ddc
**/DerivedDataCache/**/*.udd

# Ignore all Intermediate and Saved directories
**/Intermediate/
**/Saved/

# UBT configuration
/Engine/Programs/UnrealBuildTool/
*.uatbuildrecord
*.tmp

# Build output
**/obj/
*.csprojAssemblyReference.cache

# UBT log files
/Engine/Programs/UnrealBuildTool/*.txt

# Python cache
*.pyc
__pycache__/

# JetBrains IDE
.idea/
!.idea/runConfigurations/
.gradle/

# HoloLens WMRInterop autogenerated files
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/packages/
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInteropHoloLens/Generated Files/
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInteropHoloLens/x64/
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInteropHoloLens/ARM64/
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInterop/x64/
/Engine/Source/ThirdParty/WindowsMixedRealityInterop/MixedRealityInterop/ARM64/

# macOS Finder files
.DS_Store

# VS Code workspace files
*.code-workspace

.vs
```

<Card title="警告！" icon="triangle-exclamation" iconType="duotone" color="#ca8b04">
  初回スキャンをより簡単で高速にするため、Diversion リポジトリを初期化する **前** に `.dvignore` を作成してください。

  `.dvignore` はリポジトリのルート配下に置く必要があります。
</Card>

### 2.4 UE のセットアップスクリプトを実行する（Windows）

UE ソースのルートから、次を実行します:

```cmd theme={null}
Setup.bat
GenerateProjectFiles.bat
```

### 2.5 UE 用の Diversion リポジトリを初期化する

1. **UE リポジトリのルートで** Diversion リポジトリを初期化します（Diversion CLI または UI）。
2. `.dvignore` が適用されていることを確認します（キャッシュ / 中間ファイルが追跡対象外のままであること）。

### 2.6 このソースツリーに UE **プロジェクト** を追加する

このソースエンジンに対してコンパイルされるゲームプロジェクトを、想定されるパス（多くの場合、UE リポジトリのルート、または BuildGraph が想定する同階層のパス）に配置します。必要なファイルを Diversion にコミットします。

***

## 3) Horde ストリームを Diversion リポジトリ/ブランチに向ける

これは、UE5 ソースリポジトリの準備（セクション 2）の **後** に行います。

Horde 設定ディレクトリ配下のストリーム設定（`*.stream.json`）を編集します:

* `C:\\ProgramData\\Epic\\Horde\\Server\\`

**`name`** フィールドが Diversion リポジトリとブランチをターゲットにしていることを確認します:

```json theme={null}
// Diversion‑required: set the repo id and branch name
"name": "//<repo-id>/<branch>"
```

> 構成が分割されている場合（globals → project → stream）、`name` は UE ソースストリームを表す **stream** JSON に配置してください。

***

## 4) UE ソースストリーム用に Horde を構成する

1. Horde 設定ファイルが `C:\\ProgramData\\Epic\\Horde\\Server\\` 配下にあることを確認します。
2. プロジェクト（`*.project.json`）がストリーム（`*.stream.json`）を参照していることを確認します。
3. ストリーム JSON で、Diversion リポジトリとブランチのマッピングを設定し（*セクション 3 参照*）、適切なジョブテンプレート（BuildGraph）とその他の Horde の一般要件を定義します。
4. パイプラインが正しく設定されたことを検証するため、まずは最小限のエディター専用の BuildGraph ジョブから始めます。

> Horde の設定スタックは **Globals → Projects → Streams** の順です。`.project.json`/`.stream.json` 拡張子を使用することで、JSON スキーマツールを有効にできます。

***

## 5) スモークテスト

* 構成を保存した後、Horde を再起動またはホットリロードします。
* Horde ダッシュボードでプロジェクト/ストリームを開き、既存の構成に基づく小さな BuildGraph ジョブをキューに投入し、エージェントが Diversion から同期してビルドできることを確認します。

***

## クイックリファレンス（Windows）

* **Git の無視ファイルを削除する**（UE リポジトリのルートから）:

  ```cmd theme={null}
  for /r %f in (.gitignore) do @del "%f"
  ```

* **UE セットアップ**

  ```cmd theme={null}
  Setup.bat
  GenerateProjectFiles.bat
  ```

***

## 参考資料

* **[UE on GitHub](https://www.unrealengine.com/en-US/ue-on-github)** — Epic↔GitHub アカウントの連携
* **[Download UE Source](https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine)** — 公式ガイド
* **[Build UE from Source](https://dev.epicgames.com/documentation/en-us/unreal-engine/building-unreal-engine-from-source)** — Windows 向けの注意事項
* **[Horde（概要）](https://dev.epicgames.com/documentation/en-us/unreal-engine/horde-in-unreal-engine)** — 概要ドキュメント
* **[Horde Orientation](https://dev.epicgames.com/documentation/en-us/unreal-engine/horde-orientation-for-unreal-engine)** — スキーマサーバー、構成
* **[Horde Build Automation（概要）](https://dev.epicgames.com/documentation/en-us/unreal-engine/horde-build-automation-for-unreal-engine)** — ビルド自動化の概要
* **[Horde Build Automation（チュートリアル）](https://dev.epicgames.com/documentation/en-us/unreal-engine/horde-build-automation-tutorial-for-unreal-engine)** — ビルド自動化のチュートリアル
