-
Notifications
You must be signed in to change notification settings - Fork 552
[Xamarin.Android.Build.Tasks] Rework how we resolve netstandard Nugets #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Commit f7c942d added support for replacing Reference assemblies with runtime assemblies. However a member of the Nuget team correctly pointed out that the Nuget does not akways have the same name as the package its in... So lets rework this code to do something else. We have the full path to the reference assembly. We also have the Nuget Project Model. This contains a list of the Paths for the cache's being used. So we use that information to attempt to figure out which package this reference came from. We can the use the Nuget ProjectModel to look up the replacement runtime assembly. Again this should just skip over things if we can't find what we want and issue the normal warning.
return resolver.Load (path, forceLoad: true); | ||
foreach (var folder in lockFile.PackageFolders) { | ||
var path = assemblyPath.Replace (folder.Path, string.Empty); | ||
var libraryPath = lockFile.Libraries.FirstOrDefault (x => path.StartsWith (x.Path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass StringComparison.OrdinalIgnoreCase
to StartsWith
var libraryPath = lockFile.Libraries.FirstOrDefault (x => path.StartsWith (x.Path)); | ||
if (libraryPath == null) | ||
continue; | ||
var library = target.Libraries.FirstOrDefault (x => x.Name == libraryPath.Name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using String.Compare (x.Name, libraryPath.Name, StringComparison.OrdinalIgnoreCase) == 0
instead of the ==
operator here
#1459) Commit f7c942d added support for replacing Reference assemblies with runtime assemblies. However a member of the Nuget team correctly pointed out that the Nuget does not akways have the same name as the package its in... So lets rework this code to do something else. We have the full path to the reference assembly. We also have the Nuget Project Model. This contains a list of the Paths for the cache's being used. So we use that information to attempt to figure out which package this reference came from. We can the use the Nuget ProjectModel to look up the replacement runtime assembly. Again this should just skip over things if we can't find what we want and issue the normal warning.
@dellis1972 the conversation in dotnet/macios#3791 is likely worth following if you haven't seen it yet. |
Commit f7c942d added support for replacing Reference
assemblies with runtime assemblies. However a member of
the Nuget team correctly pointed out that the Nuget does
not akways have the same name as the package its in...
So lets rework this code to do something else. We have the
full path to the reference assembly. We also have the Nuget
Project Model. This contains a list of the Paths for the
cache's being used. So we use that information to attempt to
figure out which package this reference came from. We can the
use the Nuget ProjectModel to look up the replacement runtime
assembly.
Again this should just skip over things if we can't find what
we want and issue the normal warning.