Skip to content

Normalize the source paths in the embedded PDB on build servers - #3025

Merged
nohwnd merged 1 commit into
mainfrom
fix-3009-deterministic-source-paths
Sep 5, 2026
Merged

Normalize the source paths in the embedded PDB on build servers#3025
nohwnd merged 1 commit into
mainfrom
fix-3009-deterministic-source-paths

Conversation

@nohwnd

@nohwnd nohwnd commented Sep 5, 2026

Copy link
Copy Markdown
Member

Fix #3009

DebugType=embedded is worth keeping, it is what puts file and line numbers into stack traces from Pester's own C# code. But the paths in those traces are the build machine's absolute paths and they ship that way.

What 6.1.0 shipped to everyone:

D:\a\1\s\src\csharp\Pester\Block.cs
D:\a\1\s\src\csharp\Pester\BoolOption.cs

D:\a\1\s is the Azure agent's working directory.

ContinuousIntegrationBuild turns on DeterministicSourcePaths, and the .NET 8 SDK has SourceLink built in, so there is no package to add. One property.

Only on a build server

Locally the real path is what you want, so the trace points at a file the editor can open. Verified all three:

1. local dev build (no CI vars)
    /Users/nohwnd/p/pester-trees/fix-3009-deterministic-paths/src/csharp/Pester/Block.cs
2. GitHub Actions (GITHUB_ACTIONS=true)
    /_/src/csharp/Pester/Block.cs
3. Azure DevOps release (TF_BUILD=true)
    /_/src/csharp/Pester/Block.cs

The condition covers both TF_BUILD and GITHUB_ACTIONS on purpose. CI is GitHub Actions since #2905, but releasing still runs on Azure DevOps for the signing service connection, so gating on GITHUB_ACTIONS alone would normalize CI builds and leave the released binaries carrying the path, which is the case this issue is about.

It also makes the build reproducible

The same source in two folders produced two different Pester.dll files, the only difference being the embedded path. I hit this by accident while proving an unrelated change did not affect the artifact. With the property set, two directories produce the same bytes:

dir A: 0c4149fe5418a5f6ce42980a5d6476957046d158fcef4a690f72e3a85a8ee944
dir B: 0c4149fe5418a5f6ce42980a5d6476957046d158fcef4a690f72e3a85a8ee944

Verification

Builds clean on net8.0 and net462, 0 warnings, 0 errors. tst/Pester.Tests.ps1 green. Line numbers in traces are unchanged, only the path root moves.

No test for this one. Asserting on the PDB contents would only pass on a build server, and the property is inert locally, so the test would be skipped exactly where it could regress. LMK if you want it anyway, it would have to be a CI-only check.

🤖

DebugType=embedded is worth keeping, it is what puts file and line numbers into stack
traces from Pester's own C# code. But the paths in those traces are the build machine's
absolute paths and they ship that way. 6.1.0 carries D:\a\1\s\src\csharp\Pester\...,
which is the Azure agent's working directory.

ContinuousIntegrationBuild turns on DeterministicSourcePaths, and the .NET 8 SDK has
SourceLink built in, so no package is needed. Paths become /_/src/csharp/Pester/...
and the line numbers are unchanged.

Set only on a build server. A local build keeps the real path so the trace points at a
file the editor can open. The condition covers TF_BUILD and GITHUB_ACTIONS, because CI
is GitHub Actions but releasing still runs on Azure DevOps, and normalizing only CI
would leave the released binaries carrying the path, which is the case this is about.

It also makes the build reproducible. The same source in two folders produced two
different Pester.dll files before, the only difference being the embedded path.

Fix #3009

🤖
@nohwnd
nohwnd enabled auto-merge (squash) September 5, 2026 08:24
@nohwnd
nohwnd merged commit 9a5cefd into main Sep 5, 2026
15 checks passed
@nohwnd
nohwnd deleted the fix-3009-deterministic-source-paths branch September 5, 2026 08:33
nohwnd added a commit that referenced this pull request Sep 5, 2026
* Write the 6.2.0-alpha2 release notes pass

Covers the four user visible pull requests merged since alpha1. #3025 and #3021
were already in the file.

Should-BeFasterThan and Should-BeSlowerThan rejecting what they cannot measure is
a behavior change, not a fix. A test that passed on a string or an int was not
asserting anything and it fails now.

🤖

* Bump the manifest to alpha2

The notes heading moved to 6.2.0-alpha2 but src/Pester.psd1 still said alpha1, so
the built module would have published as 6.2.0-alpha1 again. Prerelease and the
ReleaseNotes link follow the heading. ModuleVersion and RequiredAssemblyVersion stay
at 6.2.0, only the prerelease label changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded PDBs ship the build machine's absolute source paths

1 participant