56 lines
1.7 KiB
PowerShell
56 lines
1.7 KiB
PowerShell
# XCamera库编译脚本
|
||
# 需要安装MSBuild和.NET Framework 4.0
|
||
|
||
Write-Host "正在编译XCamera项目..." -ForegroundColor Green
|
||
|
||
# 设置MSBuild路径
|
||
$msbuildPaths = @(
|
||
"${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe",
|
||
"${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe",
|
||
"${env:ProgramFiles(x86)}\MSBuild\14.0\Bin\MSBuild.exe"
|
||
)
|
||
|
||
$msbuild = $null
|
||
foreach ($path in $msbuildPaths) {
|
||
if (Test-Path $path) {
|
||
$msbuild = $path
|
||
break
|
||
}
|
||
}
|
||
|
||
if ($msbuild -eq $null) {
|
||
Write-Host "未找到MSBuild,请安装Visual Studio或.NET Framework SDK" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
Write-Host "使用MSBuild: $msbuild" -ForegroundColor Yellow
|
||
|
||
# 切换到脚本目录
|
||
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||
Set-Location $scriptPath
|
||
|
||
# 还原NuGet包
|
||
Write-Host "正在还原NuGet包..." -ForegroundColor Green
|
||
try {
|
||
nuget.exe restore XCamera.sln
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host "NuGet包还原失败,尝试直接编译..." -ForegroundColor Yellow
|
||
}
|
||
} catch {
|
||
Write-Host "NuGet命令未找到,尝试直接编译..." -ForegroundColor Yellow
|
||
}
|
||
|
||
# 编译项目
|
||
Write-Host "正在编译项目..." -ForegroundColor Green
|
||
& $msbuild XCamera.sln /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal
|
||
|
||
if ($LASTEXITCODE -eq 0) {
|
||
Write-Host "编译成功!" -ForegroundColor Green
|
||
Write-Host "输出文件在: bin\Release\" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host "编译失败!" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
Write-Host "按任意键继续..."
|
||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |