Newer
Older
TIASshot / setup.ps1
# =============================================================================
# TIASshot 開発環境セットアップスクリプト
# 実行方法: PowerShell を管理者権限で開き,以下を実行する
#   Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
#   .\setup.ps1
# =============================================================================

$ErrorActionPreference = "Stop"

Write-Host "========================================" -ForegroundColor Cyan
Write-Host " TIASshot 開発環境セットアップ"          -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""

# -----------------------------------------------------------------------------
# Step 1: Visual Studio 2022 のインストール
# -----------------------------------------------------------------------------
Write-Host "[Step 1] Visual Studio 2022 のインストール確認..." -ForegroundColor Yellow

$vsInstalled = Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" `
    -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*Visual Studio*2022*" }
if ($vsInstalled) {
    Write-Host "  Visual Studio はインストール済みです.スキップします." -ForegroundColor Green
} else {
    Write-Host "  Visual Studio 2022 をインストールします..." -ForegroundColor White
    $vsconfigPath = Join-Path $PSScriptRoot ".vsconfig"
    winget install Microsoft.VisualStudio.2022.Community --no-upgrade `
        --override "--config `"$vsconfigPath`" --quiet --wait"
    Write-Host "  インストール完了." -ForegroundColor Green
}

Write-Host ""

# -----------------------------------------------------------------------------
# Step 2: データ保存フォルダの作成
# -----------------------------------------------------------------------------
Write-Host "[Step 2] データ保存フォルダの作成..." -ForegroundColor Yellow

$dataFolder = "C:\TIAS_Data"
if (Test-Path $dataFolder) {
    Write-Host "  $dataFolder は既に存在します.スキップします." -ForegroundColor Green
} else {
    New-Item -ItemType Directory -Path $dataFolder | Out-Null
    Write-Host "  $dataFolder を作成しました." -ForegroundColor Green
}

Write-Host ""

# -----------------------------------------------------------------------------
# Step 3: NuGet パッケージの復元
# -----------------------------------------------------------------------------
Write-Host "[Step 3] NuGet パッケージの復元..." -ForegroundColor Yellow

$slnPath = Join-Path $PSScriptRoot "TIASshot.sln"
if (Test-Path $slnPath) {
    # nuget.exe が PATH になければリポジトリルートにダウンロードして使用する
    $nugetCmd = Get-Command nuget.exe -ErrorAction SilentlyContinue
    if ($nugetCmd) {
        $nugetExe = "nuget.exe"
    } else {
        $nugetExe = Join-Path $PSScriptRoot "nuget.exe"
        if (-not (Test-Path $nugetExe)) {
            Write-Host "  nuget.exe をダウンロードします..." -ForegroundColor White
            Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" `
                -OutFile $nugetExe
        }
    }
    & $nugetExe restore $slnPath
    Write-Host "  NuGet パッケージの復元が完了しました." -ForegroundColor Green
} else {
    Write-Host "  TIASshot.sln が見つかりません.手動で復元してください." -ForegroundColor Red
}

Write-Host ""

# -----------------------------------------------------------------------------
# Step 4: IC Imaging Control SDK(手動インストール案内)
# -----------------------------------------------------------------------------
Write-Host "[Step 4] IC Imaging Control SDK のインストール案内..." -ForegroundColor Yellow
Write-Host "  IC Imaging Control SDK は手動インストールが必要です."  -ForegroundColor White
Write-Host "  ブラウザで The Imaging Source のダウンロードページを開きます." -ForegroundColor White
Write-Host ""
$response = Read-Host "  ダウンロードページを開きますか? (y/N)"
if ($response -eq "y" -or $response -eq "Y") {
    Start-Process "https://www.theimagingsource.com/en-us/support/download/"
}

Write-Host ""

# -----------------------------------------------------------------------------
# 完了メッセージ
# -----------------------------------------------------------------------------
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " セットアップが完了しました"             -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "次の手順を手動で実施してください:" -ForegroundColor Yellow
Write-Host "  1. IC Imaging Control SDK のインストール(Step 4 参照)"
Write-Host "  2. TIASshot.sln を Visual Studio 2022 で開いてビルド確認"
Write-Host "  3. config.xml・カメラ設定ファイル・CSV ファイルの配置"
Write-Host "     (詳細は docs\02_ENV\ENV_01_開発環境構築手順.md を参照)"
Write-Host ""