diff --git a/src/Compilers/Core/Portable/Compilation/Compilation.cs b/src/Compilers/Core/Portable/Compilation/Compilation.cs index 9fdbdef715c6ee9ef4d542fd3c15f575eeef816d..3473ec5e42959b520a7b7ebb403d49581f86bd68 100644 --- a/src/Compilers/Core/Portable/Compilation/Compilation.cs +++ b/src/Compilers/Core/Portable/Compilation/Compilation.cs @@ -1776,6 +1776,18 @@ private static EmitResult ToEmitResultAndFree(DiagnosticBag diagnostics, bool su bool emitPortablePdb = moduleBeingBuilt.EmitOptions.DebugInformationFormat == DebugInformationFormat.PortablePdb; string pdbPath = (pdbStreamProvider != null) ? (moduleBeingBuilt.EmitOptions.PdbFilePath ?? FileNameUtilities.ChangeExtension(SourceModule.Name, "pdb")) : null; + // The PDB path is emitted in it's entirety into the PE. This makes it impossible to have deterministic + // builds that occur in different source directories. To enable this we shave all path information from + // the PDB when specified by the user. + // + // This is a temporary work around to allow us to make progress with determinism. The following issue + // tracks getting an official solution here. + // + // https://github.com/dotnet/roslyn/issues/9813 + string pePdbPath = Feature("pdb-path-determinism") != null && !string.IsNullOrEmpty(pdbPath) + ? Path.GetFileName(pdbPath) + : pdbPath; + try { metadataDiagnostics = DiagnosticBag.GetInstance(); @@ -1872,7 +1884,7 @@ private static EmitResult ToEmitResultAndFree(DiagnosticBag diagnostics, bool su getPeStream, getPortablePdbStream, nativePdbWriter, - pdbPath, + pePdbPath, metadataOnly, deterministic, cancellationToken))