sigyllly commited on
Commit
dcbff4e
·
verified ·
1 Parent(s): 23a142f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -12
main.py CHANGED
@@ -141,25 +141,21 @@ def generate_script():
141
  with open(script_path, 'w') as file:
142
  file.write(modified_cs)
143
 
144
- # Step 10: Locate csc and compile the C# script
 
 
 
145
  try:
146
- # Find the path to csc
147
- csc_path = subprocess.run(['which', 'csc'], capture_output=True, text=True, check=True).stdout.strip()
148
- except subprocess.CalledProcessError:
149
- return "csc not found. Make sure the .NET SDK is installed.", 500
150
-
151
- # Compile the C# script
152
- compile_command = f'{csc_path} /target:winexe /platform:x64 /out:run.exe {script_path} /win32icon:app.ico /win32manifest:app.manifest'
153
- compile_result = subprocess.run(compile_command, shell=True, check=True, capture_output=True)
154
-
155
- if compile_result.returncode != 0:
156
- return f"Compilation failed: {compile_result.stderr.decode()}", 500
157
 
158
  # Provide a link to download the compiled executable
159
  return send_file('run.exe', as_attachment=True)
160
 
161
 
162
 
 
163
  # Start the Flask app
164
  if __name__ == '__main__':
165
  app.run(host='0.0.0.0', port=7860, debug=True)
 
141
  with open(script_path, 'w') as file:
142
  file.write(modified_cs)
143
 
144
+ # Step 10: Compile the C# script using mcs
145
+ compile_command = f'mcs -target:exe -out:run.exe {script_path} -win32icon:app.ico -win32manifest:app.manifest'
146
+
147
+ # Run the compilation command
148
  try:
149
+ subprocess.run(compile_command, shell=False, check=True)
150
+ except subprocess.CalledProcessError as e:
151
+ return f"Compilation failed: {e}", 500
 
 
 
 
 
 
 
 
152
 
153
  # Provide a link to download the compiled executable
154
  return send_file('run.exe', as_attachment=True)
155
 
156
 
157
 
158
+
159
  # Start the Flask app
160
  if __name__ == '__main__':
161
  app.run(host='0.0.0.0', port=7860, debug=True)