             let diagnosticFile = diaDir.appending(component: "\(packageIdentity).dia")
             try localFileSystem.createDirectory(diaDir, recursive: true)
             cmd += ["-Xfrontend", "-serialize-diagnostics-path", "-Xfrontend", diagnosticFile.pathString]
-            result.diagnosticFile = diagnosticFile
+            evaluationResult.diagnosticFile = diagnosticFile
         }
 
         cmd += [manifestPath.pathString]
 
         cmd += self.extraManifestFlags
 
-        try withTemporaryDirectory(removeTreeOnDeinit: true) { tmpDir in
+        try withTemporaryDirectory { tmpDir, cleanupTmpDir in
             // Set path to compiled manifest executable.
 #if os(Windows)
             let executableSuffix = ".exe"

            cmd += ["-o", compiledManifestFile.pathString]

            // Compile the manifest.
            let compilerResult = try Process.popen(arguments: cmd, environment: toolchain.swiftCompilerEnvironment)
            let compilerOutput = try (compilerResult.utf8Output() + compilerResult.utf8stderrOutput()).spm_chuzzle()
            result.compilerOutput = compilerOutput

            // Return now if there was an error.
            if compilerResult.exitStatus != .terminated(code: 0) {
                return
            }

            // Pass an open file descriptor of a file to which the JSON representation of the manifest will be written.
            let jsonOutputFile = tmpDir.appending(component: "\(packageIdentity)-output.json")
            guard let jsonOutputFileDesc = fopen(jsonOutputFile.pathString, "w") else {
                throw StringError("couldn't create the manifest's JSON output file")
            }

            cmd = [compiledManifestFile.pathString]
#if os(Windows)
            // NOTE: `_get_osfhandle` returns a non-owning, unsafe,
            // unretained HANDLE.  DO NOT invoke `CloseHandle` on `hFile`.
            let hFile: Int = _get_osfhandle(_fileno(jsonOutputFileDesc))
            cmd += ["-handle", "\(String(hFile, radix: 16))"]
#else
            cmd += ["-fileno", "\(fileno(jsonOutputFileDesc))"]
#endif

            let packageDirectory = manifestPath.parentDirectory.pathString
            let contextModel = ContextModel(packageDirectory: packageDirectory)
            cmd += ["-context", try contextModel.encode()]

            // If enabled, run command in a sandbox.
            // This provides some safety against arbitrary code execution when parsing manifest files.
            // We only allow the permissions which are absolutely necessary.
            if isManifestSandboxEnabled {
                let cacheDirectories = [self.databaseCacheDir, moduleCachePath].compactMap{ $0 }
                let strictness: Sandbox.Strictness = toolsVersion < .v5_3 ? .manifest_pre_53 : .default
                cmd = Sandbox.apply(command: cmd, writableDirectories: cacheDirectories, strictness: strictness)
            }

            // Run the compiled manifest.
            var environment = ProcessEnv.vars
#if os(Windows)
            let windowsPathComponent = runtimePath.pathString.replacingOccurrences(of: "/", with: "\\")
            environment["Path"] = "\(windowsPathComponent);\(environment["Path"] ?? "")"
#endif
            let runResult = try Process.popen(arguments: cmd, environment: environment)
            fclose(jsonOutputFileDesc)
            let runOutput = try (runResult.utf8Output() + runResult.utf8stderrOutput()).spm_chuzzle()
            if let runOutput = runOutput {
                // Append the runtime output to any compiler output we've received.
                result.compilerOutput = (result.compilerOutput ?? "") + runOutput
            }

            // Return now if there was an error.
            if runResult.exitStatus != .terminated(code: 0) {
                result.errorOutput = runOutput
                return
            }

            // Read the JSON output that was emitted by libPackageDescription.
            guard let jsonOutput = try localFileSystem.readFileContents(jsonOutputFile).validDescription else {
                throw StringError("the manifest's JSON output has invalid encoding")
            }
            result.manifestJSON = jsonOutput
        }
    }


        manifestPath: AbsolutePath,
        manifestContents: [UInt8],
        toolsVersion: ToolsVersion,
        delegateQueue: DispatchQueue,
        completion: @escaping (Result<EvaluationResult, Error>) -> Void
    ) {
        do {
            if localFileSystem.isFile(manifestPath) {
                try self.evaluateManifest(
