-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProgram.cs
More file actions
617 lines (536 loc) · 23 KB
/
Program.cs
File metadata and controls
617 lines (536 loc) · 23 KB
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
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Text.RegularExpressions;
var srcPath = GetSrcPath(args);
var combinedDir = Path.Combine(srcPath, "Basic.Reference.Assemblies");
var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
NetCoreApp31();
Net50();
Net60();
Net60Windows();
Net70();
Net80();
Net80Windows();
Net90();
Net100();
AspNet80();
AspNet90();
AspNet100();
NetStandard13();
NetStandard20();
NetStandard21();
Net20();
Net35();
Net40();
Net461();
Net472();
CombinedReferenceInfo();
void NetCoreApp31()
{
var content = GetGeneratedContent("NetCoreApp31", [@"microsoft.netcore.app.ref/3.1.0/ref/netcoreapp3.1"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.NetCoreApp31");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net50()
{
var content = GetGeneratedContent("Net50", [@"microsoft.netcore.app.ref/5.0.0/ref/net5.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net50");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net60()
{
var content = GetGeneratedContent("Net60", [@"microsoft.netcore.app.ref/6.0.27/ref/net6.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net60");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net60Windows()
{
var content = GetGeneratedContent("Net60Windows", [@"microsoft.windowsdesktop.app.ref/6.0.27/ref/net6.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net60Windows");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net70()
{
var content = GetGeneratedContent("Net70", [@"microsoft.netcore.app.ref/7.0.16/ref/net7.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net70");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net80()
{
var content = GetGeneratedContent("Net80", [@"microsoft.netcore.app.ref/8.0.3/ref/net8.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net80");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
File.WriteAllText(Path.Combine(combinedDir, "Generated.Net80.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(combinedDir, "Generated.Net80.targets"), content.TargetsContent, encoding);
}
void Net80Windows()
{
var content = GetGeneratedContent("Net80Windows", [@"microsoft.windowsdesktop.app.ref/8.0.8/ref/net8.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net80Windows");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net90()
{
var content = GetGeneratedContent("Net90", [@"microsoft.netcore.app.ref/9.0.0/ref/net9.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net90");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net100()
{
var content = GetGeneratedContent("Net100", [@"microsoft.netcore.app.ref/10.0.0/ref/net10.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net100");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void AspNet80()
{
var content = GetGeneratedContent("AspNet80", [@"microsoft.netcore.app.ref/8.0.3/ref/net8.0", @"microsoft.aspnetcore.app.ref/8.0.3/ref/net8.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.AspNet80");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void AspNet90()
{
var content = GetGeneratedContent("AspNet90", [@"microsoft.netcore.app.ref/9.0.0/ref/net9.0", @"microsoft.aspnetcore.app.ref/9.0.0/ref/net9.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.AspNet90");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void AspNet100()
{
var content = GetGeneratedContent("AspNet100", [@"microsoft.netcore.app.ref/10.0.0/ref/net10.0", @"microsoft.aspnetcore.app.ref/10.0.0/ref/net10.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.AspNet100");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void NetStandard13()
{
// netstandard1.3 is a special case because it's not a single package. Instead the collection of DLLs that make
// up the TFM are just checked into the repo directly.
var realPackagePath = Path.Combine(srcPath, "Resources", "netstandard1.3");
var content = GetGeneratedContentCore("NetStandard13", [realPackagePath], [], srcPath, @"$(MSBuildThisFileDirectory)..");
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.NetStandard13");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void NetStandard20()
{
var content = GetGeneratedContent(
"NetStandard20",
[@"netstandard.library/2.0.3/build/netstandard2.0/ref"],
[
@"microsoft.csharp/4.7.0/ref/netstandard2.0",
@"microsoft.visualbasic/10.3.0/ref/netstandard2.0",
@"system.threading.tasks.extensions/4.5.4/lib/netstandard2.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.NetStandard20");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
File.WriteAllText(Path.Combine(combinedDir, "Generated.NetStandard20.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(combinedDir, "Generated.NetStandard20.targets"), content.TargetsContent, encoding);
}
void NetStandard21()
{
var content = GetGeneratedContent(
"NetStandard21",
[@"netstandard.library.ref/2.1.0/ref/netstandard2.1"],
[
@"microsoft.csharp/4.7.0/ref/netstandard2.0",
@"microsoft.visualbasic/10.3.0/ref/netstandard2.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.NetStandard21");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net20()
{
var content = GetGeneratedContent("Net20", [@"microsoft.netframework.referenceassemblies.net20/1.0.3/build/.NETFramework/v2.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net20");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net40()
{
var content = GetGeneratedContent("Net40", [@"microsoft.netframework.referenceassemblies.net40/1.0.3/build/.NETFramework/v4.0"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net40");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net35()
{
var content = GetGeneratedContent("Net35", [@"microsoft.netframework.referenceassemblies.net35/1.0.3/build/.NETFramework/v3.5"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net35");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net461()
{
var content = GetGeneratedContent(
"Net461",
[@"microsoft.netframework.referenceassemblies.net461/1.0.3/build/.NETFramework/v4.6.1"],
[
@"system.threading.tasks.extensions/4.5.4/lib/net461",
@"system.valuetuple/4.5.0/lib/net461"
]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net461");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
}
void Net472()
{
var content = GetGeneratedContent("Net472", [@"microsoft.netframework.referenceassemblies.net472/1.0.3/build/.NETFramework/v4.7.2"]);
var targetDir = Path.Combine(srcPath, "Basic.Reference.Assemblies.Net472");
File.WriteAllText(Path.Combine(targetDir, "Generated.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(targetDir, "Generated.targets"), content.TargetsContent, encoding);
File.WriteAllText(Path.Combine(combinedDir, "Generated.Net472.cs"), content.CodeContent, encoding);
File.WriteAllText(Path.Combine(combinedDir, "Generated.Net472.targets"), content.TargetsContent, encoding);
}
const string referenceInfo = """
/// <summary>
/// Contains different properties of a reference that are interesting for use in testing.
/// </suummary>
public readonly struct ReferenceInfo
{
/// <summary>
/// The file name of the reference.
/// </summary>
public string FileName { get; }
/// <summary>
/// The image bytes of the reference
/// </summary>
public byte[] ImageBytes { get; }
/// <summary>
/// The reference loaded as a <see cref="PortableExecutableReference"/>
/// </summary>
public PortableExecutableReference Reference { get; }
/// <summary>
/// The MVID of this reference
/// </summary>
public Guid Mvid { get; }
public ReferenceInfo(string fileName, byte[] imageBytes, PortableExecutableReference reference, Guid mvid)
{
FileName = fileName;
ImageBytes = imageBytes;
Reference = reference;
Mvid = mvid;
}
public void Deconstruct(out string fileName, out byte[] imageBytes, out PortableExecutableReference reference, out Guid mvid)
{
fileName = FileName;
imageBytes = ImageBytes;
reference = Reference;
mvid = Mvid;
}
public (string FileName, byte[] ImageBytes, PortableExecutableReference Reference, Guid Mvid) AsTuple() =>
(FileName, ImageBytes, Reference, Mvid);
}
""";
void CombinedReferenceInfo()
{
var content = $$"""
// This is a generated file, please edit Generate\Program.cs to change the contents
using Microsoft.CodeAnalysis;
using System;
namespace Basic.Reference.Assemblies;
{{referenceInfo}}
""";
File.WriteAllText(Path.Combine(combinedDir, "ReferenceInfo.cs"), content, encoding);
}
string GetSrcPath(string[] args)
{
var dir = Environment.CurrentDirectory;
do
{
var filePath = Path.Combine(dir, "Src", "Generate", "Program.cs");
if (File.Exists(filePath))
{
return Path.Combine(dir, "Src");
}
dir = Path.GetDirectoryName(dir);
} while (dir != null);
throw new Exception("Could not find workspace path");
}
static (Guid Mvid, bool IsAssembly)? GetMvid(string filePath)
{
try
{
using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new PEReader(fileStream, PEStreamOptions.LeaveOpen);
var mdReader = reader.GetMetadataReader();
GuidHandle handle = mdReader.GetModuleDefinition().Mvid;
return (mdReader.GetGuid(handle), mdReader.IsAssembly);
}
catch (Exception)
{
// The ref assemblies often include a few native DLLs. These won't have MIVD so we can just ignore them.
return null;
}
}
static string GetReferenceInfoIndented(string indent)
{
var builder = new StringBuilder();
using var reader = new StringReader(referenceInfo);
var first = true;
while (reader.ReadLine() is string line)
{
if (!first)
{
builder.AppendLine();
}
if (!string.IsNullOrEmpty(line))
{
builder.Append($"{indent}{line}");
}
first = false;
}
return builder.ToString();
}
static string GetReferenceInfo(string containingTypeName) => $$"""
#if !BASIC_REFERENCE_ASSEMBLIES_COMBINED
public static partial class {{containingTypeName}}
{
{{GetReferenceInfoIndented(" ")}}
}
#endif
""";
static (string CodeContent, string TargetsContent) GetGeneratedContentCore(string name, string[] packagePaths, string[] extraPackagePaths, string packagePrefix, string targetsPrefix)
{
var targetsContent = new StringBuilder();
targetsContent.AppendLine("""
<Project>
<ItemGroup>
""");
var resourcesContent = new StringBuilder();
resourcesContent.AppendLine($$"""
public static partial class {{name}}
{
public static class Resources
{
""");
var refContent = new StringBuilder();
refContent.AppendLine($$"""
public static partial class {{name}}
{
public static class References
{
""");
var refInfoContent = new StringBuilder();
refInfoContent.AppendLine($$"""
public static partial class {{name}}
{
public static class ReferenceInfos
{
""");
ProcessDlls(
name,
packagePaths,
packagePrefix,
targetsPrefix,
"References",
targetsContent,
resourcesContent,
refContent,
refInfoContent);
var codeContent = new StringBuilder();
codeContent.AppendLine($$"""
// This is a generated file, please edit Src\Generate\Program.cs to change the contents
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;
namespace Basic.Reference.Assemblies;
""");
codeContent.AppendLine(refInfoContent.ToString());
codeContent.AppendLine(refContent.ToString());
if (extraPackagePaths.Length > 0)
{
var extraRefContent = new StringBuilder();
extraRefContent.AppendLine($$"""
public static partial class {{name}}
{
public static class ExtraReferences
{
""");
var extraRefInfoContent = new StringBuilder();
extraRefInfoContent.AppendLine($$"""
public static partial class {{name}}
{
public static class ExtraReferenceInfos
{
""");
ProcessDlls(
name,
extraPackagePaths,
packagePrefix,
targetsPrefix,
"ExtraReferences",
targetsContent,
resourcesContent,
extraRefContent,
extraRefInfoContent);
codeContent.AppendLine(extraRefInfoContent.ToString());
codeContent.AppendLine(extraRefContent.ToString());
}
resourcesContent.AppendLine("""
}
}
""");
codeContent.AppendLine(resourcesContent.ToString());
codeContent.AppendLine(GetReferenceInfo(name));
targetsContent.AppendLine("""
</ItemGroup>
</Project>
""");
return (codeContent.ToString(), targetsContent.ToString());
void ProcessDlls(
string name,
string[] packagePaths,
string packagePrefix,
string targetsPrefix,
string refName,
StringBuilder targetsContent,
StringBuilder resourcesContent,
StringBuilder refContent,
StringBuilder refInfoContent)
{
var lowerName = name.ToLower();
var allPropNames = new List<string>();
foreach (var dllInfo in FindDlls(packagePaths, packagePrefix))
{
var dllName = Path.GetFileName(dllInfo.FilePath)!;
var dll = Path.GetFileNameWithoutExtension(dllName);
var logicalName = $"{lowerName}.{dll}";
var dllResourcePath = Path.Join(targetsPrefix, dllInfo.RelativeFilePath);
targetsContent.AppendLine($$"""
<EmbeddedResource Include="{{dllResourcePath}}" WithCulture="false">
<LogicalName>{{logicalName}}</LogicalName>
<Link>Resources\{{lowerName}}\{{dllName}}</Link>
</EmbeddedResource>
""");
var propName = dll.Replace(".", "");
allPropNames.Add(propName);
var fieldName = $"_{propName}";
resourcesContent.AppendLine($$"""
/// <summary>
/// The image bytes for {{dllName}}
/// </summary>
public static byte[] {{propName}} => ResourceLoader.GetOrCreateResource(ref {{fieldName}}, "{{logicalName}}");
private static byte[]? {{fieldName}};
""");
refInfoContent.AppendLine($$"""
/// <summary>
/// The <see cref="ReferenceInfo"/> for {{dllName}}
/// </summary>
public static ReferenceInfo {{propName}} => new ReferenceInfo("{{dllName}}", Resources.{{propName}}, {{name}}.{{refName}}.{{propName}}, global::System.Guid.Parse("{{dllInfo.Mvid}}"));
""");
refContent.AppendLine($$"""
private static PortableExecutableReference? {{fieldName}};
/// <summary>
/// The <see cref="PortableExecutableReference"/> for {{dllName}}
/// </summary>
public static PortableExecutableReference {{propName}}
{
get
{
if ({{fieldName}} is null)
{
{{fieldName}} = AssemblyMetadata.CreateFromImage(ResourceLoader.GetResourceBlobAsImmutable("{{logicalName}}")).GetReference(filePath: "{{dllName}}", display: "{{dll}} ({{lowerName}})");
}
return {{fieldName}};
}
}
""");
}
refInfoContent.AppendLine("""
private static ImmutableArray<ReferenceInfo> _all;
public static ImmutableArray<ReferenceInfo> All
{
get
{
if (_all.IsDefault)
{
_all =
[
""");
refContent.AppendLine("""
private static ImmutableArray<PortableExecutableReference> _all;
public static ImmutableArray<PortableExecutableReference> All
{
get
{
if (_all.IsDefault)
{
_all =
[
""");
foreach (var propName in allPropNames)
{
refInfoContent.AppendLine($" {propName},");
refContent.AppendLine($" {propName},");
}
refContent.AppendLine("""
];
}
return _all;
}
}
}
}
""");
refInfoContent.AppendLine("""
];
}
return _all;
}
}
public static IEnumerable<(string FileName, byte[] ImageBytes, PortableExecutableReference Reference, Guid Mvid)> AllValues => All.Select(x => x.AsTuple());
}
}
""");
}
static IEnumerable<(string FilePath, string RelativeFilePath, Guid Mvid)> FindDlls(string[] packagePaths, string packagePrefix)
{
var dllPaths = new List<string>();
foreach (var packagePath in packagePaths)
{
dllPaths.AddRange(Directory.GetFiles(packagePath, "*.dll"));
var facadesPath = Path.Combine(packagePath, "Facades");
if (Directory.Exists(facadesPath))
{
dllPaths.AddRange(Directory.GetFiles(facadesPath, "*.dll"));
}
}
var allPropNames = new List<string>();
foreach (var dllPath in dllPaths)
{
if (GetMvid(dllPath) is not var (mvid, isAssembly) || !isAssembly)
{
continue;
}
var relativeFilePath = dllPath.Substring(packagePrefix.Length);
yield return (dllPath, relativeFilePath, mvid);
}
}
}
static (string CodeContent, string TargetsContent) GetGeneratedContent(string name, string[] packagePaths, string[]? extraPackagePaths = null)
{
var nugetPackageRoot = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
if (string.IsNullOrEmpty(nugetPackageRoot))
{
nugetPackageRoot = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE")!, ".nuget", "packages");
}
var realPackagePaths = packagePaths.Select(x => Path.Combine(nugetPackageRoot, x)).ToArray();
var realExtraPackagePaths = extraPackagePaths is not null
? extraPackagePaths.Select(x => Path.Combine(nugetPackageRoot, x)).ToArray()
: [];
return GetGeneratedContentCore(name, realPackagePaths, realExtraPackagePaths, nugetPackageRoot, "$(NuGetPackageRoot)");
}