[Xamarin.Android.Build.Tasks] Rework how we resolve netstandard Nugets#1459
Merged
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.
grendello
reviewed
Mar 22, 2018
| 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)); |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
I recommend using String.Compare (x.Name, libraryPath.Name, StringComparison.OrdinalIgnoreCase) == 0 instead of the == operator here
grendello
approved these changes
Mar 22, 2018
jonpryor
pushed a commit
that referenced
this pull request
Mar 23, 2018
#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.
Member
|
@dellis1972 the conversation in dotnet/macios#3791 is likely worth following if you haven't seen it yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.