sigyllly commited on
Commit
8491b72
·
verified ·
1 Parent(s): 838901f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -4
main.py CHANGED
@@ -154,18 +154,21 @@ def generate_script():
154
  with open(project_file_path, 'w') as file:
155
  file.write(project_file_content)
156
 
157
- # Step 10: Compile the C# project using dotnet build
158
  compile_command = f'dotnet build {project_name}/{project_name}.csproj -c Release -o /app'
159
- result = subprocess.run(compile_command, shell=True, check=False, capture_output=True)
160
 
161
- # Check the result of the compilation
162
  if result.returncode != 0:
163
- return f"Compilation failed: {result.stderr.decode()}", 500
 
 
164
 
165
  # Provide a link to download the compiled executable
166
  exe_path = os.path.join('/app', project_name, 'bin', 'Release', 'net7.0', 'PolymorphicProgram.exe')
167
  return send_file(exe_path, as_attachment=True)
168
 
 
169
  # Start the Flask app
170
  if __name__ == '__main__':
171
  app.run(host='0.0.0.0', port=7860, debug=True)
 
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
+ result = subprocess.run(compile_command, shell=True, check=True, capture_output=True)
160
 
161
+ # Log the output of the compilation command for debugging
162
  if result.returncode != 0:
163
+ error_message = result.stderr.decode() if result.stderr else "Unknown error"
164
+ print(f"Compilation failed: {error_message}")
165
+ return f"Compilation failed: {error_message}", 500
166
 
167
  # Provide a link to download the compiled executable
168
  exe_path = os.path.join('/app', project_name, 'bin', 'Release', 'net7.0', 'PolymorphicProgram.exe')
169
  return send_file(exe_path, as_attachment=True)
170
 
171
+
172
  # Start the Flask app
173
  if __name__ == '__main__':
174
  app.run(host='0.0.0.0', port=7860, debug=True)