-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.ps1
More file actions
42 lines (35 loc) · 1.34 KB
/
publish.ps1
File metadata and controls
42 lines (35 loc) · 1.34 KB
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
42
# Author: Giancarlo Trevisan
# Date: 2025-06-05
# Description:
# This script increments the patch version in FillODT.csproj, publishes the project for win-x64,
# renames and zips the output folder, and moves the zip to the current directory.
# 1. Increment patch version in FillODT.csproj
$csproj = Join-Path $pwd.Path "FillODT.csproj"
[xml]$proj = Get-Content $csproj -Raw
# Find the Version node
$versionNode = $proj.GetElementsByTagName("Version")[0]
$version = $versionNode.InnerText
$parts = $version.split('.')
$parts[2] = ([int]$parts[2] + 1).ToString()
$newVersion = "$($parts[0]).$($parts[1]).$($parts[2])"
$versionNode.InnerText = $newVersion
$proj.Save($csproj)
# 2. Publish
dotnet publish -c Release -r win-x64
# 3. Rename publish folder
$publishDir = Join-Path $pwd.Path "\bin\Release\net9.0\win-x64\publish"
$targetDir = "FillODT.v$newVersion.win-x64"
if (Test-Path $publishDir.Replace("publish", $targetDir)) {
Remove-Item $publishDir.Replace("publish", $targetDir) -Recurse -Force
}
Rename-Item $publishDir $targetDir
$publishDir = $publishDir.Replace("publish", $targetDir)
# 4. Zip the folder
$zipFile = "$publishDir.zip"
if (Test-Path $zipFile) {
Remove-Item $zipFile -Force
}
Compress-Archive -Path $publishDir\* -DestinationPath $zipFile
# 5. Clean up
Remove-Item $publishDir -Recurse -Force
Move-Item -Path $zipFile -Destination $pwd