Skip to content

Commit bc3dc72

Browse files
authored
Fix path data in FrameworkList.xml (#26622)
* Fix path data in FrameworkList.xml * Move FrameworkList.xml to SharedFxRoot * Fix targeting pack xml test * Add test * Add another test * Extract .xml files to Helix as well * Add another test * Update TestRunner.cs * Remove slash
1 parent d7dcac3 commit bc3dc72

File tree

5 files changed

+164
-15
lines changed

5 files changed

+164
-15
lines changed

eng/helix/content/RunTests/TestRunner.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ public async Task<bool> InstallAspNetAppIfNeededAsync()
9898
Directory.CreateDirectory(appRuntimePath);
9999
Console.WriteLine($"Set ASPNET_RUNTIME_PATH: {appRuntimePath}");
100100
EnvironmentVariables.Add("ASPNET_RUNTIME_PATH", appRuntimePath);
101-
Console.WriteLine($"Found AspNetRuntime: {Options.AspNetRuntime}, extracting *.txt,json,dll to {appRuntimePath}");
101+
Console.WriteLine($"Found AspNetRuntime: {Options.AspNetRuntime}, extracting *.txt,json,dll,xml to {appRuntimePath}");
102102
using (var archive = ZipFile.OpenRead(Options.AspNetRuntime))
103103
{
104104
foreach (var entry in archive.Entries)
105105
{
106106
// These are the only extensions that end up in the shared fx directory
107107
if (entry.Name.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) ||
108108
entry.Name.EndsWith(".json", StringComparison.OrdinalIgnoreCase) ||
109-
entry.Name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
109+
entry.Name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
110+
entry.Name.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
110111
{
111112
entry.ExtractToFile(Path.Combine(appRuntimePath, entry.Name), overwrite: true);
112113
}

eng/tools/RepoTasks/CreateFrameworkListFile.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ public class CreateFrameworkListFile : Task
2323
[Required]
2424
public string TargetFile { get; set; }
2525

26-
public string ManagedRoot { get; set; } = "";
27-
28-
public string NativeRoot { get; set; } = "";
29-
3026
/// <summary>
3127
/// Extra attributes to place on the root node.
3228
///
@@ -53,7 +49,8 @@ public override bool Execute()
5349
AssemblyName = FileUtilities.GetAssemblyName(item.ItemSpec),
5450
FileVersion = FileUtilities.GetFileVersion(item.ItemSpec),
5551
IsNative = item.GetMetadata("IsNativeImage") == "true",
56-
IsSymbolFile = item.GetMetadata("IsSymbolFile") == "true"
52+
IsSymbolFile = item.GetMetadata("IsSymbolFile") == "true",
53+
PackagePath = item.GetMetadata("PackagePath")
5754
})
5855
.Where(f =>
5956
!f.IsSymbolFile &&
@@ -65,7 +62,7 @@ public override bool Execute()
6562
new XAttribute("Type", f.IsNative ? "Native" : "Managed"),
6663
new XAttribute(
6764
"Path",
68-
Path.Combine(f.IsNative ? NativeRoot : ManagedRoot, f.Filename).Replace('\\', '/')));
65+
Path.Combine(f.PackagePath, f.Filename).Replace('\\', '/')));
6966

