90 lines
3.5 KiB
PowerShell
90 lines
3.5 KiB
PowerShell
# Navisworks Transport Plugin 部署脚本
|
||
# 用于将编译后的插件文件复制到Navisworks 2026插件目录
|
||
|
||
param(
|
||
[switch]$Debug = $false # 是否包含调试文件
|
||
)
|
||
|
||
# 定义路径
|
||
$sourceDir = ".\bin\Debug"
|
||
$pluginDll = "$sourceDir\NavisworksTransportPlugin.dll"
|
||
$pluginPdb = "$sourceDir\NavisworksTransportPlugin.pdb"
|
||
$localizationFile = "$sourceDir\src\Resources\NavisworksTransport.Tian.name.txt"
|
||
|
||
# 目标目录
|
||
$systemPluginDir = "${env:ProgramFiles}\Autodesk\Navisworks Manage 2026\Plugins\NavisworksTransportPlugin"
|
||
|
||
Write-Host "=== Navisworks Transport Plugin 部署工具 ===" -ForegroundColor Green
|
||
Write-Host ""
|
||
|
||
# 检查源文件是否存在
|
||
if (-not (Test-Path $pluginDll)) {
|
||
Write-Host "错误: 找不到插件文件 $pluginDll" -ForegroundColor Red
|
||
Write-Host "请先编译项目: dotnet build NavisworksTransportPlugin.csproj" -ForegroundColor Yellow
|
||
exit 1
|
||
}
|
||
|
||
# 使用标准插件目录
|
||
$targetDir = $systemPluginDir
|
||
Write-Host "部署到Navisworks插件目录: $targetDir" -ForegroundColor Yellow
|
||
Write-Host "注意: 需要管理员权限" -ForegroundColor Yellow
|
||
|
||
# 创建目标目录
|
||
try {
|
||
if (-not (Test-Path $targetDir)) {
|
||
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
|
||
Write-Host "✓ 创建目录: $targetDir" -ForegroundColor Green
|
||
}
|
||
|
||
# 创建资源子目录
|
||
$resourcesTargetDir = "$targetDir\src\Resources"
|
||
if (-not (Test-Path $resourcesTargetDir)) {
|
||
New-Item -ItemType Directory -Path $resourcesTargetDir -Force | Out-Null
|
||
Write-Host "✓ 创建资源目录: $resourcesTargetDir" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host "错误: 无法创建目录 $targetDir" -ForegroundColor Red
|
||
Write-Host "错误详情: $($_.Exception.Message)" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
# 复制文件
|
||
try {
|
||
# 复制主插件文件
|
||
Copy-Item $pluginDll $targetDir -Force
|
||
Write-Host "✓ 复制插件文件: NavisworksTransportPlugin.dll" -ForegroundColor Green
|
||
|
||
# 复制调试文件(如果需要)
|
||
if ($Debug -and (Test-Path $pluginPdb)) {
|
||
Copy-Item $pluginPdb $targetDir -Force
|
||
Write-Host "✓ 复制调试文件: NavisworksTransportPlugin.pdb" -ForegroundColor Green
|
||
}
|
||
|
||
# 复制本地化文件
|
||
if (Test-Path $localizationFile) {
|
||
Copy-Item $localizationFile $resourcesTargetDir -Force
|
||
Write-Host "✓ 复制本地化文件: NavisworksTransport.Tian.name.txt" -ForegroundColor Green
|
||
}
|
||
|
||
} catch {
|
||
Write-Host "错误: 复制文件失败" -ForegroundColor Red
|
||
Write-Host "错误详情: $($_.Exception.Message)" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "🎉 插件部署成功!" -ForegroundColor Green
|
||
Write-Host ""
|
||
Write-Host "下一步操作:" -ForegroundColor Yellow
|
||
Write-Host "1. 启动 Navisworks Manage 2026" -ForegroundColor White
|
||
Write-Host "2. 在菜单中查找 '物流路径规划' 面板" -ForegroundColor White
|
||
Write-Host "3. 如果没有出现,请检查插件管理器中是否已加载" -ForegroundColor White
|
||
Write-Host ""
|
||
Write-Host "插件位置: $targetDir" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# 显示Navisworks插件管理器信息
|
||
Write-Host "💡 提示:" -ForegroundColor Yellow
|
||
Write-Host "- 如果插件没有自动加载,请在Navisworks中打开 '主页' > '插件管理器'" -ForegroundColor White
|
||
Write-Host "- 确保 'NavisworksTransportPlugin' 已启用" -ForegroundColor White
|
||
Write-Host "- 插件将显示为可停靠面板,而不是在附加模块选项卡中" -ForegroundColor White |