-
Notifications
You must be signed in to change notification settings - Fork 515
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
[msbuild] Fix detecting already signed executables. #3743
Conversation
The MSBuild tasks will codesign an executable if the executable's timestamp is later than `_CodeSignature/CodeResources`'s timestamp (or if `_CodeSignature/CodeResources` doesn't exist). Unfortunately, the codesign executable modifies both of those files, and the executable last. This means that even just after running codesign, the executable's timestamp might be later than `_CodeSignature/CodeResources`'s timestamp (due to HFS+'s one-second timestamp resolution, this might happen all within the same second, which means that this is a random issue: the problem only occurs if the executable was modified at least a second later than `_CodeSignature/CodeResources`.) So make sure to touch `_CodeSignature/CodeResources` after running codesign, so that the next time a build occurs (with no modifications), we don't resign needlessly. Fixes this (random) test failure when running the MSBuild tests: 1) Test Failure : Xamarin.iOS.Tasks.TargetTests.RebuildExecutable_NoModifications #1: ../MySingleView/bin/iPhoneSimulator/Debug/MySingleView.app/MySingleView Expected: 2017-11-30 10:04:20.000 But was: 2017-11-30 10:04:22.000 Fixes xamarin/maccore#592.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense but are not all our bots using APFS ?
Build success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woow, what a subtle bug...
@spouliot not all our bots, but the High Sierra bots should. This is a good question, because this should be 100% reproducible on APFS... yet it isn't. Test failure from a High Sierra bot (log, wrench revision) :
the timestamps clearly have a one-second resolution. I logged onto the bot, to confirm its file system: $ diskutil info /
[...]
File System Personality: APFS
Type (Bundle): apfs
Name (User Visible): APFS I tested that mono returns sub-second times: $ csharp -e 'System.IO.File.GetLastWriteTimeUtc ("/Users/builder/MonkeyWrench.log").ToString ("HH:mm:ss.fffffff")'
"11:22:45.2788357" so I have no idea why this is random on High Sierra as well. |
So I figured out why our High Sierra bots don't fail: mono didn't support sub-second timestamp resolution on non-Windows platforms until mono 5.12 (mono/mono@e0e185d). I tested for exactly this on the bot, but it turns out that the bot had mono 5.12 installed from another test run when I tested it 😠 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are Codesign invocations in Xamarin.Mac.Common.targets, does it need a fix as well for this issue?
The MSBuild tasks will codesign an executable if the executable's timestamp is later than `_CodeSignature/CodeResources`'s timestamp (or if `_CodeSignature/CodeResources` doesn't exist). Unfortunately, the codesign executable modifies both of those files, and the executable last. This means that even just after running codesign, the executable's timestamp might be later than `_CodeSignature/CodeResources`'s timestamp (due to HFS+'s one-second timestamp resolution, this might happen all within the same second, which means that this is a random issue: the problem only occurs if the executable was modified at least a second later than `_CodeSignature/CodeResources`.) So make sure to touch `_CodeSignature/CodeResources` after running codesign, so that the next time a build occurs (with no modifications), we don't resign needlessly. Fixes this (random) test failure when running the MSBuild tests: 1) Test Failure : Xamarin.iOS.Tasks.TargetTests.RebuildExecutable_NoModifications #1: ../MySingleView/bin/iPhoneSimulator/Debug/MySingleView.app/MySingleView Expected: 2017-11-30 10:04:20.000 But was: 2017-11-30 10:04:22.000 Fixes https://github.com/xamarin/maccore/issues/592.
The MSBuild tasks will codesign an executable if the executable's timestamp is later than `_CodeSignature/CodeResources`'s timestamp (or if `_CodeSignature/CodeResources` doesn't exist). Unfortunately, the codesign executable modifies both of those files, and the executable last. This means that even just after running codesign, the executable's timestamp might be later than `_CodeSignature/CodeResources`'s timestamp (due to HFS+'s one-second timestamp resolution, this might happen all within the same second, which means that this is a random issue: the problem only occurs if the executable was modified at least a second later than `_CodeSignature/CodeResources`.) So make sure to touch `_CodeSignature/CodeResources` after running codesign, so that the next time a build occurs (with no modifications), we don't resign needlessly. Fixes this (random) test failure when running the MSBuild tests: 1) Test Failure : Xamarin.iOS.Tasks.TargetTests.RebuildExecutable_NoModifications #1: ../MySingleView/bin/iPhoneSimulator/Debug/MySingleView.app/MySingleView Expected: 2017-11-30 10:04:20.000 But was: 2017-11-30 10:04:22.000 Fixes https://github.com/xamarin/maccore/issues/592.
The MSBuild tasks will codesign an executable if the executable's timestamp is
later than
_CodeSignature/CodeResources
's timestamp (or if_CodeSignature/CodeResources
doesn't exist).Unfortunately, the codesign executable modifies both of those files, and the
executable last. This means that even just after running codesign, the
executable's timestamp might be later than
_CodeSignature/CodeResources
'stimestamp (due to HFS+'s one-second timestamp resolution, this might happen
all within the same second, which means that this is a random issue: the
problem only occurs if the executable was modified at least a second later
than
_CodeSignature/CodeResources
.)So make sure to touch
_CodeSignature/CodeResources
after running codesign,so that the next time a build occurs (with no modifications), we don't resign
needlessly.
Fixes this (random) test failure when running the MSBuild tests:
Fixes https://github.com/xamarin/maccore/issues/592.