7067
if (f.AssemblyName != null)
7168
{

src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
109109

110110
<AssetTargetFallback>$(AssetTargetFallback);native,Version=0.0</AssetTargetFallback>
111111

112-
<FrameworkListFileName>RuntimeList.xml</FrameworkListFileName>
113-
<FrameworkListOutputPath>$(ArtifactsObjDir)$(FrameworkListFileName)</FrameworkListOutputPath>
114-
115112
<NativePlatform>$(TargetArchitecture)</NativePlatform>
116113
<NativePlatform Condition=" '$(NativePlatform)' == 'x86' ">Win32</NativePlatform>
117114
</PropertyGroup>
@@ -156,6 +153,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant
156153
<RedistLayoutTargetDir>$(RedistSharedFrameworkLayoutRoot)$(SharedRuntimeSubPath)</RedistLayoutTargetDir>
157154
<LocalInstallationOutputPath>$(LocalDotNetRoot)$(SharedRuntimeSubPath)</LocalInstallationOutputPath>
158155

156+
<FrameworkListFileName>RuntimeList.xml</FrameworkListFileName>
157+
<FrameworkListOutputPath>$(SharedFxLayoutTargetDir)$(FrameworkListFileName)</FrameworkListOutputPath>
158+
159159
<InternalArchiveOutputFileName>$(InternalInstallerBaseName)-$(PackageVersion)-$(TargetRuntimeIdentifier)$(ArchiveExtension)</InternalArchiveOutputFileName>
160160
<InternalArchiveOutputPath>$(InstallersOutputPath)$(InternalArchiveOutputFileName)</InternalArchiveOutputPath>
161161
<RedistArchiveOutputFileName>$(RuntimeInstallerBaseName)-$(PackageVersion)-$(TargetRuntimeIdentifier)$(ArchiveExtension)</RedistArchiveOutputFileName>
@@ -531,11 +531,17 @@ This package is an internal implementation of the .NET Core SDK and is not meant
531531
DependsOnTargets="_ResolveSharedFrameworkContent"
532532
BeforeTargets="_GetPackageFiles"
533533
Condition="'$(ManifestsPackagePath)' != ''">
534+
535+
<ItemGroup>
536+
<SharedFxContent Condition="'%(SharedFxContent.Extension)' == '.dll'">
537+
<PackagePath Condition="'%(SharedFxContent.IsNativeImage)' == 'true'">$(NativeAssetsPackagePath)</PackagePath>
538+
<PackagePath Condition="'%(SharedFxContent.IsNativeImage)' != 'true'">$(ManagedAssetsPackagePath)</PackagePath>
539+
</SharedFxContent>
540+
</ItemGroup>
541+
534542
<RepoTasks.CreateFrameworkListFile
535543
Files="@(SharedFxContent)"
536544
TargetFile="$(FrameworkListOutputPath)"
537-
ManagedRoot="$(ManagedAssetsPackagePath)"
538-
NativeRoot="$(NativeAssetsPackagePath)"
539545
RootAttributes="@(FrameworkListRootAttributes)" />
540546

541547
<ItemGroup>

src/Framework/test/SharedFxTests.cs

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.IO.Compression;
78
using System.Linq;
89
using System.Reflection;
910
using System.Reflection.Metadata;
1011
using System.Reflection.PortableExecutable;
12+
using System.Xml.Linq;
1113
using Newtonsoft.Json.Linq;
1214
using Xunit;
1315
using Xunit.Abstractions;
@@ -209,5 +211,105 @@ public void ItContainsVersionFile()
209211
Assert.Equal(TestData.GetRepositoryCommit(), lines[0]);
210212
Assert.Equal(TestData.GetTestDataValue("RuntimePackageVersion"), lines[1]);
211213
}
214+
215+
[Fact]
216+
public void RuntimeListListsContainsCorrectEntries()
217+
{
218+
var runtimeListPath = Path.Combine(_sharedFxRoot, "RuntimeList.xml");
219+
var expectedAssemblies = TestData.GetSharedFxDependencies()
220+
.Split(';', StringSplitOptions.RemoveEmptyEntries)
221+
.ToHashSet();
222+
223+
AssertEx.FileExists(runtimeListPath);
224+
225+
var runtimeListDoc = XDocument.Load(runtimeListPath);
226+
var runtimeListEntries = runtimeListDoc.Root.Descendants();
227+
228+
_output.WriteLine("==== file contents ====");
229+
_output.WriteLine(string.Join('\n', runtimeListEntries.Select(i => i.Attribute("Path").Value).OrderBy(i => i)));
230+
_output.WriteLine("==== expected assemblies ====");
231+
_output.WriteLine(string.Join('\n', expectedAssemblies.OrderBy(i => i)));
232+
233+
var actualAssemblies = runtimeListEntries
234+
.Select(i =>
235+
{
236+
var filePath = i.Attribute("Path").Value;
237+
var fileParts = filePath.Split('/');
238+
var fileName = fileParts[fileParts.Length - 1];
239+
return fileName.EndsWith(".dll", StringComparison.Ordinal)
240+
? fileName.Substring(0, fileName.Length - 4)
241+
: fileName;
242+
})
243+
.ToHashSet();
244+
245+
var missing = expectedAssemblies.Except(actualAssemblies);
246+
var unexpected = actualAssemblies.Except(expectedAssemblies);
247+
248+
_output.WriteLine("==== missing assemblies from the runtime list ====");
249+
_output.WriteLine(string.Join('\n', missing));
250+
_output.WriteLine("==== unexpected assemblies in the runtime list ====");
251+
_output.WriteLine(string.Join('\n', unexpected));
252+
253+
Assert.Empty(missing);
254+
Assert.Empty(unexpected);
255+
256+
Assert.All(runtimeListEntries, i =>
257+
{
258+
var assemblyType = i.Attribute("Type").Value;
259+
var assemblyPath = i.Attribute("Path").Value;
260+
var fileVersion = i.Attribute("FileVersion").Value;
261+
262+
if (assemblyType.Equals("Managed"))
263+
{
264+
var assemblyVersion = i.Attribute("AssemblyVersion").Value;
265+
Assert.True(Version.TryParse(assemblyVersion, out _), $"{assemblyPath} has assembly version {assemblyVersion}. Assembly version must be convertable to System.Version");
266+
}
267+
268+
Assert.True(Version.TryParse(fileVersion, out _), $"{assemblyPath} has file version {fileVersion}. File version must be convertable to System.Version");
269+
});
270+
}
271+
272+
[Fact]
273+
public void RuntimeListListsContainsCorrectPaths()
274+
{
275+
var runtimePath = Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH");
276+
if (string.IsNullOrEmpty(runtimePath))
277+
{
278+
return;
279+
}
280+
281+
var runtimeListPath = Path.Combine(_sharedFxRoot, "RuntimeList.xml");
282+
283+
AssertEx.FileExists(runtimeListPath);
284+
285+
var runtimeListDoc = XDocument.Load(runtimeListPath);
286+
var runtimeListEntries = runtimeListDoc.Root.Descendants();
287+
288+
var sharedFxPath = Path.Combine(Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT"), ("Microsoft.AspNetCore.App.Runtime.win-x64." + TestData.GetSharedFxVersion() + ".nupkg"));
289+
290+
ZipArchive archive = ZipFile.OpenRead(sharedFxPath);
291+
292+
var actualPaths = archive.Entries
293+
.Where(i => i.FullName.EndsWith(".dll"))
294+
.Select(i => i.FullName).ToHashSet();
295+
296+
var expectedPaths = runtimeListEntries.Select(i => i.Attribute("Path").Value).ToHashSet();
297+
298+
_output.WriteLine("==== package contents ====");
299+
_output.WriteLine(string.Join('\n', actualPaths.OrderBy(i => i)));
300+
_output.WriteLine("==== expected assemblies ====");
301+
_output.WriteLine(string.Join('\n', expectedPaths.OrderBy(i => i)));
302+
303+
var missing = expectedPaths.Except(actualPaths);
304+
var unexpected = actualPaths.Except(expectedPaths);
305+
306+
_output.WriteLine("==== missing assemblies from the runtime list ====");
307+
_output.WriteLine(string.Join('\n', missing));
308+
_output.WriteLine("==== unexpected assemblies in the runtime list ====");
309+
_output.WriteLine(string.Join('\n', unexpected));
310+
311+
Assert.Empty(missing);
312+
Assert.Empty(unexpected);
313+
}
212314
}
213315
}

