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

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -7
main.py CHANGED
@@ -154,15 +154,17 @@ 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
- 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')
 
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')