Skip to content

PropertyListEditor.Entry defaulted to string.Empty #24091

Description

@yaliashkevich

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

net9.0-ios18.5

Description

I used to use PropertyListEditor task to merge Entitlements.plist with keys specific to environment (i.e. dev, stage, etc). For instance I do add environment specific com.apple.developer.associated-domains

    <Target Name="_UpdateCodesignEntitlements" AfterTargets="_DetectAppManifest">
        <!-- Copy original entitlemnts for further modifications -->
        <ItemGroup>
            <_UpdatedCodesignEntitlements Include="$(IntermediateOutputPath)Entitlements.Build.plist" />
        </ItemGroup>
        <Copy SourceFiles="$(CodesignEntitlements)" DestinationFiles="@(_UpdatedCodesignEntitlements)" />

        <!-- ensure to remove Entitlements.Build.plist when cleanup is executed -->
        <ItemGroup>
            <FileWrites Include="@(_UpdatedCodesignEntitlements)"/>
        </ItemGroup>

        <!-- overwrite CodesignEntitlements file path -->
        <PropertyGroup>
            <CodesignEntitlements>@(_UpdatedCodesignEntitlements)</CodesignEntitlements>
        </PropertyGroup>

        <!-- Merge entitlements defined by <Entitlements> items -->
        <PropertyListEditor
            PropertyList="$(CodesignEntitlements)"
            Action="Merge"
            Value="%(Entitlements.FullPath)" />
    </Target>

where <Entitlements> is my custom item that depends on build configuration. Similar to <PartialAppManifest>.

That is not working anymore. The behaviour has been changed by this commit 0a62c2b

Now Entry is defaulted to string.Empty and merging of two plist files failing:

public string Entry { get; set; } = string.Empty;

so this branch is always executed:

that way I can not use PropertyListEditor to merge two plist files now.

The "PropertyListEditor" task failed unexpectedly.
      System.IndexOutOfRangeException: Index was outside the bounds of the array.
         at Xamarin.MacDev.Tasks.PropertyListEditor.Merge(PObject plist) in /Users/builder/azdo/_work/1/s/macios/msbuild/Xamarin.MacDev.Tasks/Tasks/Pr
      opertyListEditor.cs:line 464
         at Xamarin.MacDev.Tasks.PropertyListEditor.Execute() in /Users/builder/azdo/_work/1/s/macios/msbuild/Xamarin.MacDev.Tasks/Tasks/PropertyListE
      ditor.cs:line 620
         at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
         at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, Ta
      skHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

Can PropertyListEditor have Entry as nullable (as it was previously) or use null or empty check?

Also it will be nice to have <PartialEntitlements> out of the box.

Steps to Reproduce

check description

Did you find any workaround?

No response

Build logs

No response

Metadata

Metadata

Assignees

Labels

bugIf an issue is a bug or a pull request a bug fixmsbuildIssues affecting our msbuild tasks/targetsregressionThe issue or pull request is a regression

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions