Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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 |
-
|
158 |
-
compile_command = f'dotnet build {
|
|
|
159 |
try:
|
160 |
-
result = subprocess.run(compile_command, shell=True, check=True, capture_output=True)
|
|
|
161 |
except subprocess.CalledProcessError as e:
|
162 |
-
|
163 |
-
print(f"
|
164 |
-
|
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 |
-
|
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
|