Skip to content

Conversation

@guimafelipe
Copy link
Member

@guimafelipe guimafelipe commented Jul 30, 2021

Fixes Issue #3876

Main PR

Description

Building a WPF .NET Core project with dotnet.exe is not deterministic, but building it with msbuild.exe is deterministic as expected: .NET Core does not create identical .BAML files.

During compilation, WPF creates an optimized binary version of .XAML files, called .BAML. The .BAML files between two different builds sometimes have references in the references section written in a different order. .BAML created from the same .XAML file should always be the same.

This PR is based on this fix from @MichaeIDietrich.

Customer Impact

Builds may not be deterministic.

Regression

No regression.

Testing

The fix was testing building some projects using the dotnet build command, and comparing the generated files using a diff program. Without the fix, the files are almost always different.

Risk

Low. This change only makes the order of references written to BAML consistent.

guimafelipe and others added 2 commits July 29, 2021 15:26
* adding orderby in foreach loop

* Order references to make BAML deterministic

Co-authored-by: Felipe da Conceicao Guimaraes <felipeda@microsoft.com>
Co-authored-by: Michael Dietrich <dev.michaeldietrich@outlook.de>
@guimafelipe guimafelipe requested a review from a team as a code owner July 30, 2021 12:50
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jul 30, 2021
@ghost ghost requested review from SamBent, fabiant3 and ryalanms July 30, 2021 12:50
@ryalanms ryalanms changed the title Fixing deterministic build bug with dotnet.exe 5.0 [release/5.0] Fixing deterministic build bug in WPF's BAML files Aug 3, 2021
@leecow leecow added this to the 5.0.10 milestone Aug 3, 2021
@leecow leecow modified the milestones: 5.0.10, 5.0.11 Aug 3, 2021
@ryalanms ryalanms merged commit 2ac9944 into release/5.0 Aug 9, 2021
@vishalmsft vishalmsft deleted the deterministic.build.fix.5.0 branch February 10, 2022 06:04
@ghost ghost locked as resolved and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage Servicing-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants