-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.ps1
41 lines (31 loc) · 1.43 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Uses dotnet to compile the release version of the plugin. A distributable zip will be placed in your working dir.
$version = "2.0.1"
$workingDir = Get-Location
# Compile the solution using dotnet and check for success
$buildToolPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe"
$buildResult = & $buildToolPath .\Tebex-TorchAPI\Tebex-TorchAPI.sln -p:Configuration=Release
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet build failed with exit code $LASTEXITCODE"
Write-Error $buildResult
exit $LASTEXITCODE
}
# Change to the release directory
Set-Location -Path .\Tebex-TorchAPI\bin\x64\Release
# Rename the DLL file
if (Test-Path -Path "Tebex-TorchAPI-$version.dll") {
Remove-Item -Path "Tebex-TorchAPI-$version.dll"
}
Rename-Item -Path "TebexTorchAPI.dll" -NewName "Tebex-TorchAPI-$version.dll"
# Remove existing zip file if it exists
$zipPath = "Tebex-TorchAPI-$version.zip"
if (Test-Path -Path $zipPath) {
Remove-Item -Path $zipPath
}
# Create a new zip file
Compress-Archive -Path "Tebex-TorchAPI-$version.dll" -DestinationPath $zipPath
# Move the zip file to the original working directory
Move-Item -Path $zipPath -Destination $workingDir
# Return to the original working directory
Set-Location -Path $workingDir
# Write a success message
Write-Output "Build and packaging completed successfully. The distributable zip is located at $workingDir\Tebex-TorchAPI-$version.zip"