Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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 |
-
|
158 |
compile_command = f'dotnet build {project_name}/{project_name}.csproj -c Release -o /app'
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
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')
|