diff --git a/etc/nsjail/execute.cfg b/etc/nsjail/execute.cfg
index c241d68a07d73aa3f50b516be5f27e3d7a6b6ac7..912c24fde1c3c05fcb5dc946b4d66d0d7db278c7 100644
--- a/etc/nsjail/execute.cfg
+++ b/etc/nsjail/execute.cfg
@@ -28,7 +28,7 @@ cgroup_net_cls_parent: "ce-compile"
 cgroup_cpu_parent: "ce-compile"
 
 cgroup_mem_max: 1342177280 # 1.25 GiB
-cgroup_pids_max: 64  # go uses a bunch (probably one per CPU, on my desktop)
+cgroup_pids_max: 72
 cgroup_cpu_ms_per_sec: 1000
 
 mount {
diff --git a/lib/compilers/dotnet.ts b/lib/compilers/dotnet.ts
index 9549138d06039e801cccd4c37f88f4bd6435753b..3a229d541d0b26a311bdd83f132cc78f3165d20f 100644
--- a/lib/compilers/dotnet.ts
+++ b/lib/compilers/dotnet.ts
@@ -46,7 +46,6 @@ class DotNetCompiler extends BaseCompiler {
     private buildConfig: string;
     private clrBuildDir: string;
     private langVersion: string;
-    private compileToBinary = false;
 
     constructor(compilerInfo, env) {
         super(compilerInfo, env);
@@ -94,6 +93,44 @@ class DotNetCompiler extends BaseCompiler {
         ];
     }
 
+    async writeProjectfile(programDir: string, compileToBinary: boolean, sourceFile: string) {
+        const projectFileContent = `<Project Sdk="Microsoft.NET.Sdk">
+            <PropertyGroup>
+                <TargetFramework>${this.targetFramework}</TargetFramework>
+                <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+                <AssemblyName>CompilerExplorer</AssemblyName>
+                <LangVersion>${this.langVersion}</LangVersion>
+                <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
+                <Nullable>enable</Nullable>
+                <OutputType>${compileToBinary ? 'Exe' : 'Library'}</OutputType>
+            </PropertyGroup>
+            <ItemGroup>
+                <Compile Include="${sourceFile}" />
+            </ItemGroup>
+        </Project>
+        `;
+
+        const projectFilePath = path.join(programDir, `CompilerExplorer${this.lang.extensions[0]}proj`);
+        await fs.writeFile(projectFilePath, projectFileContent);
+    }
+
+    override async buildExecutable(compiler, options, inputFilename, execOptions) {
+        const dirPath = path.dirname(inputFilename);
+        const inputFilenameSafe = this.filename(inputFilename);
+        const sourceFile = path.basename(inputFilenameSafe);
+        await this.writeProjectfile(dirPath, true, sourceFile);
+
+        return super.buildExecutable(compiler, options, inputFilename, execOptions);
+    }
+
+    override async doCompilation(inputFilename, dirPath, key, options, filters, backendOptions, libraries, tools) {
+        const inputFilenameSafe = this.filename(inputFilename);
+        const sourceFile = path.basename(inputFilenameSafe);
+        await this.writeProjectfile(dirPath, filters.binary, sourceFile);
+
+        return super.doCompilation(inputFilename, dirPath, key, options, filters, backendOptions, libraries, tools);
+    }
+
     override async runCompiler(
         compiler: string,
         options: string[],
@@ -105,29 +142,15 @@ class DotNetCompiler extends BaseCompiler {
         }
 
         const programDir = path.dirname(inputFilename);
-        const sourceFile = path.basename(inputFilename);
 
-        const projectFilePath = path.join(programDir, `CompilerExplorer${this.lang.extensions[0]}proj`);
         const crossgen2Path = path.join(this.clrBuildDir, 'crossgen2', 'crossgen2.dll');
         const nugetConfigPath = path.join(programDir, 'nuget.config');
 
         const programOutputPath = path.join(programDir, 'bin', this.buildConfig, this.targetFramework);
         const programDllPath = path.join(programOutputPath, 'CompilerExplorer.dll');
-        const projectFileContent = `<Project Sdk="Microsoft.NET.Sdk">
-            <PropertyGroup>
-                <TargetFramework>${this.targetFramework}</TargetFramework>
-                <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-                <AssemblyName>CompilerExplorer</AssemblyName>
-                <LangVersion>${this.langVersion}</LangVersion>
-                <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
-                <Nullable>enable</Nullable>
-                <OutputType>${this.compileToBinary ? 'Exe' : 'Library'}</OutputType>
-            </PropertyGroup>
-            <ItemGroup>
-                <Compile Include="${sourceFile}" />
-            </ItemGroup>
-         </Project>
-        `;
+
+        const sdkBaseDir = path.join(path.dirname(compiler), 'sdk');
+        const sdkVersions = await fs.readdir(sdkBaseDir);
 
         const nugetConfigFileContent = `<?xml version="1.0" encoding="utf-8"?>
         <configuration>
@@ -158,7 +181,6 @@ class DotNetCompiler extends BaseCompiler {
         execOptions.env.DOTNET_NOLOGO = 'true';
 
         execOptions.customCwd = programDir;
-        await fs.writeFile(projectFilePath, projectFileContent);
         await fs.writeFile(nugetConfigPath, nugetConfigFileContent);
 
         const crossgen2Options: string[] = [];
@@ -211,10 +233,6 @@ class DotNetCompiler extends BaseCompiler {
     }
 
     override optionsForFilter(filters: ParseFiltersAndOutputOptions) {
-        if (filters.binary) {
-            this.compileToBinary = true;
-        }
-
         return this.compilerOptions;
     }