sigyllly commited on
Commit
00ed759
·
verified ·
1 Parent(s): 1bd78a1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -11
main.py CHANGED
@@ -154,21 +154,20 @@ def generate_script():
154
  with open(project_file_path, 'w') as file:
155
  file.write(project_file_content)
156
 
157
- # Compile the C# project using dotnet build
158
- compile_command = f'dotnet build {project_name}/{project_name}.csproj -c Release -o /app'
 
159
  try:
160
- result = subprocess.run(compile_command, shell=True, check=True, capture_output=True)
 
161
  except subprocess.CalledProcessError as e:
162
- error_message = e.stderr.decode() if e.stderr else "Unknown error"
163
- print(f"Compilation failed: {error_message}") # Log the error for server-side monitoring
164
- return f"Compilation failed: {error_message}", 500
165
-
166
- # Log successful compilation output
167
- print(f"Compilation succeeded: {result.stdout.decode()}")
168
 
169
  # Provide a link to download the compiled executable
170
- exe_path = os.path.join('/app', project_name, 'bin', 'Release', 'net7.0', 'PolymorphicProgram.exe')
171
- return send_file(exe_path, as_attachment=True)
172
 
173
 
174
  # Start the Flask app
 
154
  with open(project_file_path, 'w') as file:
155
  file.write(project_file_content)
156
 
157
+ # Step 10: Compile the C# script using dotnet
158
+ compile_command = f'dotnet build {script_path.replace(".cs", ".csproj")} -c Release -o /app'
159
+
160
  try:
161
+ result = subprocess.run(compile_command, shell=True, check=True, text=True, capture_output=True)
162
+ print(f"Compilation succeeded: {result.stdout}") # Log the successful output
163
  except subprocess.CalledProcessError as e:
164
+ print(f"Compilation failed with return code {e.returncode}") # Log the return code
165
+ print(f"stdout: {e.stdout}") # Log the standard output
166
+ print(f"stderr: {e.stderr}") # Log the standard error
167
+ return f"Compilation failed: {e.stderr.strip()}", 500
 
 
168
 
169
  # Provide a link to download the compiled executable
170
+ return send_file('run.exe', as_attachment=True)
 
171
 
172
 
173
  # Start the Flask app