Skip to content

Commit

Permalink
chore: 插件开发辅助脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloWRC committed Oct 1, 2024
1 parent 54e9295 commit 71b34dc
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tools/plugin/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
param($quiet=$true)

$ErrorActionPreference = 'Stop'
$scriptPath = $MyInvocation.MyCommand.Definition
$classIslandRoot = "$([System.IO.Path]::GetDirectoryName($scriptPath))\..\..\ClassIsland"


function SetEnvironmentVariable {
param (
$Name,
$Value,
$Scope="User"
)
$out = "$Name = $Value"
Write-Host $out -ForegroundColor DarkGray
[Environment]::SetEnvironmentVariable($Name, $Value, $Scope)
}

Set-Location $classIslandRoot


try {
$quietparams = ""
if ($quiet){
$quietparams = ("-p:WarningLevel=0", "-p:NoWarn=NU1701")
}
dotnet --version
Write-Host "🔧 正在清理…" -ForegroundColor Cyan

dotnet clean ClassIsland.csproj
Write-Host "🔧 正在构建 ClassIsland,这可能需要 1-6 分钟。" -ForegroundColor Cyan
dotnet build ClassIsland.csproj -c Debug -p:Version=$(git describe --tags --abbrev=0) -p:NuGetVersion=$(git describe --tags --abbrev=0) $quietparams
}
catch {
Write-Host "🔥 构建失败" -ForegroundColor Red
return
}


Write-Host "🔧 正在设置开发环境变量…" -ForegroundColor Cyan

SetEnvironmentVariable("ClassIsland_DebugBinaryFile", [System.IO.Path]::GetFullPath("${classIslandRoot}\bin\Debug\net8.0-windows\ClassIsland.exe"))
SetEnvironmentVariable("ClassIsland_DebugBinaryDirectory", [System.IO.Path]::GetFullPath("${classIslandRoot}/bin\Debug\net8.0-windows\"))

Write-Host "构建完成" -ForegroundColor Green
29 changes: 29 additions & 0 deletions tools/plugin/plugindev-init.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function EnvironmentCheckFailed {
param (
$item
)
exit
}

$ErrorActionPreference = "Stop"


Write-Host "欢迎开发 ClassIsland 插件" -ForegroundColor Blue


$scriptPath = $MyInvocation.MyCommand.Definition

cd "$([System.IO.Path]::GetDirectoryName($scriptPath))\..\.."

# Check environment
Write-Host "🔧 正在检查环境…" -ForegroundColor Cyan

# TODO: Check env


Write-Host "您的开发环境可以开发 ClassIsland 插件。" -ForegroundColor Green


# Build ClassIsland

pwsh -ep Bypass -File ./tools/plugin/build.ps1

0 comments on commit 71b34dc

Please sign in to comment.