src/Framework/test/TargetingPackTests.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.IO.Compression;
78
using System.Linq;
89
using System.Reflection;
910
using System.Reflection.Metadata;
@@ -313,14 +314,14 @@ public void FrameworkListListsContainsCorrectEntries()
313314
var frameworkListEntries = frameworkListDoc.Root.Descendants();
314315

315316
_output.WriteLine("==== file contents ====");
316-
_output.WriteLine(string.Join('\n', frameworkListEntries.Select(i => i.Attribute("Path").Value).OrderBy(i => i)));
317+
_output.WriteLine(string.Join('\n', frameworkListEntries.Select(i => i.Attribute("AssemblyName").Value).OrderBy(i => i)));
317318
_output.WriteLine("==== expected assemblies ====");
318319
_output.WriteLine(string.Join('\n', expectedAssemblies.OrderBy(i => i)));
319320

320321
var actualAssemblies = frameworkListEntries
321322
.Select(i =>
322323
{
323-
var fileName = i.Attribute("Path").Value;
324+
var fileName = i.Attribute("AssemblyName").Value;
324325
return fileName.EndsWith(".dll", StringComparison.Ordinal)
325326
? fileName.Substring(0, fileName.Length - 4)
326327
: fileName;
@@ -348,5 +349,47 @@ public void FrameworkListListsContainsCorrectEntries()
348349
Assert.True(Version.TryParse(fileVersion, out _), $"{assemblyPath} has file version {fileVersion}. File version must be convertable to System.Version");
349350
});
350351
}
352+
353+
[Fact]
354+
public void FrameworkListListsContainsCorrectPaths()
355+
{
356+
if (!_isTargetingPackBuilding || string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
357+
{
358+
return;
359+
}
360+
361+
var frameworkListPath = Path.Combine(_targetingPackRoot, "data", "FrameworkList.xml");
362+
363+
AssertEx.FileExists(frameworkListPath);
364+
365+
var frameworkListDoc = XDocument.Load(frameworkListPath);
366+
var frameworkListEntries = frameworkListDoc.Root.Descendants();
367+
368+
var targetingPackPath = Path.Combine(Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT"), ("Microsoft.AspNetCore.App.Ref." + TestData.GetSharedFxVersion() + ".nupkg"));
369+
370+
ZipArchive archive = ZipFile.OpenRead(targetingPackPath);
371+
372+
var actualPaths = archive.Entries
373+
.Where(i => i.FullName.EndsWith(".dll"))
374+
.Select(i => i.FullName).ToHashSet();
375+
376+
var expectedPaths = frameworkListEntries.Select(i => i.Attribute("Path").Value).ToHashSet();
377+
378+
_output.WriteLine("==== package contents ====");
379+
_output.WriteLine(string.Join('\n', actualPaths.OrderBy(i => i)));
380+
_output.WriteLine("==== expected assemblies ====");
381+
_output.WriteLine(string.Join('\n', expectedPaths.OrderBy(i => i)));
382+
383+
var missing = expectedPaths.Except(actualPaths);
384+
var unexpected = actualPaths.Except(expectedPaths);
385+
386+
_output.WriteLine("==== missing assemblies from the runtime list ====");
387+
_output.WriteLine(string.Join('\n', missing));
388+
_output.WriteLine("==== unexpected assemblies in the runtime list ====");
389+
_output.WriteLine(string.Join('\n', unexpected));
390+
391+
Assert.Empty(missing);
392+
Assert.Empty(unexpected);
393+
}
351394
}
352395
}

0 commit comments

Comments
 (0)