Skip to content

Commit

Permalink
[msbuild] Fix ILStripping of resource assemblies on Windows.
Browse files Browse the repository at this point in the history
Any assembly that's not already on the Mac must be copied there, so do that.
We detect if an assembly exist on the Mac by checking the file size of the
file on Windows: a 0-length file is an output file from an assembly that exist
on the Mac, otherwise it doesn't and must be copied.

Fixes #17009.
Fixes #14841.
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1817898.
  • Loading branch information
rolfbjarne committed Jun 28, 2023
1 parent 3f6d43c commit 5727bef
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion msbuild/Xamarin.iOS.Tasks/Tasks/ILStripBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ public override bool Execute ()
return result;
}

public bool ShouldCopyToBuildServer (ITaskItem item) => false;
public bool ShouldCopyToBuildServer (ITaskItem item)
{
// Some assemblies are already on the Mac, and we have a 0-length
// output file on Windows. We don't want to copy these files.
// However, some assemblies have to be copied, because they don't
// already exist on the Mac (typically resource assemblies). So
// filter to assemblies with a non-zero length.

var finfo = new FileInfo (item.ItemSpec);
if (!finfo.Exists || finfo.Length == 0)
return false;

return true;
}

public bool ShouldCreateOutputFile (ITaskItem item) => true;

Expand Down

0 comments on commit 5727bef

Please sign in to comment.