-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish_release.bat
77 lines (58 loc) · 2.33 KB
/
publish_release.bat
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set kms_version=v1.0.0
set projectFile=KOTORModSync.GUI\KOTORModSync.csproj
set publishProfilesDir=KOTORModSync.GUI\Properties\PublishProfiles
set sevenZipPath="C:\Program Files\7-Zip\7z.exe"
:: Remove old builds if they exist.
del /F /Q bin\*.zip
for /d %%x in (bin\publish\*) do rmdir /S /Q "%%x"
for /r "%publishProfilesDir%" %%i in (*.pubxml) do (
set fileName=%%~ni
echo Publishing configuration for '!fileName!'
for /f "tokens=1-3 delims=_" %%a in ("!fileName!") do (
set framework=%%a
set rid=%%b
set lastSection=%%c
)
:: Extract the CPU from the RID
for /f "tokens=2 delims=-" %%a in ("!rid!") do set cpu=%%a
echo Framework: '!framework!'
echo RID: '!rid!'
echo CPU: '!cpu!'
echo Subfolder: '!lastSection!'
:: Build the dotnet publish command with the --framework argument
set publishCommand=dotnet publish %projectFile% -c Release --framework !framework! /p:PublishProfile=!fileName!.pubxml
echo Publish command: !publishCommand!
:: Execute the publish command
call !publishCommand!
set topLevelFolder=KOTORModSync !kms_version!
:: Get the publish folder path
IF "!lastSection!"=="" (
set publishFolder=.\bin\publish\!framework!\!rid!
) ELSE (
set publishFolder=.\bin\publish\!lastSection!\!framework!\!rid!
)
:: Rename for our top level folder for the archive.
rename "!publishFolder!" "!topLevelFolder!"
IF "!lastSection!"=="" (
set publishFolder=.\bin\publish\!framework!\!topLevelFolder!
) ELSE (
set publishFolder=.\bin\publish\!lastSection!\!framework!\!topLevelFolder!
)
:: Ensure 'docs' folder exists inside the publishFolder
if not exist "!publishFolder!\docs" mkdir "!publishFolder!\docs"
:: Copy the license and documentation into the 'docs' folder
copy /Y "LICENSE.TXT" "!publishFolder!\docs"
copy /Y "KOTORModSync - Official Documentation.txt" "!publishFolder!\docs"
:: Define the archive file path
set archiveFile=bin\!rid!.zip
:: Create the archive using 7zip CLI
%sevenZipPath% a -tzip "!archiveFile!" "!publishFolder!*"
:: Remove the leftover folder
rmdir /S /Q "!publishFolder!"
echo Publishing with framework '!framework!' completed successfully.
)
echo Built all targets.
pause
ENDLOCAL