Skip to content

Commit

Permalink
[msbuild] Fix: Assembly.GetManifestResourceNames() may return an em…
Browse files Browse the repository at this point in the history
…pty string (#21280)

This avoids the `UnpackLibraryResources` to fail.

```
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_17.5/17.5.8020/tools/msbuild/iOS/Xamarin.Shared.targets(1985,3): error MSB4018: System.ArgumentException: Value does not fall within the expected range. (Parameter 'resourceName') 
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_17.5/17.5.8020/tools/msbuild/iOS/Xamarin.Shared.targets(1985,3): error MSB4018:    at System.Reflection.TypeLoading.Ecma.EcmaAssembly.GetManifestResourceInfo(String resourceName)
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_17.5/17.5.8020/tools/msbuild/iOS/Xamarin.Shared.targets(1985,3): error MSB4018:    at Xamarin.MacDev.Tasks.UnpackLibraryResources.GetAssemblyManifestResources(String fileName)+MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/UnpackLibraryResources.cs:line 254
```

This was initially submitted by @jeromelaban in #21277.

---------

Co-authored-by: Jérôme Laban <jerome@platform.uno>
  • Loading branch information
rolfbjarne and jeromelaban authored Sep 23, 2024
1 parent 16a6284 commit f57d915
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/UnpackLibraryResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ IEnumerable<ManifestResource> GetAssemblyManifestResources (string fileName)
}

foreach (var resourceName in assembly.GetManifestResourceNames ()) {
if (string.IsNullOrEmpty (resourceName))
continue;
var info = assembly.GetManifestResourceInfo (resourceName);
if (!info.ResourceLocation.HasFlag (ResourceLocation.Embedded))
continue;
Expand Down

8 comments on commit f57d915

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.