PlistBuddy on Windows

1.1k views Asked by At

I’m in the process of moving our Xamarin build infrastructure to be Windows based and I’ve hit a problem in that our build scripts currently use PlistBuddy to read from and write to the Info.plist file of an app.

Obviously PlistBuddy won’t run on Windows.

Has anyone seen any other solution for interacting with Plist files on Windows? I’ve seen a few that use a GUI but we would need this to have a CLI.

1

There are 1 answers

0
Jon Douglas On

You can force the Build Agent to run arbitrary commands on the Mac via tying into any generic Task/Target(You can look in the Xamarin.iOS .targets files for a better idea here) that runs across the SSH connection. This is currently available in another method by using the <Exec> Task with a SessionId of your $(BuildSessionId). Here's an example of how you might do this:

<Exec Command="..." SessionId="$(BuildSessionId)" />

If the SessionId is null/empty, then that means we are not connected to the Mac. If it's not null/empty, then we are connected to the Mac.

We can then force this condition to always run on the Mac via:

<Exec Command="..." SessionId="$(BuildSessionId)" Condition=" '$(BuildSessionId)' != '' " />

Please note that the following built-in tasks are exposed for remote execution:

  • Copy
  • Delete
  • Exec
  • MakeDir
  • Move
  • RemoveDir
  • Touch

Source: https://github.com/xamarin/xamarin-macios/blob/fc55e4306f79491fd269ca2495c6a859799cb1c6/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets#L74-L80

You can then invoke the PlistBuddy Command via this method.

EX:

  <Target Name="_SayGoodbye">
    <Exec Command="plistbuddy ..." SessionId="$(BuildSessionId)" Condition=" '$(BuildSessionId)' != '' "/>
  </Target>

If you wanted to go about a MSBuild custom Task way, You can see examples of previous built Tasks here:

https://github.com/xamarin/xamarin-macios/tree/fc55e4306f79491fd269ca2495c6a859799cb1c6/msbuild/Xamarin.iOS.Tasks.Core/Tasks

EX Plist in Use:

https://github.com/xamarin/xamarin-macios/blob/fc55e4306f79491fd269ca2495c6a859799cb1c6/msbuild/Xamarin.iOS.Tasks.Core/Tasks/MTouchTaskBase.cs#L608

EX Tests with Plist:

https://github.com/xamarin/xamarin-macios/tree/fc55e4306f79491fd269ca2495c6a859799cb1c6/msbuild/tests/Xamarin.iOS.Tasks.Tests/TaskTests/GeneratePlistTaskTests

This is more of a MSBuild customization at this point, but it's definitely possible to do what you're trying to do using these items.