forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResolveTargetingPackAssets.cs
666 lines (556 loc) · 28.7 KB
/
ResolveTargetingPackAssets.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Xml.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using static Microsoft.DotNet.Cli.EnvironmentVariableNames;
namespace Microsoft.NET.Build.Tasks
{
public class ResolveTargetingPackAssets : TaskBase
{
public ITaskItem[] FrameworkReferences { get; set; } = Array.Empty<ITaskItem>();
public ITaskItem[] ResolvedTargetingPacks { get; set; } = Array.Empty<ITaskItem>();
public ITaskItem[] RuntimeFrameworks { get; set; } = Array.Empty<ITaskItem>();
public bool GenerateErrorForMissingTargetingPacks { get; set; }
public bool NuGetRestoreSupported { get; set; } = true;
public string NetCoreTargetingPackRoot { get; set; }
public string ProjectLanguage { get; set; }
[Output]
public ITaskItem[] ReferencesToAdd { get; set; }
[Output]
public ITaskItem[] AnalyzersToAdd { get; set; }
[Output]
public ITaskItem[] PlatformManifests { get; set; }
[Output]
public string PackageConflictPreferredPackages { get; set; }
[Output]
public ITaskItem[] PackageConflictOverrides { get; set; }
[Output]
public ITaskItem[] UsedRuntimeFrameworks { get; set; }
private static readonly bool s_allowCacheLookup = Environment.GetEnvironmentVariable(ALLOW_TARGETING_PACK_CACHING) != "0";
public ResolveTargetingPackAssets()
{
}
protected override void ExecuteCore()
{
StronglyTypedInputs inputs = GetInputs();
string cacheKey = inputs.CacheKey();
ResolvedAssetsCacheEntry results;
if (s_allowCacheLookup &&
BuildEngine4?.GetRegisteredTaskObject(
cacheKey,
RegisteredTaskObjectLifetime.AppDomain /* really "until process exit" */)
is ResolvedAssetsCacheEntry cacheEntry)
{
// NOTE: It's conceivably possible that the user modified the targeting
// packs between builds. Since that is extremely rare and the standard
// user scenario reads the targeting pack contents over and over without
// modification, we're electing not to check for file modification and
// returning any cached results that we have.
results = cacheEntry;
}
else
{
results = Resolve(inputs, Log, BuildEngine4);
if (s_allowCacheLookup)
{
BuildEngine4?.RegisterTaskObject(cacheKey, results, RegisteredTaskObjectLifetime.AppDomain, allowEarlyCollection: true);
}
}
ReferencesToAdd = results.ReferencesToAdd;
AnalyzersToAdd = results.AnalyzersToAdd;
PlatformManifests = results.PlatformManifests;
PackageConflictOverrides = results.PackageConflictOverrides;
PackageConflictPreferredPackages = results.PackageConflictPreferredPackages;
UsedRuntimeFrameworks = results.UsedRuntimeFrameworks;
}
internal StronglyTypedInputs GetInputs() => new(
FrameworkReferences,
ResolvedTargetingPacks,
RuntimeFrameworks,
GenerateErrorForMissingTargetingPacks,
NuGetRestoreSupported,
NetCoreTargetingPackRoot,
ProjectLanguage);
private static ResolvedAssetsCacheEntry Resolve(StronglyTypedInputs inputs, Logger log, IBuildEngine4 buildEngine)
{
List<TaskItem> referencesToAdd = new List<TaskItem>();
List<TaskItem> analyzersToAdd = new List<TaskItem>();
List<TaskItem> platformManifests = new List<TaskItem>();
List<TaskItem> packageConflictOverrides = new List<TaskItem>();
List<string> preferredPackages = new List<string>();
var resolvedTargetingPacks = inputs.ResolvedTargetingPacks
.ToDictionary(
tp => tp.Name,
StringComparer.OrdinalIgnoreCase);
FrameworkReference[] frameworkReferences = inputs.FrameworkReferences;
foreach (var frameworkReference in frameworkReferences)
{
bool foundTargetingPack = resolvedTargetingPacks.TryGetValue(frameworkReference.Name, out TargetingPack targetingPack);
string targetingPackRoot = targetingPack?.Path;
if (string.IsNullOrEmpty(targetingPackRoot) || !Directory.Exists(targetingPackRoot))
{
if (inputs.GenerateErrorForMissingTargetingPacks)
{
if (!foundTargetingPack)
{
log.LogError(Strings.UnknownFrameworkReference, frameworkReference.Name);
}
else
{
if (inputs.NuGetRestoreSupported)
{
log.LogError(Strings.TargetingPackNeedsRestore, frameworkReference.Name);
}
else
{
log.LogError(
Strings.TargetingApphostPackMissingCannotRestore,
"Targeting",
$"{inputs.NetCoreTargetingPackRoot}\\{targetingPack.NuGetPackageId ?? ""}",
targetingPack.TargetFramework ?? "",
targetingPack.NuGetPackageId ?? "",
targetingPack.NuGetPackageVersion ?? ""
);
}
}
}
}
else
{
string targetingPackFormat = targetingPack.Format;
if (targetingPackFormat.Equals("NETStandardLegacy", StringComparison.OrdinalIgnoreCase))
{
AddNetStandardTargetingPackAssets(targetingPack, targetingPackRoot, referencesToAdd);
}
else
{
string targetingPackTargetFramework = targetingPack.TargetFramework;
if (string.IsNullOrEmpty(targetingPackTargetFramework))
{
targetingPackTargetFramework = "netcoreapp3.0";
}
string targetingPackDataPath = Path.Combine(targetingPackRoot, "data");
string targetingPackDllFolder = Path.Combine(targetingPackRoot, "ref", targetingPackTargetFramework);
// Fall back to netcoreapp5.0 folder if looking for net5.0 and it's not found
if (!Directory.Exists(targetingPackDllFolder) &&
targetingPackTargetFramework.Equals("net5.0", StringComparison.OrdinalIgnoreCase))
{
targetingPackTargetFramework = "netcoreapp5.0";
targetingPackDllFolder = Path.Combine(targetingPackRoot, "ref", targetingPackTargetFramework);
}
string platformManifestPath = Path.Combine(targetingPackDataPath, "PlatformManifest.txt");
string packageOverridesPath = Path.Combine(targetingPackDataPath, "PackageOverrides.txt");
string frameworkListPath = Path.Combine(targetingPackDataPath, "FrameworkList.xml");
FrameworkListDefinition definition = new(
frameworkListPath,
targetingPackRoot,
targetingPackDllFolder,
targetingPack.Name,
targetingPack.Profile,
targetingPack.NuGetPackageId,
targetingPack.NuGetPackageVersion,
inputs.ProjectLanguage);
AddItemsFromFrameworkList(definition, buildEngine, referencesToAdd, analyzersToAdd);
if (File.Exists(platformManifestPath))
{
platformManifests.Add(new TaskItem(platformManifestPath));
}
if (File.Exists(packageOverridesPath))
{
packageConflictOverrides.Add(CreatePackageOverride(targetingPack.NuGetPackageId, packageOverridesPath));
}
preferredPackages.AddRange(targetingPack.PackageConflictPreferredPackages.Split(';'));
}
}
}
// Calculate which RuntimeFramework items should actually be used based on framework references
HashSet<string> frameworkReferenceNames = new HashSet<string>(frameworkReferences.Select(fr => fr.Name), StringComparer.OrdinalIgnoreCase);
// Filter out duplicate references (which can happen when referencing two different profiles that overlap)
List<TaskItem> deduplicatedReferences = DeduplicateItems(referencesToAdd);
List<TaskItem> deduplicatedAnalyzers = DeduplicateItems(analyzersToAdd);
ResolvedAssetsCacheEntry newCacheEntry = new()
{
ReferencesToAdd = deduplicatedReferences.Distinct().ToArray(),
AnalyzersToAdd = deduplicatedAnalyzers.Distinct().ToArray(),
PlatformManifests = platformManifests.ToArray(),
PackageConflictOverrides = packageConflictOverrides.ToArray(),
PackageConflictPreferredPackages = string.Join(";", preferredPackages),
UsedRuntimeFrameworks = inputs.RuntimeFrameworks.Where(rf => frameworkReferenceNames.Contains(rf.FrameworkName))
.Select(rf => rf.Item)
.ToArray(),
};
return newCacheEntry;
}
// Get distinct items based on case-insensitive ItemSpec comparison
private static List<TaskItem> DeduplicateItems(List<TaskItem> items)
{
HashSet<string> seenItemSpecs = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
List<TaskItem> deduplicatedItems = new List<TaskItem>(items.Count);
foreach (var item in items)
{
if (seenItemSpecs.Add(item.ItemSpec))
{
deduplicatedItems.Add(item);
}
}
return deduplicatedItems;
}
private static TaskItem CreatePackageOverride(string runtimeFrameworkName, string packageOverridesPath)
{
TaskItem packageOverride = new TaskItem(runtimeFrameworkName);
packageOverride.SetMetadata("OverriddenPackages", File.ReadAllText(packageOverridesPath));
return packageOverride;
}
private static void AddNetStandardTargetingPackAssets(TargetingPack targetingPack, string targetingPackRoot, List<TaskItem> referencesToAdd)
{
string targetingPackTargetFramework = targetingPack.TargetFramework;
string targetingPackAssetPath = Path.Combine(targetingPackRoot, "build", targetingPackTargetFramework, "ref");
foreach (var dll in Directory.GetFiles(targetingPackAssetPath, "*.dll"))
{
var reference = CreateItem(
dll,
targetingPack.Name,
targetingPack.NuGetPackageId,
targetingPack.NuGetPackageVersion);
if (!Path.GetFileName(dll).Equals("netstandard.dll", StringComparison.OrdinalIgnoreCase))
{
reference.SetMetadata("Facade", "true");
}
referencesToAdd.Add(reference);
}
}
private static void AddItemsFromFrameworkList(FrameworkListDefinition definition, IBuildEngine4 buildEngine4, List<TaskItem> referenceItems, List<TaskItem> analyzerItems)
{
string frameworkListKey = definition.CacheKey();
if (s_allowCacheLookup &&
buildEngine4?.GetRegisteredTaskObject(
frameworkListKey,
RegisteredTaskObjectLifetime.AppDomain)
is FrameworkList cacheEntry)
{
// As above, we are not even checking timestamps here
// and instead assuming that the targeting pack folder
// is fully immutable.
analyzerItems.AddRange(cacheEntry.Analyzers);
referenceItems.AddRange(cacheEntry.References);
}
XDocument frameworkListDoc = XDocument.Load(definition.FrameworkListPath);
string profile = definition.Profile;
bool usePathElementsInFrameworkListAsFallBack =
TestFirstFileInFrameworkListUsingAssemblyNameConvention(definition.TargetingPackDllFolder, frameworkListDoc);
List<TaskItem> referenceItemsFromThisFramework = new List<TaskItem>();
List<TaskItem> analyzerItemsFromThisFramework = new List<TaskItem>();
foreach (var fileElement in frameworkListDoc.Root.Elements("File"))
{
if (!string.IsNullOrEmpty(profile))
{
var profileAttributeValue = fileElement.Attribute("Profile")?.Value;
if (profileAttributeValue == null)
{
// If profile was specified but this assembly doesn't belong to any profiles, don't reference it
continue;
}
var assemblyProfiles = profileAttributeValue.Split(';');
if (!assemblyProfiles.Contains(profile, StringComparer.OrdinalIgnoreCase))
{
// Assembly wasn't in profile specified, so don't reference it
continue;
}
}
string referencedByDefaultAttributeValue = fileElement.Attribute("ReferencedByDefault")?.Value;
if (referencedByDefaultAttributeValue != null &&
referencedByDefaultAttributeValue.Equals("false", StringComparison.OrdinalIgnoreCase))
{
// Don't automatically reference this assembly if it has ReferencedByDefault="false"
continue;
}
string itemType = fileElement.Attribute("Type")?.Value;
bool isAnalyzer = itemType?.Equals("Analyzer", StringComparison.OrdinalIgnoreCase) ?? false;
string dllPath = usePathElementsInFrameworkListAsFallBack || isAnalyzer ?
Path.Combine(definition.TargetingPackRoot, fileElement.Attribute("Path").Value) :
GetDllPathViaAssemblyName(definition.TargetingPackDllFolder, fileElement);
var item = CreateItem(dllPath, definition.FrameworkReferenceName, definition.NuGetPackageId, definition.NuGetPackageVersion);
item.SetMetadata("AssemblyVersion", fileElement.Attribute("AssemblyVersion").Value);
item.SetMetadata("FileVersion", fileElement.Attribute("FileVersion").Value);
item.SetMetadata("PublicKeyToken", fileElement.Attribute("PublicKeyToken").Value);
if (isAnalyzer)
{
string itemLanguage = fileElement.Attribute("Language")?.Value;
if (itemLanguage != null)
{
// expect cs instead of C#, fs rather than F# per NuGet conventions
string projectLanguage = definition.ProjectLanguage?.Replace('#', 's');
if (projectLanguage == null || !projectLanguage.Equals(itemLanguage, StringComparison.OrdinalIgnoreCase))
{
continue;
}
}
analyzerItemsFromThisFramework.Add(item);
}
else
{
referenceItemsFromThisFramework.Add(item);
}
}
if (s_allowCacheLookup)
{
FrameworkList list = new()
{
Analyzers = analyzerItemsFromThisFramework.ToArray(),
References = referenceItemsFromThisFramework.ToArray(),
};
buildEngine4?.RegisterTaskObject(frameworkListKey, list, RegisteredTaskObjectLifetime.AppDomain, allowEarlyCollection: true);
}
analyzerItems.AddRange(analyzerItemsFromThisFramework);
referenceItems.AddRange(referenceItemsFromThisFramework);
}
/// <summary>
/// Due to https://github.com/dotnet/sdk/issues/12098 we fall back to use "Path" when "AssemblyName" will
/// not resolve the actual dll.
/// </summary>
/// <returns>if use we should use "Path" element in frameworkList as a fallback</returns>
private static bool TestFirstFileInFrameworkListUsingAssemblyNameConvention(string targetingPackDllFolder,
XDocument frameworkListDoc)
{
bool usePathElementsInFrameworkListPathAsFallBack;
var firstFileElement = frameworkListDoc.Root.Elements("File").FirstOrDefault();
if (firstFileElement == null)
{
usePathElementsInFrameworkListPathAsFallBack = false;
}
else
{
string dllPath = GetDllPathViaAssemblyName(targetingPackDllFolder, firstFileElement);
usePathElementsInFrameworkListPathAsFallBack = !File.Exists(dllPath);
}
return usePathElementsInFrameworkListPathAsFallBack;
}
private static string GetDllPathViaAssemblyName(string targetingPackDllFolder, XElement fileElement)
{
string assemblyName = fileElement.Attribute("AssemblyName").Value;
var dllPath = Path.Combine(targetingPackDllFolder, assemblyName + ".dll");
return dllPath;
}
private static TaskItem CreateItem(string dll, ITaskItem targetingPack)
{
return CreateItem(
dll,
targetingPack.ItemSpec,
targetingPack.GetMetadata(MetadataKeys.NuGetPackageId),
targetingPack.GetMetadata(MetadataKeys.NuGetPackageVersion));
}
private static TaskItem CreateItem(string dll, string frameworkReferenceName, string nuGetPackageId, string nuGetPackageVersion)
{
var reference = new TaskItem(dll);
reference.SetMetadata(MetadataKeys.ExternallyResolved, "true");
reference.SetMetadata(MetadataKeys.Private, "false");
reference.SetMetadata(MetadataKeys.NuGetPackageId, nuGetPackageId);
reference.SetMetadata(MetadataKeys.NuGetPackageVersion, nuGetPackageVersion);
reference.SetMetadata("FrameworkReferenceName", frameworkReferenceName);
reference.SetMetadata("FrameworkReferenceVersion", nuGetPackageVersion);
return reference;
}
internal class StronglyTypedInputs
{
public FrameworkReference[] FrameworkReferences { get; private set; }
public TargetingPack[] ResolvedTargetingPacks {get; private set;}
public RuntimeFramework[] RuntimeFrameworks {get; private set;}
public bool GenerateErrorForMissingTargetingPacks {get; private set;}
public bool NuGetRestoreSupported {get; private set;}
public string NetCoreTargetingPackRoot {get; private set;}
public string ProjectLanguage {get; private set;}
public StronglyTypedInputs(
ITaskItem[] frameworkReferences,
ITaskItem[] resolvedTargetingPacks,
ITaskItem[] runtimeFrameworks,
bool generateErrorForMissingTargetingPacks,
bool nuGetRestoreSupported,
string netCoreTargetingPackRoot,
string projectLanguage)
{
FrameworkReferences = frameworkReferences.Select(fr => new FrameworkReference(fr.ItemSpec)).ToArray();
ResolvedTargetingPacks = resolvedTargetingPacks.Select(
item => new TargetingPack(
item.ItemSpec,
item.GetMetadata(MetadataKeys.Path),
item.GetMetadata("TargetingPackFormat"),
item.GetMetadata("TargetFramework"),
item.GetMetadata("Profile"),
item.GetMetadata(MetadataKeys.NuGetPackageId),
item.GetMetadata(MetadataKeys.NuGetPackageVersion),
item.GetMetadata(MetadataKeys.PackageConflictPreferredPackages)))
.ToArray();
RuntimeFrameworks = runtimeFrameworks.Select(item => new RuntimeFramework(item.ItemSpec, item.GetMetadata(MetadataKeys.FrameworkName), item)).ToArray();
GenerateErrorForMissingTargetingPacks = generateErrorForMissingTargetingPacks;
NuGetRestoreSupported = nuGetRestoreSupported;
NetCoreTargetingPackRoot = netCoreTargetingPackRoot;
ProjectLanguage = projectLanguage;
}
public string CacheKey()
{
StringBuilder cacheKeyBuilder = new(nameof(ResolveTargetingPackAssets) + nameof(StronglyTypedInputs));
cacheKeyBuilder.AppendLine();
foreach (var frameworkReference in FrameworkReferences)
{
cacheKeyBuilder.AppendLine(frameworkReference.CacheKey());
}
cacheKeyBuilder.AppendLine();
foreach (var resolvedTargetingPack in ResolvedTargetingPacks)
{
cacheKeyBuilder.AppendLine(resolvedTargetingPack.CacheKey());
}
cacheKeyBuilder.AppendLine(nameof(RuntimeFrameworks));
foreach (var runtimeFramework in RuntimeFrameworks)
{
cacheKeyBuilder.AppendLine(runtimeFramework.CacheKey());
}
cacheKeyBuilder.AppendLine($"{nameof(GenerateErrorForMissingTargetingPacks)}={GenerateErrorForMissingTargetingPacks}");
cacheKeyBuilder.AppendLine($"{nameof(NuGetRestoreSupported)}={NuGetRestoreSupported}");
cacheKeyBuilder.AppendLine($"{nameof(NetCoreTargetingPackRoot)}={NetCoreTargetingPackRoot}");
cacheKeyBuilder.AppendLine($"{nameof(ProjectLanguage)}={ProjectLanguage}");
return cacheKeyBuilder.ToString();
}
}
private class FrameworkList
{
public IReadOnlyList<TaskItem> Analyzers;
public IReadOnlyList<TaskItem> References;
}
internal class FrameworkReference
{
public string Name { get; private set; }
public FrameworkReference(string name)
{
Name = name;
}
public string CacheKey()
{
return $"FrameworkReference: {Name}";
}
}
internal class TargetingPack
{
public string Name { get; private set; }
public string Path { get; private set; }
public string Format { get; private set; }
public string TargetFramework { get; private set; }
public string Profile { get; private set; }
public string NuGetPackageId { get; private set; }
public string NuGetPackageVersion { get; private set; }
public string PackageConflictPreferredPackages { get; private set; }
public TargetingPack(
string name,
string path,
string format,
string targetFramework,
string profile,
string nuGetPackageId,
string nuGetPackageVersion,
string packageConflictPreferredPackages)
{
Name = name;
Path = path;
Format = format;
TargetFramework = targetFramework;
Profile = profile;
NuGetPackageId = nuGetPackageId;
NuGetPackageVersion = nuGetPackageVersion;
PackageConflictPreferredPackages = packageConflictPreferredPackages;
}
public string CacheKey()
{
StringBuilder builder = new();
builder.AppendLine(nameof(TargetingPack));
builder.AppendLine(Name);
builder.AppendLine(Path);
builder.AppendLine(Format);
builder.AppendLine(TargetFramework);
builder.AppendLine(Profile);
builder.AppendLine(NuGetPackageId);
builder.AppendLine(NuGetPackageVersion);
builder.AppendLine(PackageConflictPreferredPackages);
return builder.ToString();
}
}
internal class RuntimeFramework
{
public string Name { get; private set; }
public string FrameworkName { get; private set; }
public readonly ITaskItem Item;
public RuntimeFramework(string name, string frameworkName, ITaskItem item)
{
Name = name;
FrameworkName = frameworkName;
Item = item;
}
public string CacheKey()
{
return $"{nameof(RuntimeFramework)}: {Name} ({FrameworkName})";
}
}
internal readonly struct FrameworkListDefinition
{
public readonly string FrameworkListPath;
public readonly string TargetingPackRoot;
public readonly string TargetingPackDllFolder;
public readonly string ProjectLanguage;
public readonly string FrameworkReferenceName;
public readonly string Profile;
public readonly string NuGetPackageId;
public readonly string NuGetPackageVersion;
public FrameworkListDefinition(string frameworkListPath,
string targetingPackRoot,
string targetingPackDllFolder,
string frameworkReferenceName,
string profile,
string nuGetPackageId,
string nuGetPackageVersion,
string projectLanguage)
{
FrameworkListPath = frameworkListPath;
TargetingPackRoot = targetingPackRoot;
TargetingPackDllFolder = targetingPackDllFolder;
ProjectLanguage = projectLanguage;
FrameworkReferenceName = frameworkReferenceName;
Profile = profile;
NuGetPackageId = nuGetPackageId;
NuGetPackageVersion = nuGetPackageVersion;
}
/// <summary>
/// Construct a key for the framework-specific cache lookup.
/// </summary>
public string CacheKey()
{
// IMPORTANT: any input changes that can affect the output should be included in this key.
StringBuilder keyBuilder = new(nameof(FrameworkListDefinition));
keyBuilder.AppendLine();
keyBuilder.AppendLine(FrameworkListPath);
keyBuilder.AppendLine(TargetingPackRoot);
keyBuilder.AppendLine(TargetingPackDllFolder);
keyBuilder.AppendLine(FrameworkReferenceName);
keyBuilder.AppendLine(Profile);
keyBuilder.AppendLine(NuGetPackageId);
keyBuilder.AppendLine(NuGetPackageVersion);
keyBuilder.AppendLine(ProjectLanguage);
string frameworkListKey = keyBuilder.ToString();
return frameworkListKey;
}
}
private class ResolvedAssetsCacheEntry
{
public ITaskItem[] ReferencesToAdd;
public ITaskItem[] AnalyzersToAdd;
public ITaskItem[] PlatformManifests;
public string PackageConflictPreferredPackages;
public ITaskItem[] PackageConflictOverrides;
public ITaskItem[] UsedRuntimeFrameworks;
}
}
}