-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Optionally output unresolved assembly conflicts #5990
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -86,6 +86,7 @@ public ResolveAssemblyReference() | |||||||||||||||
private ITaskItem[] _scatterFiles = Array.Empty<TaskItem>(); | ||||||||||||||||
private ITaskItem[] _copyLocalFiles = Array.Empty<TaskItem>(); | ||||||||||||||||
private ITaskItem[] _suggestedRedirects = Array.Empty<TaskItem>(); | ||||||||||||||||
private List<ITaskItem> _unresolvedConflicts = new List<ITaskItem>(); | ||||||||||||||||
private string[] _targetFrameworkSubsets = Array.Empty<string>(); | ||||||||||||||||
private string[] _fullTargetFrameworkSubsetNames = Array.Empty<string>(); | ||||||||||||||||
private string _targetedFrameworkMoniker = String.Empty; | ||||||||||||||||
|
@@ -214,6 +215,12 @@ public bool IgnoreTargetFrameworkAttributeVersionMismatch | |||||||||||||||
/// </remarks> | ||||||||||||||||
public bool FindDependenciesOfExternallyResolvedReferences { get; set; } | ||||||||||||||||
|
||||||||||||||||
/// <summary> | ||||||||||||||||
/// If true, outputs any unresolved assembly conflicts (MSB3277) in UnresolvedAssemblyConflicts | ||||||||||||||||
/// instead of logging them. | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
doesn't it do both? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep! Fixed. That was a holdover from how I'd originally designed it. |
||||||||||||||||
/// </summary> | ||||||||||||||||
public bool OutputUnresolvedAssemblyConflicts { get; set; } | ||||||||||||||||
|
||||||||||||||||
/// <summary> | ||||||||||||||||
/// List of target framework subset names which will be searched for in the target framework directories | ||||||||||||||||
/// </summary> | ||||||||||||||||
|
@@ -915,6 +922,18 @@ public String DependsOnNETStandard | |||||||||||||||
private set; | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
/// <summary> | ||||||||||||||||
/// If OutputUnresolvedAssemblyConflicts then a list of information about unresolved conflicts that normally would have | ||||||||||||||||
/// been outputted in MSB3277. Otherwise empty. | ||||||||||||||||
/// </summary> | ||||||||||||||||
[Output] | ||||||||||||||||
public ITaskItem[] UnresolvedAssemblyConflicts { | ||||||||||||||||
get | ||||||||||||||||
{ | ||||||||||||||||
return _unresolvedConflicts.ToArray(); | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||||||||||||
|
||||||||||||||||
#endregion | ||||||||||||||||
#region Logging | ||||||||||||||||
|
||||||||||||||||
|
@@ -990,16 +1009,36 @@ quiet at the engine level. | |||||||||||||||
// Log the reference which lost the conflict and the dependencies and source items which caused it. | ||||||||||||||||
LogReferenceDependenciesAndSourceItemsToStringBuilder(fusionName, conflictCandidate, logDependencies.AppendLine()); | ||||||||||||||||
|
||||||||||||||||
string toOutput; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Both |
||||||||||||||||
if (logWarning) | ||||||||||||||||
{ | ||||||||||||||||
// This warning is logged regardless of AutoUnify since it means a conflict existed where the reference | ||||||||||||||||
// chosen was not the conflict victor in a version comparison. In other words, the victor was older. | ||||||||||||||||
Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.FoundConflicts", assemblyName.Name, StringBuilderCache.GetStringAndRelease(logConflict)); | ||||||||||||||||
toOutput = StringBuilderCache.GetStringAndRelease(logConflict); | ||||||||||||||||
Log.LogWarningWithCodeFromResources("ResolveAssemblyReference.FoundConflicts", assemblyName.Name, toOutput); | ||||||||||||||||
} | ||||||||||||||||
else | ||||||||||||||||
{ | ||||||||||||||||
Log.LogMessage(ChooseReferenceLoggingImportance(conflictCandidate), StringBuilderCache.GetStringAndRelease(logConflict)); | ||||||||||||||||
Log.LogMessage(MessageImportance.Low, StringBuilderCache.GetStringAndRelease(logDependencies)); | ||||||||||||||||
toOutput = StringBuilderCache.GetStringAndRelease(logConflict); | ||||||||||||||||
string extra = StringBuilderCache.GetStringAndRelease(logDependencies); | ||||||||||||||||
Log.LogMessage(ChooseReferenceLoggingImportance(conflictCandidate), toOutput); | ||||||||||||||||
Log.LogMessage(MessageImportance.Low, extra); | ||||||||||||||||
|
||||||||||||||||
// This does an extra allocation, so only do it when necessary. | ||||||||||||||||
if (OutputUnresolvedAssemblyConflicts) | ||||||||||||||||
{ | ||||||||||||||||
toOutput += '\n' + extra; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not be more structured add { "logMessage", toOutput },
{ "logMessageDetails", extra } |
||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
if (OutputUnresolvedAssemblyConflicts) | ||||||||||||||||
{ | ||||||||||||||||
_unresolvedConflicts.Add(new TaskItem(assemblyName.Name, new Dictionary<string, string>() | ||||||||||||||||
{ | ||||||||||||||||
{ "logMessage", toOutput }, | ||||||||||||||||
{"victorVersionNumber", victor.ReferenceVersion.ToString() }, | ||||||||||||||||
{"victimVersionNumber", conflictCandidate.ReferenceVersion.ToString() } | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super-nit: Missing space after |
||||||||||||||||
})); | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
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.
Should we make this a theory and test what happens when the item has the
.dll
extension? @dsplaisted is there a concrete answer for including.dll
in the assembly name? Or did your comment, "possibly with .dll possibly not," refer to the fact thatassemblyName.Name
may not have the extension along with it?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 understood him to mean that the SDK can handle the output having the .dll extension or not having it—it's the same information, just presented slightly differently. Since I'm creating the item, and I went with no .dll extension, that shouldn't be an issue.
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 wasn't sure whether the assembly name processed by ResolveAssemblyReference would have the .dll extension on it. If it consistently does not have the extension, then I would leave it out. It's also theoretically possible to reference an .exe, I believe.
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.
The summary behind
assemblyName.Name
:Looks like the SDK will have to account for both scenarios, unless there's a preference on how we handle it here. I'm okay with either scenario.
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.
Sounds like MSBuild shouldn't do anything special here then (ie don't add the .dll extension).