| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- param(
- [switch]$StartServices
- )
- $ErrorActionPreference = "Stop"
- function Write-Step($msg) {
- Write-Host "[AIDOP INIT] $msg"
- }
- function Test-Command($name) {
- return [bool](Get-Command $name -ErrorAction SilentlyContinue)
- }
- function Invoke-Checked($command, [string[]]$arguments) {
- & $command @arguments
- if ($LASTEXITCODE -ne 0) {
- throw "$command failed with exit code $LASTEXITCODE"
- }
- }
- Write-Step "Workspace: $(Get-Location)"
- if (-not (Test-Command "dotnet")) {
- throw "dotnet not found. Please install .NET SDK 8.x first."
- }
- $dotnetVersion = (dotnet --version)
- Write-Step "dotnet version: $dotnetVersion"
- if (-not (Test-Command "node")) {
- throw "node not found. Please install Node.js >=18 first."
- }
- $nodeVersion = (node --version)
- Write-Step "node version: $nodeVersion"
- $webDir = "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/Web"
- $entryDir = "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/server/Admin.NET.Web.Entry"
- if (-not (Test-Path $webDir)) { throw "Web directory not found: $webDir" }
- if (-not (Test-Path $entryDir)) { throw "Web.Entry directory not found: $entryDir" }
- Write-Step "Install frontend dependencies + hooks"
- Push-Location $webDir
- try {
- if (Test-Command "pnpm") {
- Invoke-Checked "pnpm" @("install")
- } else {
- Write-Step "pnpm not found, fallback to npm install --legacy-peer-deps"
- Invoke-Checked "npm" @("install", "--legacy-peer-deps")
- }
- Invoke-Checked "npm" @("run", "prepare")
- } finally {
- Pop-Location
- }
- Write-Step "Build backend core (net8.0)"
- Invoke-Checked "dotnet" @("build", "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/server/Admin.NET.Core/Admin.NET.Core.csproj", "--framework", "net8.0")
- if ($StartServices) {
- Write-Step "Starting backend and frontend services"
- Start-Process powershell -ArgumentList "-NoExit", "-Command", "Set-Location '$entryDir'; dotnet run --framework net8.0"
- Start-Process powershell -ArgumentList "-NoExit", "-Command", "Set-Location '$webDir'; npm run dev"
- Write-Step "Services started. Backend: http://localhost:5005 Frontend: http://localhost:8888"
- }
- Write-Step "Initialization complete."
|