-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
In conflict resolution, treat items from FrameworkList.xml as platform assemblies #1618
In conflict resolution, treat items from FrameworkList.xml as platform assemblies #1618
Conversation
Version assemblyVersion; | ||
if (string.IsNullOrEmpty(assemblyVersionString) || !Version.TryParse(assemblyVersionString, out assemblyVersion)) | ||
{ | ||
string errorMessage = string.Format(CultureInfo.InvariantCulture, Strings.ErrorParsingFrameworkListInvalidValue, |
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.
Messages shown to the user should be formatted with current culture
} | ||
|
||
var frameworkList = XDocument.Load(frameworkListPath); | ||
foreach (var file in frameworkList.Elements("File")) |
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.
Some framework lists chain to others. Critically, I believe Mono's are that way and this will need to work when targeting net471 with Mono msbuild.
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 took a look at this and it turns out that the GetReferenceAssemblyPaths
target takes care of this. If there are chained framework lists, it will set TargetFrameworkDirectory
to a semicolon-separated list of the chained folders. For example:
C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v6.0;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v5.1;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v5.0;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.4.87;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.4;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.3;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.2;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.1;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.0.3;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v2.3;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0;;;C:\Program Files %28x86%29\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\
However, the FrameworkList.xml
files for Mono don't list any File
entries. So I think we will need to scan the directory for assemblies to treat as platform assemblies if we don't find any File
items listed in the FrameworkList.xml
.
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.
That could get expensive, if you do need to do that make sure you don't crack the assemblies at that point but instead create lazy items that point to the TargetFrameworkDirectory location.
I don't suppose MSBuild has an API built on top of their framework list / metadata cache?
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.
@ericstj Yes, that's the way I would do it. I'm not sure at this point whether we need this to apply to Xamarin/Mono.
The MSBuild API (the RedistList
class) isn't public and doesn't have any way to get a list of the framework assemblies, only to check if a given assembly name is part of the framework. We could make an API for this public if we have to, but so far it doesn't look like we do.
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.
yield return new ConflictItem(assemblyName + ".dll", | ||
packageId: null, | ||
assemblyVersion: assemblyVersion, | ||
fileVersion: null); |
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.
Extra whitespace
@Pilchie for approval Customer scenario .NET Framework 4.7.1 projects which reference libraries targeting .NET Standard 1.x Bugs this fixes Workarounds, if any n/a Risk Medium Performance impact TBD Root cause analysis .NET 4.7.1 ships with .NET Standard Facades in box, and as part of the reference assemblies. This requires some additional logic in order for the in-box versions to override the ones coming from NuGet. How was the bug found? Internal design |
What is the state of the testing mentioned above? Additionally, what can be done to mitigate performance concerns? |
@Pilchie The PR includes tests, which are disabled for now because we don't have the .NET 4.7.1 targeting pack on the CI machines. I've run the tests locally and filed #1625 to enable them later. As for perf, we could make a process-wide cache of the data we are reading, which is what MSBuild does. We could also update MSBuild to provide an API to get the list of assemblies in the framework along with the versions. MSBuild already reads and caches this file so that solution would have very little overhead. |
I'm going to need some code reviewers to sign off on this before I can approve an escalate. |
{ | ||
// This is not an error, as we get both the root target framework directory as well as the Facades folder passed in as TargetFrameworkDirectories. | ||
// Only the root will have a RedistList\FrameworkList.xml in it | ||
yield break; |
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.
Consider not using a yield enumerator if this is a hot path where allocations matter.
// Also treat assemblies from FrameworkList.xml as platform assemblies | ||
if (TargetFrameworkDirectories != null && TargetFrameworkDirectories.Any()) | ||
{ | ||
platformItems = platformItems.Concat(TargetFrameworkDirectories.SelectMany(tfd => |
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.
Consider not using SelectMany
+ Concat
if this is a hot path where allocations matter.
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.
Please file a bug to handle the Mono case. (I know you have offline discussions going on that, but it would be good to have a bug tracking what isn't handled in initial commit.)
@nguerrera I've filed #1627 |
Why did this get closed? |
Good question... I guess I misclicked (or maybe my daughter did :-) ) |
@MattGertz for approval. Ask mode template is here: #1618 (comment) |
…K project references SDK project
We are in Escrow. Please migrate to VSO bug -- thanks! |
Approved from my side. Escrow technically starts at 5PM tonight, but we likely can't get it in before then due to turnaround on signing, so I've submitted for Escrow in VSO. |
@dotnet-bot test OSX10.12 Debug |
@dotnet-bot test OSX10.12 Release |
@@ -0,0 +1,124 @@ | |||
using FluentAssertions; |
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.
missing copyright header
|
||
compilePlatformItems = TargetFrameworkDirectories.SelectMany(tfd => | ||
{ | ||
return frameworkListReader.GetConflictItems(Path.Combine(tfd.ItemSpec, "RedistList", "FrameworkList.xml"), log); |
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.
Return here is confusing, can you eliminate the curly braces?
With dotnet#1618, conflict resolution now depends on TargetFrameworkDirectory property, and the GetReferenceAssemblyPaths target to set it. However, the custom FilterCopyLocal target in our projects was causing GetReferenceAssemblyPaths to run before GetFrameworkPaths, and when GetFrameworkPaths was subsequently run, it reset the TargetFrameworkDirectory property to v4.0.30319. This change adds a dependency to PrepareForBuild so that both targets run in the right order.
…df6-aca1-e570af2cc4d4 [release/6.x] Update dependencies from dotnet/roslyn
Fixes #1336
Tests still to come (though they will probably depend on the .NET 4.7.1 targeting pack, so they'll have to be disabled until it is released).
@ericstj @AlexGhiondea @nguerrera @AndyGerlicher @cdmihai for review