uhsnx
uhsnx

Reputation: 21

how to execute binary file from the C# .NET MAUI project and get the output

Tried to execute libimobiledevice idevice_id binary file from the C# MAUI Project but everytime i get,

Error: Unable to retrieve device list!

            var command = $"{Path.Combine(Directory.GetCurrentDirectory(), "Contents/Resources/bin/idevice_id")}";

            Process process = new Process();
            ProcessStartInfo processStartInfo2 = process.StartInfo = new ProcessStartInfo
            {
                FileName = "bash",
                Arguments = $"-c \"{command}\"",
                UseShellExecute = false,
                RedirectStandardOutput = true,
                CreateNoWindow = true,
                WorkingDirectory = "/bin/"
            };
            Process process2 = process;
            process2.Start();
            while (!process2.StandardOutput.EndOfStream)
            {
                string text = ((TextReader)process2.StandardOutput).ReadToEnd();
                if (!text.Contains("Unable"))
                {
                    result = text;
                }
            }

            process2.WaitForExit();
            process.WaitForExit();

I tried to access the binary file from Console Application and it worked fine there.

What I want to achieve is to pack the binary file with the MAUI app and get the device UDID list.

I tried to access the binary file from Console Application and it worked fine there.

UPDATE: I have able to solve that problem. The issue was related to App Sandbox which was enabled in Entitlements.plist file. I had to remove that.

Upvotes: 1

Views: 142

Answers (0)

Related Questions