Skip to content

[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

Merged
merged 3 commits into from
Mar 22, 2018

Conversation

dellis1972
Copy link
Contributor

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.

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 dellis1972 requested a review from jonpryor March 22, 2018 10:52
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));
Copy link
Contributor

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);
Copy link
Contributor

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

@jonpryor jonpryor merged commit 029a8b4 into dotnet:master 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.
@pjcollins
Copy link
Member

@dellis1972 the conversation in dotnet/macios#3791 is likely worth following if you haven't seen it yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants