diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/ReadItemsFromFileBase.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/ReadItemsFromFileBase.cs index 595523eb74c1..4a93f54c5079 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/ReadItemsFromFileBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/ReadItemsFromFileBase.cs @@ -34,7 +34,10 @@ public override bool Execute () { var result = new List (); foreach (var file in File) { - var document = XDocument.Load (file.ItemSpec); + // XDocument.Load(string) takes a string to a URI, not a file path, so with certain characters that becomes a problem. + // Just File.OpenRead instead and use the XDocument.Load(Stream) overload instead. + using var stream = global::System.IO.File.OpenRead (file.ItemSpec); + var document = XDocument.Load (stream); var items = document.Root .Elements (ItemGroupElementName)