-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReleaseBuilder.py
101 lines (72 loc) · 3.2 KB
/
ReleaseBuilder.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import shutil
import subprocess
import os
import time
from win32com.client import Dispatch
def SetupRelease():
print("Setting up Release")
# Create a folder for the new release
shutil.copytree('Release-Template', ReleaseFolder)
def DeleteOldBuildResults():
print("Deleting old Build Results")
# Clear each projects /bin folder
for BinFolderPath in BuildBinFolderPaths:
# Check that folder exists
if os.path.isdir(BinFolderPath):
shutil.rmtree(BinFolderPath)
def BuildProjects():
print("Building Projects")
# Build each project
for ProjectPath in ProjectsPath:
subprocess.call([MSBuild, ProjectPath, Arg1])
def MoveBuildResults():
print("Moving Build Results")
# Copy each build folder to the created release folder
for i in range(2):
shutil.copytree(BuildSourcePaths[i], BuildDestinationPaths[i])
def CreateShortcuts():
print("Creating Shortcuts")
# Create a shortcut to each .exe
shell = Dispatch('WScript.Shell')
for i in range(2):
shortcut = shell.CreateShortCut(ShortcutDestinationPaths[i]) # Location where the Shortcut is created
shortcut.Targetpath = ShortcutSourcePaths[i] # What the Shortcut links too
shortcut.save()
def ReleaseBuildFinished(Start, End):
# Calulate how long the ReleaseBuild took, with 2 decimals
Time = str(round(End - Start, 2))
print("___________________________________")
print(f"\nFinished Release in {Time} seconds")
print(f'\nBuild location: {ScriptPath}\{ReleaseFolder}')
print("___________________________________")
def CreateRelease():
Start = time.time()
SetupRelease()
DeleteOldBuildResults()
BuildProjects()
MoveBuildResults()
CreateShortcuts()
End = time.time()
ReleaseBuildFinished(Start, End)
# Write out header
print("___________________________________")
print("\nReleaseBuilder v1.1.0")
print("___________________________________")
# Set all variables
ScriptPath = os.getcwd()
ReleaseName = input("\nName of Release: ")
ReleaseFolder = f'Releases\{ReleaseName}'
ProjectsPath = [f'{ScriptPath}\SpeedrunNotes\SpeedrunNotes.csproj', f'{ScriptPath}\SpeedrunNotesEditor\SpeedrunNotesEditor.csproj']
BuildSourcePaths = [f'{ScriptPath}/SpeedrunNotes/bin/Release/net7.0-windows10.0.19041.0/win10-x64', f'{ScriptPath}/SpeedrunNotesEditor/bin/Release/net7.0-windows10.0.19041.0/win10-x64']
BuildBinFolderPaths = [f'{ScriptPath}/SpeedrunNotes/bin', f'{ScriptPath}/SpeedrunNotesEditor/bin']
BuildDestinationPaths = [f'{ReleaseFolder}/SpeedrunNotes', f'{ReleaseFolder}/SpeedrunNotesEditor']
ShortcutSourcePaths = [f'{BuildSourcePaths[0]}\SpeedrunNotes.exe', f'{BuildSourcePaths[1]}\SpeedrunNotesEditor.exe']
ShortcutDestinationPaths = [f'{ReleaseFolder}\SpeedrunNotes.lnk', f'{ReleaseFolder}\SpeedrunNotesEditor.lnk']
MSBuild = r'C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe'
Arg1 = '/p:Configuration=Release'
# Write out more stuff
print("\nProjects to build: \n -SpeedrunNotes \n -SpeedrunNotesEditor")
print(f"\nBuild destination: {ScriptPath}\{ReleaseFolder}")
AAA = input("\nPress Enter to start building the Release")
print("___________________________________")
CreateRelease()