Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/Tasks/Common/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,10 @@
<data name="UnsupportedSDKVersionForNetStandard20" xml:space="preserve">
<value>The version of Microsoft.NET.Sdk used by this project is insufficient to support references to libraries targeting .NET Standard 1.5 or higher. Please install version 2.0 or higher of the .NET Core SDK.</value>
</data>
<data name="ErrorParsingFrameworkListInvalidValue" xml:space="preserve">
<value>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</value>
</data>
<data name="FrameworkListPathNotRooted" xml:space="preserve">
<value>Framework list file path '{0}' is not rooted. Only full paths are supported.</value>
</data>
</root>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">Platforma RuntimeIdentifier a PlatformTarget se musí shodovat.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">Die RuntimeIdentifier-Plattform und PlatformTarget müssen übereinstimmen.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">Las plataformas RuntimeIdentifier y PlatformTarget deben coincidir.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">La plateforme RuntimeIdentifier et la PlatformTarget doivent correspondre.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">La piattaforma di RuntimeIdentifier e quella di PlatformTarget devono corrispondere.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">RuntimeIdentifier プラットフォームと PlatformTarget は一致している必要があります。</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">RuntimeIdentifier 플랫폼과 PlatformTarget은 일치해야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">Platforma RuntimeIdentifier i wartość PlatformTarget muszą być zgodne.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">A plataforma RuntimeIdentifier e a PlatformTarget devem corresponder.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">Платформа RuntimeIdentifier и PlatformTarget должны совпадать.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">RuntimeIdentifier platformu ile PlatformTarget eşleşmelidir.</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">RuntimeIdentifier 平台和 PlatformTarget 必须匹配。</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@
<target state="translated">RuntimeIdentifier 平台必須與 PlatformTarget 相符。</target>
<note />
</trans-unit>
<trans-unit id="ErrorParsingFrameworkListInvalidValue">
<source>Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</source>
<target state="new">Error parsing FrameworkList from '{0}'. {1} '{2}' was invalid.</target>
<note />
</trans-unit>
<trans-unit id="FrameworkListPathNotRooted">
<source>Framework list file path '{0}' is not rooted. Only full paths are supported.</source>
<target state="new">Framework list file path '{0}' is not rooted. Only full paths are supported.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private TConflictItem ResolveConflict(TConflictItem item1, TConflictItem item2)
return item2;
}

string message = conflictMessage + SENTENCE_SPACING + string.Format(CultureInfo.InvariantCulture, Strings.ConflictCouldNotDetermineWinner);
string message = conflictMessage + SENTENCE_SPACING + string.Format(CultureInfo.CurrentCulture, Strings.ConflictCouldNotDetermineWinner);

log.LogMessage(message);
return null;
Expand Down
103 changes: 103 additions & 0 deletions src/Tasks/Common/src/ConflictResolution/FrameworkListReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.NET.Build.Tasks;
using Microsoft.Build.Utilities;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Xml.Linq;
using System.Linq;
using Microsoft.Build.Framework;

namespace Microsoft.NET.Build.Tasks.ConflictResolution
{
class FrameworkListReader
{
private IBuildEngine4 _buildEngine;

public FrameworkListReader(IBuildEngine4 buildEngine)
{
_buildEngine = buildEngine;
}

public IEnumerable<ConflictItem> GetConflictItems(string frameworkListPath, ILog log)
{
if (frameworkListPath == null)
{
throw new ArgumentNullException(nameof(frameworkListPath));
}

if (!Path.IsPathRooted(frameworkListPath))
{
throw new BuildErrorException(Strings.FrameworkListPathNotRooted, frameworkListPath);
}

string objectKey = $"{nameof(FrameworkListReader)}:{frameworkListPath}";

IEnumerable<ConflictItem> result;

object existingConflictItems = _buildEngine.GetRegisteredTaskObject(objectKey, RegisteredTaskObjectLifetime.AppDomain);

if (existingConflictItems == null)
{
result = LoadConflictItems(frameworkListPath, log);

_buildEngine.RegisterTaskObject(objectKey, result, RegisteredTaskObjectLifetime.AppDomain, true);
}
else
{
result = (IEnumerable<ConflictItem>)existingConflictItems;
}

return result;
}

private static IEnumerable<ConflictItem> LoadConflictItems(string frameworkListPath, ILog log)
{
if (!File.Exists(frameworkListPath))
{
// 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
return Enumerable.Empty<ConflictItem>();
}

var frameworkList = XDocument.Load(frameworkListPath);
var ret = new List<ConflictItem>();
foreach (var file in frameworkList.Root.Elements("File"))
{
var assemblyName = file.Attribute("AssemblyName")?.Value;
var assemblyVersionString = file.Attribute("Version")?.Value;

if (string.IsNullOrEmpty(assemblyName))
{
string errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingFrameworkListInvalidValue,
frameworkListPath,
"AssemblyName",
assemblyName);
log.LogError(errorMessage);
return Enumerable.Empty<ConflictItem>();
}

Version assemblyVersion;
if (string.IsNullOrEmpty(assemblyVersionString) || !Version.TryParse(assemblyVersionString, out assemblyVersion))
{
string errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingFrameworkListInvalidValue,
frameworkListPath,
"Version",
assemblyVersionString);
log.LogError(errorMessage);
return Enumerable.Empty<ConflictItem>();
}

ret.Add(new ConflictItem(assemblyName + ".dll",
packageId: null,
assemblyVersion: assemblyVersion,
fileVersion: null));
}

return ret;
}
}
}
Loading