Deterministic Builds in C#
The C# compiler (Roslyn) supports deterministic builds since Visual Studio 2015. This means that compiling assemblies under the same conditions (permalink) would produce byte-for-byte equivalent binaries.
If you also intend on shipping non-portable (permalink)) PDBs, you must also make sure that paths in the PDBs are absolute using path mapping. The recommended way would be to map the enlistment (repo) root to a fixed path, such as
For more information, see this blog post.
Deterministicrequires Visual Studio 2015 (Roslyn version 1.0).
PathMaprequires Visual Studio 2015 Update 3 (Roslyn version 1.3).
In MSBuild (.csproj) - assuming you've defined the property
<Project> <PropertyGroup> <Deterministic>true</Deterministic> <PathMap>$(EnlistmentRoot)=C:\</Features> </PropertyGroup> </Project>
In the compiler command-line:
> csc /deterministic /pathmap:C:\Source\MyRepo=C:\