Skip to content

Commit

Permalink
Run lsregister -f after I/O before running a MacCatalyst app
Browse files Browse the repository at this point in the history
Without this, launching the app fails (observed on arm64 locally, but
also on x64 on dotnet/runtime CI) with

```
The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10827 "kLSNoExecutableErr: The executable is missing" UserInfo={_LSLine=3691, _LSFunction=_LSOpenStuffCallLocal}
```

Fixes dotnet#611
  • Loading branch information
lambdageek committed May 28, 2021
1 parent fd2a4a5 commit 2732acd
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ protected async Task<ProcessExecutionResult> RunMacCatalystApp(
await _processManager.ExecuteCommandAsync("chmod", new[] { "+x", binaryPath }, _mainLog, TimeSpan.FromSeconds(10), cancellationToken: cancellationToken);
}

// On Big Sur it seems like the launch services database is not updated fast enough after we do some I/O with the app bundle.
// Force registration for the app by running
// /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /path/to/app.app
var lsRegisterPath = @"/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";
await _processManager.ExecuteCommandAsync(lsRegisterPath, new[] {"-f", appInfo.LaunchAppPath }, _mainLog, TimeSpan.FromSeconds(10), cancellationToken: cancellationToken);

var arguments = new List<string>
{
"-W",
Expand Down

0 comments on commit 2732acd

Please sign in to comment.