Project.Fengling.QoderVersion/Backend/vs-snippets/Install-VSSnippets.ps1
sam e24925e1ed chore(build): 添加基础构建配置和版本管理
- 新增 .dockerignore 文件,忽略多种临时及中间文件
- 新增 .gitattributes 文件,配置文本文件换行及合并行为
- 新增详细的 .gitignore 文件,排除多种开发及生成文件
- 新增 VS Code C# 代码片段,提升开发效率
- 添加 Directory.Build.props,统一 MSBuild 配置和代码分析规则
- 添加空的 Directory.Build.targets,预留构建任务扩展位置
- 添加 Directory.Packages.props,实现依赖包版本集中管理和声明
2026-02-11 12:58:54 +08:00

84 lines
3.3 KiB
PowerShell

# NetCorePal Template - Visual Studio Code Snippets Installer
# Auto install Visual Studio code snippets
param(
[string]$VisualStudioVersion = "2022",
[switch]$ShowPathOnly
)
$ErrorActionPreference = "Stop"
Write-Host "NetCorePal Template - Visual Studio Code Snippets Installer" -ForegroundColor Green
Write-Host "=================================================" -ForegroundColor Green
# Get current script directory
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$SnippetFile = Join-Path $ScriptDir "NetCorePalTemplates.snippet"
# Check if snippet file exists
if (-not (Test-Path $SnippetFile)) {
Write-Error "Snippet file not found: $SnippetFile"
exit 1
}
# Build Visual Studio snippets directory path
$VSSnippetsPath = "$env:USERPROFILE\Documents\Visual Studio $VisualStudioVersion\Code Snippets\Visual C#\My Code Snippets"
Write-Host "Target directory: $VSSnippetsPath" -ForegroundColor Yellow
# If only showing path, don't execute installation
if ($ShowPathOnly) {
Write-Host ""
Write-Host "Manual installation steps:" -ForegroundColor Cyan
Write-Host "1. Ensure target directory exists: $VSSnippetsPath" -ForegroundColor White
Write-Host "2. Copy file: $SnippetFile" -ForegroundColor White
Write-Host "3. To target directory: $VSSnippetsPath" -ForegroundColor White
Write-Host "4. Restart Visual Studio" -ForegroundColor White
Write-Host ""
Write-Host "Or use Tools > Code Snippets Manager > Import in Visual Studio" -ForegroundColor Yellow
return
}
# Create directory if it doesn't exist
if (-not (Test-Path $VSSnippetsPath)) {
Write-Host "Creating snippets directory..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path $VSSnippetsPath -Force | Out-Null
}
# Copy snippet file
$DestinationFile = Join-Path $VSSnippetsPath "NetCorePalTemplates.snippet"
try {
Copy-Item -Path $SnippetFile -Destination $DestinationFile -Force
Write-Host "Code snippets installed successfully!" -ForegroundColor Green
Write-Host " Source file: $SnippetFile" -ForegroundColor Gray
Write-Host " Target file: $DestinationFile" -ForegroundColor Gray
Write-Host ""
Write-Host "Available snippet shortcuts:" -ForegroundColor Cyan
Write-Host " postproc - PostProcessor class" -ForegroundColor White
Write-Host " tstclass - Test class" -ForegroundColor White
Write-Host " ncpcmd - NetCorePal command" -ForegroundColor White
Write-Host " ncpcmdres - Command response" -ForegroundColor White
Write-Host " evnt - Domain event" -ForegroundColor White
Write-Host " ncprepo - Repository interface" -ForegroundColor White
Write-Host " epp - FastEndpoint" -ForegroundColor White
Write-Host ""
Write-Host "Usage:" -ForegroundColor Cyan
Write-Host "1. Open C# file in Visual Studio" -ForegroundColor White
Write-Host "2. Type shortcut (like 'postproc')" -ForegroundColor White
Write-Host "3. Press Tab key twice" -ForegroundColor White
Write-Host "4. Fill parameters and press Tab to switch to next parameter" -ForegroundColor White
Write-Host ""
Write-Host "Note: If Visual Studio is running, restart it to load new snippets." -ForegroundColor Yellow
}
catch {
Write-Error "Installation failed: $($_.Exception.Message)"
exit 1
}
Write-Host ""
Write-Host "Installation completed!" -ForegroundColor Green