Skip to content

Commit ffb363f

Browse files
committed
cleaup
1 parent a979750 commit ffb363f

42 files changed

Lines changed: 224 additions & 176 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ private async Task<PackageSpec> GetPackageSpecAsync(ISettings settings)
479479
FrameworkName = targetFramework,
480480
Warn = warn,
481481
PackagesToPrune = packagesToPrune,
482+
TargetAlias = targetFramework.ToString(),
482483
};
483484

484485
// Build up runtime information.

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/PackageReferenceProject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ internal static Dictionary<string, TransitiveEntry> ComputeTransitivePackageOrig
383383
// For each target framework graph (Framework, RID)-pair:
384384
foreach (LockFileTarget targetFxGraph in targetsList)
385385
{
386-
var key = new FrameworkRuntimePair(targetFxGraph.TargetFramework, targetFxGraph.RuntimeIdentifier);
386+
var key = new FrameworkRuntimePair(targetFxGraph.TargetAlias, targetFxGraph.TargetFramework, targetFxGraph.RuntimeIdentifier);
387387

388388
foreach (var directPkg in installedPackages) // 3.1 For each direct dependency
389389
{

src/NuGet.Clients/NuGet.VisualStudio.Implementation/SolutionExplorer/Models/AssetsFileDependenciesSnapshot.cs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ private AssetsFileDependenciesSnapshot(LockFile? lockFile, AssetsFileDependencie
9696
continue;
9797
}
9898

99-
string targetAlias = GetTargetAlias(lockFileTarget.Name);
99+
string targetAlias = lockFileTarget.TargetAlias;
100100

101101
previous.DataByTarget.TryGetValue(targetAlias, out AssetsFileTarget? previousTarget);
102102

103-
ImmutableArray<AssetsFileLogMessage> logMessages = ParseLogMessages(lockFile, previousTarget, lockFileTarget.Name);
103+
ImmutableArray<AssetsFileLogMessage> logMessages = ParseLogMessages(lockFile, previousTarget, targetAlias);
104104

105105
dataByTarget.Add(
106106
targetAlias,
@@ -114,34 +114,6 @@ private AssetsFileDependenciesSnapshot(LockFile? lockFile, AssetsFileDependencie
114114
DataByTarget = dataByTarget.ToImmutable();
115115
return;
116116

117-
string GetTargetAlias(string lockFileTargetName)
118-
{
119-
// In some places, the target alias specified in the project file (e.g. "net472") will not
120-
// match the target name used throughout the lock file (e.g. ".NETFramework,Version=v4.7.2").
121-
// The dependencies tree only uses the target alias (what's in the project file) so we need
122-
// to map back to that. See https://github.com/dotnet/project-system/issues/6832.
123-
124-
if (lockFile.PackageSpec.TargetFrameworks.Any(t => t.TargetAlias == lockFileTargetName))
125-
{
126-
// The target name used in the assets file matches the target alias in the project file.
127-
return lockFileTargetName;
128-
}
129-
130-
// The target name used in the assets file does NOT match any target alias in the project.
131-
// Attempt to find the name used in the project.
132-
foreach (TargetFrameworkInformation targetInfo in lockFile.PackageSpec.TargetFrameworks)
133-
{
134-
if (targetInfo.FrameworkName.DotNetFrameworkName == lockFileTargetName)
135-
{
136-
// We found a match, so return the alias.
137-
return targetInfo.TargetAlias;
138-
}
139-
}
140-
141-
// No match was found. Not ideal. Nothing to do but return the original value.
142-
return lockFileTargetName;
143-
}
144-
145117
static ImmutableArray<AssetsFileLogMessage> ParseLogMessages(LockFile lockFile, AssetsFileTarget? previousTarget, string target)
146118
{
147119
if (lockFile.LogMessages.Count == 0)

src/NuGet.Core/NuGet.Build.Tasks.Console/MSBuildStaticGraphRestore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ internal static List<TargetFrameworkInformation> GetTargetFrameworkInfos(IReadOn
752752
FrameworkReferences = GetFrameworkReferences(msBuildProjectInstance),
753753
PackagesToPrune = prunedReferences,
754754
RuntimeIdentifierGraphPath = msBuildProjectInstance.GetProperty(nameof(TargetFrameworkInformation.RuntimeIdentifierGraphPath)),
755-
TargetAlias = targetAlias,
755+
TargetAlias = string.IsNullOrEmpty(targetAlias) ? targetFramework.ToString() : targetAlias,
756756
Warn = warn
757757
};
758758

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#nullable enable
22
~NuGet.Commands.IRestoreTargetGraph.TargetAlias.get -> string
33
~NuGet.Commands.RestoreTargetGraph.TargetAlias.get -> string
4+
~NuGet.Commands.RestoreTargetGraph.TargetGraphNameWithAlias.get -> string

src/NuGet.Core/NuGet.Commands/RestoreCommand/CompatibilityChecker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ internal async Task<CompatibilityCheckResult> CheckAsync(
230230
/// </summary>
231231
private static RestoreLogMessage GetErrorMessage(NuGetLogCode logCode, CompatibilityIssue issue, RestoreTargetGraph graph)
232232
{
233-
return RestoreLogMessage.CreateError(logCode, issue.Format(), issue.Package.Id, graph.TargetGraphName);
233+
return RestoreLogMessage.CreateError(logCode, issue.Format(), issue.Package.Id, graph.TargetGraphNameWithAlias);
234234
}
235235

236236
private static IEnumerable<NuGetFramework> GetPackageFrameworks(

src/NuGet.Core/NuGet.Commands/RestoreCommand/DependencyGraphResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public async Task<ValueTuple<bool, List<RestoreTargetGraph>, RuntimeGraph>> Reso
281281
foreach (FrameworkRuntimePair? frameworkRuntimePair in compatProfile.RestoreContexts)
282282
{
283283
_logger.LogDebug($" {profile.Value.Name} -> +{frameworkRuntimePair}");
284-
_request.CompatibilityProfiles.Add(frameworkRuntimePair);
284+
_request.CompatibilityProfiles.Add(frameworkRuntimePair); // TODO NK - double chekc.
285285
}
286286
}
287287

src/NuGet.Core/NuGet.Commands/RestoreCommand/Diagnostics/UnexpectedDependencyMessages.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static IEnumerable<RestoreLogMessage> GetMissingLowerBounds(IEnumerable<I
7878
.OrderBy(e => e.Child.Name, StringComparer.OrdinalIgnoreCase)
7979
.ThenBy(e => e.Child.Version)
8080
.ThenBy(e => e.Parent.Name, StringComparer.OrdinalIgnoreCase)
81-
.Select(e => GetMissingLowerBoundMessage(e, graph.TargetGraphName)));
81+
.Select(e => GetMissingLowerBoundMessage(e, graph.TargetGraphNameWithAlias)));
8282
}
8383

8484
return messages;
@@ -159,7 +159,7 @@ public static IEnumerable<RestoreLogMessage> GetBumpedUpDependencies(
159159
match.Key.Name,
160160
match.Key.Version);
161161

162-
var graphName = indexedGraph.Graph.TargetGraphName;
162+
var graphName = indexedGraph.Graph.TargetGraphNameWithAlias;
163163

164164
messages.Add(RestoreLogMessage.CreateWarning(NuGetLogCode.NU1601, message, match.Key.Name, graphName));
165165
}
@@ -290,7 +290,7 @@ public static IEnumerable<RestoreLogMessage> GetDependenciesAboveUpperBounds(Lis
290290
child,
291291
actual);
292292

293-
messages.Add(RestoreLogMessage.CreateWarning(NuGetLogCode.NU1608, message, dependencyId, graph.TargetGraphName));
293+
messages.Add(RestoreLogMessage.CreateWarning(NuGetLogCode.NU1608, message, dependencyId, graph.TargetGraphNameWithAlias));
294294
}
295295
}
296296
}

src/NuGet.Core/NuGet.Commands/RestoreCommand/Diagnostics/UnresolvedMessages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal static async Task LogAsync(IEnumerable<IRestoreTargetGraph> graphs, Rem
3333
{
3434
var tasks = graphs.SelectMany(graph => graph.Unresolved.Select(e =>
3535
GetMessageAsync(
36-
graph.TargetGraphName,
36+
graph.TargetGraphNameWithAlias,
3737
e,
3838
context.FilterDependencyProvidersForLibrary(e),
3939
context.PackageSourceMapping.IsEnabled,

src/NuGet.Core/NuGet.Commands/RestoreCommand/IRestoreTargetGraph.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace NuGet.Commands
1212
{
1313
public interface IRestoreTargetGraph
1414
{
15+
string TargetGraphNameWithAlias { get; }
16+
1517
string TargetGraphName { get; }
1618

1719
/// <summary>

0 commit comments

Comments
 (0)