1+ import shutil
2+ from os import listdir , remove , mkdir
3+ from os .path import isfile , join , exists
4+
5+ # List of ignored dlls (in lowercase)
6+ ignore = [
7+ 'openal32.dll' ,
8+ ]
9+
10+ # Path settings
11+ in_path = '../bin/net8.0'
12+ out_path = '../bin/net8.0'
13+ out_directory = 'engine'
14+ out_full_path = f'{ out_path } /{ out_directory } /'
15+
16+ # Archive settings
17+ archive_name = f'{ out_directory } '
18+ archive_type = 'zip'
19+ archive_directory = f'{ out_path } /'
20+ archive_location = f'{ archive_directory } { archive_name } .{ archive_type } '
21+
22+ # Import file settings
23+ import_file_name = 'EngineImports.props'
24+ import_file_location = f'{ out_full_path } { import_file_name } '
25+
26+ # Getting all files
27+ files = [file for file in listdir (in_path ) if isfile (join (in_path , file ))]
28+
29+ # Remove previous build
30+ if exists (out_full_path ):
31+ shutil .rmtree (out_full_path )
32+
33+ if exists (archive_location ):
34+ remove (archive_location )
35+
36+ # Creating new dictionary
37+ mkdir (f'{ out_path } /{ out_directory } ' )
38+
39+ # Copy files and generate
40+ import_content = '<Project>\n <ItemGroup>\n '
41+ for file in files :
42+ if not file .endswith ('.dll' ):
43+ continue
44+
45+ if file .lower () in ignore :
46+ continue
47+
48+ file_name = file .replace ('.dll' , '' )
49+ import_content += f' <Reference Include="{ file_name } ">\n <HintPath>..\engine\{ file } </HintPath>\n </Reference>\n '
50+ shutil .copy2 (f'{ in_path } /{ file } ' , f'{ out_full_path } { file } ' )
51+ import_content += ' </ItemGroup>\n </Project>'
52+
53+ # Create import file
54+ with open (import_file_location , 'w' ) as file :
55+ file .write (import_content )
56+
57+ # Create archive
58+ shutil .make_archive (f'{ archive_directory } { archive_name } ' , archive_type , archive_directory )
0 commit comments