Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project build is not 'deterministic' #308

Closed
clcdrn opened this issue Jan 8, 2018 · 7 comments
Closed

Project build is not 'deterministic' #308

clcdrn opened this issue Jan 8, 2018 · 7 comments

Comments

@clcdrn
Copy link

clcdrn commented Jan 8, 2018

I'm using <Deterministic>True</Deterministic> in the .csproj file (targeting .NET 4.6.2 using the latest VS2017 build with .NET 4.7.1 under Windows 10) and it seems there is s small difference near the end of the binary file produced by the PropertyChanged task. I have not investigated it further because it's a little outside of my skill set. I'm also not clear if this is related to 'PropertyChanged' or the parent 'Fody' project. I remember reading somewhere recently that 'Fody' should be now deterministic but I can't seem to find that particular issue anymore to link it here. Is this a known issue? Should the build be 'deterministic' in the first place? Do you also need a sample project to verify this? (If yes, I'll try creating a small schema and a console project).

@BrunoJuchli
Copy link
Contributor

I can't speak for Simon, he might very well know more about this. But I'd be willing to look at this in case you can provide a repro.

For my personal notes:
Documentation on Deterministic flag:

@clcdrn
Copy link
Author

clcdrn commented Jan 8, 2018

I uploaded a test solution under my account: https://github.com/clcdrn/TestRepo/tree/master/Fody.PropertyChanged.Deterministic
Alternatively, below are the steps I used to create it.

  1. New Project -> Console App (.NET Framework) -> "Fody.PropertyChanged.Deterministic" (.NET 4.6.2)
  2. Add two new Class Libraries, each with the same 'TestClass' containing one 'TestProperty'
  3. In the Console project add references to these two class libraries
  4. Install PropertyChanged.Fody only in the first class library:
    • Install 'PropertyChanged.Fody' using NuGet (v2.2.4)
    • Update 'Fody' package dependency to the latest version (v2.3.17)
    • Apply the [AddINotifyPropertyChangedInterface] attribute
    • Configure FodyWeavers.xml
    • Build to check if it works
    • Open the dll in ILSpy to confirm it was changed by 'PropertyChanged.Fody'
  5. Edit all three .csproj files manually to add the <Deterministic>True</Deterministic>
  6. Switch build to Release (doesn't seem to matter though)
  7. Build once, retain the binaries (copy in a sub-folder)
  8. Clean solution, build again, compare the new binaries with the ones before the clean

Expected result: All binaries are the same in the two builds
Actual result: ClassLibrary1.dll and the associated .pdb differ from the original

Note: I've noticed the .pdb are also deterministic since only recently (one of the latest VS2017 updates must have included this).
I've been using the 'reproducible build' for about half a year now, since I've found it useful in my scenario even though the .pdb used to differ each time.
Now, out of 100+ projects in my solution, only those which use 'Fody.PropertyChanged' don't build deterministically yet, hence this issue here.

Aside from yours, I had been following some links myself for this new 'deterministic' flag (the last one may be relevant to this case in particular)

dotnet/roslyn#372
dotnet/roslyn#949
dotnet/roslyn#9813
https://github.com/dotnet/roslyn/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+label%3AConcept-Determinism+
https://github.com/dotnet/core/blob/master/Documentation/diagnostics/portable_pdb.md
https://ericlippert.com/2012/05/31/past-performance-is-no-guarantee-of-future-results/
http://blog.paranoidcoding.com/2016/04/05/deterministic-builds-in-roslyn.html
jbevain/cecil#76

@onyxmaster
Copy link

onyxmaster commented Jan 9, 2018

Same issue here, but with ModuleInit. Maybe this should be moved to the parent project?
We use Fody on 2 projects out of 181 in our solution, and the deterministic build is broken only for these two projects.

@SimonCropp
Copy link
Member

TBH i had not heard of Deterministic builds. AFAIK Fody does nothing explicit that would cause Deterministic builds to stop working. but i could be missing something in my ignorance.

But i guess the underlying question is "does Cecil support Deterministic builds"? perhaps @jbevain knows or can give us some pointers

@clcdrn
Copy link
Author

clcdrn commented Jan 10, 2018

I'm sorry but I'm new to GitHub and I'm not clear on how to correctly link this issue from here to the Cecil repository. Or should I create a separate issue there?

@clcdrn
Copy link
Author

clcdrn commented Jan 10, 2018

Doing a search for 'Deterministic' under the Cecil repository (https://github.com/jbevain/cecil/search?q=deterministic&type=Issues&utf8=%E2%9C%93) shows that they discussed this previously and jbevain/cecil#76 is indeed relevant to follow. I see that just by linking it here, there is a mention in that thread about this issue here. Hopefully that is enough.

@SimonCropp
Copy link
Member

seeing as this seems to be an underlying cecil issue i will close this. happy to re-open if more info becomes avaliable

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

No branches or pull requests

4 participants