Skip to content

Instantly share code, notes, and snippets.

@jaredpar
Created January 20, 2022 17:21
Show Gist options
  • Save jaredpar/c07ab29a4f323aef9386a80559bf2d78 to your computer and use it in GitHub Desktop.
Save jaredpar/c07ab29a4f323aef9386a80559bf2d78 to your computer and use it in GitHub Desktop.
Example of using PathMap to get identical builds across paths
C:\Users\jaredpar\temp\example> dotnet new classlib
The template "Class Library" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on C:\Users\jaredpar\temp\example\example.csproj...
Determining projects to restore...
Restored C:\Users\jaredpar\temp\example\example.csproj (in 49 ms).
Restore succeeded.
C:\Users\jaredpar\temp\example> dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
example -> C:\Users\jaredpar\temp\example\bin\Debug\net6.0\example.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.70
C:\Users\jaredpar\temp\example> get-filehash .\bin\debug\net6.0\example.dll
Algorithm Hash Path
--------- ---- ----
SHA256 599A0A4585517809D0936A190A183E0442A4C0062A2CEFCA8389AF260441153A C:\Users\jaredpar\temp\example\bin\debug\net6.0\...
C:\Users\jaredpar\temp\example> subst q: C:\Users\jaredpar\temp\
C:\Users\jaredpar\temp\example> cd q:\example
q:\example> rm -re -fo bin,obj
q:\example> dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored q:\example\example.csproj (in 48 ms).
example -> q:\example\bin\Debug\net6.0\example.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.81
q:\example> get-filehash .\bin\debug\net6.0\example.dll
Algorithm Hash Path
--------- ---- ----
SHA256 B448399152379836D662250323773FB0BCFF0703C865E1F1D0ADCF6EE22E700D q:\example\bin\debug\net6.0\example.dll
q:\example> rm -re -fo bin,.\obj\
q:\example> dotnet build -p:PathMap="q:\=C:\Users\jaredpar\temp\" -t:build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored q:\example\example.csproj (in 52 ms).
example -> q:\example\bin\Debug\net6.0\example.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.83
q:\example> get-filehash .\bin\debug\net6.0\example.dll
Algorithm Hash Path
--------- ---- ----
SHA256 599A0A4585517809D0936A190A183E0442A4C0062A2CEFCA8389AF260441153A q:\example\bin\debug\net6.0\example.dll
q:\example>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment