Clean up testing and move sdk download to test project

This commit is contained in:
Jackson Schuster 2024-03-20 14:43:00 -07:00
parent a783e3b6a9
commit 7180f58733
25 changed files with 170 additions and 1456 deletions

View file

@ -15,7 +15,6 @@
UnpackTarballs;
BuildXPlatTasks;
BuildMSBuildSdkResolver;
BuildSdkArchiveDiff;
BuildUnifiedBuildValidationTests;
BuildLeakDetection;
ExtractToolPackage;
@ -127,15 +126,6 @@
Targets="Build" />
</Target>
<Target Name="BuildSdkArchiveDiff"
Condition="'$(ShortStack)' != 'true' and '$(PortableBuild)' == 'true' and '$(PgoInstrument)' != 'true'" >
<MSBuild Projects="tasks\Microsoft.DotNet.SourceBuild.Tasks.SdkArchiveDiff\Microsoft.DotNet.SourceBuild.Tasks.SdkArchiveDiff.csproj"
Targets="Restore"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())" />
<MSBuild Projects="tasks\Microsoft.DotNet.SourceBuild.Tasks.SdkArchiveDiff\Microsoft.DotNet.SourceBuild.Tasks.SdkArchiveDiff.csproj"
Targets="Build" />
</Target>
<Target Name="GenerateRootFs"
Condition="'$(BuildOS)' != 'windows' and '$(CrossBuild)' == 'true' and '$(ROOTFS_DIR)' == ''">
<PropertyGroup>

View file

@ -1,136 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Formats.Tar;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
public abstract class Archive : IDisposable
{
public static async Task<Archive> Create(string path, CancellationToken cancellationToken = default)
{
if (path.EndsWith(".tar.gz"))
return await TarArchive.Create(path, cancellationToken);
else if (path.EndsWith(".zip"))
return ZipFileArchive.Create(path);
else
throw new NotSupportedException("Unsupported archive type");
}
public abstract string[] GetFileNames();
public abstract bool Contains(string relativePath);
public abstract void Dispose();
public class TarArchive : Archive
{
private string _extractedFolder;
private TarArchive(string extractedFolder)
{
_extractedFolder = extractedFolder;
}
public static new async Task<TarArchive> Create(string path, CancellationToken cancellationToken = default)
{
var tmpFolder = Directory.CreateTempSubdirectory(nameof(FindArchiveDiffs));
using (var gzStream = File.OpenRead(path))
using (var gzipStream = new GZipStream(gzStream, CompressionMode.Decompress))
{
await TarFile.ExtractToDirectoryAsync(gzipStream, tmpFolder.FullName, true, cancellationToken);
}
return new TarArchive(tmpFolder.FullName);
}
public override bool Contains(string relativePath)
{
return File.Exists(Path.Combine(_extractedFolder, relativePath));
}
public override string[] GetFileNames()
{
return Directory.GetFiles(_extractedFolder, "*", SearchOption.AllDirectories).Select(f => f.Substring(_extractedFolder.Length + 1)).ToArray();
}
public override void Dispose()
{
if (Directory.Exists(_extractedFolder))
Directory.Delete(_extractedFolder, true);
}
}
public class ZipFileArchive : Archive
{
private ZipArchive _archive;
private ZipFileArchive(ZipArchive archive)
{
_archive = archive;
}
public static ZipFileArchive Create(string path)
{
return new ZipFileArchive(new ZipArchive(File.OpenRead(path)));
}
public override bool Contains(string relativePath)
{
return _archive.GetEntry(relativePath) != null;
}
public override string[] GetFileNames()
{
return _archive.Entries.Select(e => e.FullName).ToArray();
}
public override void Dispose()
{
_archive.Dispose();
}
}
private static string GetArchiveExtension(string path)
{
if (path.EndsWith(".tar.gz"))
{
return ".tar.gz";
}
else if (path.EndsWith(".zip"))
{
return ".zip";
}
else
{
throw new ArgumentException($"Invalid archive extension '{path}': must end with .tar.gz or .zip");
}
}
public static (string Version, string Rid, string extension) GetInfoFromFileName(string filename, string packageName)
{
var extension = GetArchiveExtension(filename);
var Version = VersionIdentifier.GetVersion(filename);
if (Version is null)
throw new ArgumentException("Invalid archive file name '{filename}': No valid version found in file name.");
// Once we've removed the version, package name, and extension, we should be left with the RID
var Rid = filename
.Replace(extension, "")
.Replace(Version, "")
.Replace(packageName, "")
.Trim('-', '.', '_');
// A RID with '.' must have a version number after the first '.' in each part of the RID. For example, alpine.3.10-arm64.
// Otherwise, it's likely an archive of another type of file that we don't handle here, for example, .msi.wixpack.zip.
var ridParts = Rid.Split('-');
foreach(var item in ridParts.SelectMany(p => p.Split('.').Skip(1)))
{
if (!int.TryParse(item, out _))
throw new ArgumentException($"Invalid Rid '{Rid}' in archive file name '{filename}'. Expected RID with '.' to be part of a version. This likely means the file is an archive of a different file type.");
}
return (Version, Rid, extension);
}
}

View file

@ -1,126 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
static class Diff
{
public static ITaskItem TaskItemFromDiff((string, DifferenceKind) diff)
{
var item = new TaskItem(diff.Item1);
item.SetMetadata("Kind", Enum.GetName(diff.Item2));
return item;
}
public enum DifferenceKind
{
/// <summary>
/// Present in the test but not in the baseline
/// </summary>
Added,
/// <summary>
/// Present in the baseline but not in the test
/// </summary>
Removed,
/// <summary>
/// Present in both the baseline and test
/// </summary>
Unchanged
}
/// <summary>
/// Uses the Longest Common Subsequence algorithm (as used in 'git diff') to find the differences between two lists of strings.
/// Returns a list of the joined lists with the differences marked as either added or removed.
/// </summary>
public static List<(string, DifferenceKind DifferenceKind)> GetDiffs(
Span<string> baselineSequence,
Span<string> testSequence,
Func<string, string, bool> equalityComparer,
Func<string, string>? formatter = null,
CancellationToken cancellationToken = default)
{
// Edit distance algorithm: https://en.wikipedia.org/wiki/Longest_common_subsequence
// cancellationToken.ThrowIfCancellationRequested();
formatter ??= static s => s;
// Optimization: remove common prefix
int i = 0;
List<(string, DifferenceKind)> prefix = [];
while (i < baselineSequence.Length && i < testSequence.Length && equalityComparer(baselineSequence[i], testSequence[i]))
{
prefix.Add((formatter(baselineSequence[i]), DifferenceKind.Unchanged));
i++;
}
baselineSequence = baselineSequence[i..];
testSequence = testSequence[i..];
// Initialize first row and column
int[,] m = new int[baselineSequence.Length + 1, testSequence.Length + 1];
for (i = 0; i <= baselineSequence.Length; i++)
{
m[i, 0] = i;
}
for (i = 0; i <= testSequence.Length; i++)
{
m[0, i] = i;
}
// Compute edit distance
for (i = 1; i <= baselineSequence.Length; i++)
{
cancellationToken.ThrowIfCancellationRequested();
for (int j = 1; j <= testSequence.Length; j++)
{
if (equalityComparer(baselineSequence[i - 1], testSequence[j - 1]))
{
m[i, j] = m[i - 1, j - 1];
}
else
{
m[i, j] = 1 + Math.Min(m[i - 1, j], m[i, j - 1]);
}
}
}
// Trace back the edits
int row = baselineSequence.Length;
int col = testSequence.Length;
List<(string, DifferenceKind)> diff = [];
while (row > 0 || col > 0)
{
cancellationToken.ThrowIfCancellationRequested();
if (row > 0 && col > 0 && equalityComparer(baselineSequence[row - 1], testSequence[col - 1]))
{
diff.Add((formatter(baselineSequence[row - 1]), DifferenceKind.Unchanged));
row--;
col--;
}
else if (col > 0 && (row == 0 || m[row, col - 1] <= m[row - 1, col]))
{
diff.Add((formatter(testSequence[col - 1]), DifferenceKind.Added));
col--;
}
else if (row > 0 && (col == 0 || m[row, col - 1] > m[row - 1, col]))
{
diff.Add((formatter(baselineSequence[row - 1]), DifferenceKind.Removed));
row--;
}
else
{
throw new UnreachableException();
}
}
diff.Reverse();
prefix.AddRange(diff);
return prefix;
}
}

View file

@ -1,49 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Build.Framework;
using Task = System.Threading.Tasks.Task;
public class FindArchiveDiffs : Microsoft.Build.Utilities.Task, ICancelableTask
{
[Required]
public required ITaskItem BaselineArchive { get; init; }
[Required]
public required ITaskItem TestArchive { get; init; }
[Output]
public ITaskItem[] ContentDifferences { get; set; } = [];
private CancellationTokenSource _cancellationTokenSource = new();
private CancellationToken cancellationToken => _cancellationTokenSource.Token;
public override bool Execute()
{
return Task.Run(ExecuteAsync).Result;
}
public async Task<bool> ExecuteAsync()
{
var baselineTask = Archive.Create(BaselineArchive.ItemSpec);
var testTask = Archive.Create(TestArchive.ItemSpec);
Task.WaitAll([baselineTask, testTask], cancellationToken);
using var baseline = await baselineTask;
using var test = await testTask;
var baselineFiles = baseline.GetFileNames();
var testFiles = test.GetFileNames();
ContentDifferences =
Diff.GetDiffs(baselineFiles, testFiles, VersionIdentifier.AreVersionlessEqual, static p => VersionIdentifier.RemoveVersions(p, "{VERSION}"), cancellationToken)
.Select(Diff.TaskItemFromDiff)
.ToArray();
return true;
}
public void Cancel()
{
_cancellationTokenSource.Cancel();
}
}

View file

@ -1,94 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Build.Framework;
public abstract class GetClosestArchive : Microsoft.Build.Utilities.Task, ICancelableTask
{
[Required]
public required string BuiltArchivePath { get; init; }
[Output]
public string ClosestOfficialArchivePath { get; set; } = "";
private string? _builtVersion;
protected string BuiltVersion
{
get => _builtVersion ?? throw new InvalidOperationException();
private set => _builtVersion = value;
}
private string? _builtRid;
protected string BuiltRid
{
get => _builtRid ?? throw new InvalidOperationException();
private set => _builtRid = value;
}
private string? _archiveExtension;
protected string ArchiveExtension
{
get => _archiveExtension ?? throw new InvalidOperationException();
private set => _archiveExtension = value;
}
/// <summary>
/// The name of the package to find the closest official archive for. For example, "dotnet-sdk" or "aspnetcore-runtime".
/// </summary>
protected abstract string ArchiveName { get; }
private CancellationTokenSource _cancellationTokenSource = new();
protected CancellationToken CancellationToken => _cancellationTokenSource.Token;
public void Cancel()
{
_cancellationTokenSource.Cancel();
}
/// <summary>
/// Get the URL of the latest official archive for the given version string and RID.
/// </summary>
public abstract Task<string?> GetClosestOfficialArchiveUrl();
public abstract Task<string?> GetClosestOfficialArchiveVersion();
public override bool Execute()
{
return Task.Run(ExecuteAsync).Result;
}
public async Task<bool> ExecuteAsync()
{
CancellationToken.ThrowIfCancellationRequested();
var filename = Path.GetFileName(BuiltArchivePath);
(BuiltVersion, BuiltRid, ArchiveExtension) = Archive.GetInfoFromFileName(filename, ArchiveName);
Log.LogMessage($"Finding closest official archive for '{ArchiveName}' version '{BuiltVersion}' RID '{BuiltRid}'");
string? downloadUrl = await GetClosestOfficialArchiveUrl();
if (downloadUrl == null)
{
Log.LogError($"Failed to find a download URL for '{ArchiveName}' version '{BuiltVersion}' RID '{BuiltRid}'");
return false;
}
HttpClient client = new HttpClient();
Log.LogMessage(MessageImportance.High, $"Downloading {downloadUrl}");
HttpResponseMessage packageResponse = await client.GetAsync(downloadUrl, CancellationToken);
var packageUriPath = packageResponse.RequestMessage!.RequestUri!.LocalPath;
ClosestOfficialArchivePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + Path.GetFileName(packageUriPath));
Log.LogMessage($"Copying {packageUriPath} to {ClosestOfficialArchivePath}");
using (var file = File.Create(ClosestOfficialArchivePath))
{
await packageResponse.Content.CopyToAsync(file, CancellationToken);
}
return true;
}
}

View file

@ -1,44 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Build.Framework;
public class GetClosestOfficialSdk : GetClosestArchive
{
protected override string ArchiveName => "dotnet-sdk";
HttpClient client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
private string? closestVersion;
private string? closestUrl;
public override async Task<string?> GetClosestOfficialArchiveUrl()
{
// Channel in the form of 9.0.1xx
var channel = BuiltVersion[..5] + "xx";
var akaMsUrl = $"https://aka.ms/dotnet/{channel}/daily/{ArchiveName}-{BuiltRid}{ArchiveExtension}";
var redirectResponse = await client.GetAsync(akaMsUrl, CancellationToken);
// aka.ms returns a 301 for valid redirects and a 302 to Bing for invalid URLs
if (redirectResponse.StatusCode != HttpStatusCode.Moved)
{
Log.LogMessage(MessageImportance.High, $"Failed to find package at '{akaMsUrl}': invalid aka.ms URL");
return null;
}
closestUrl = redirectResponse.Headers.Location!.ToString();
closestVersion = VersionIdentifier.GetVersion(closestUrl);
return closestUrl;
}
public override async Task<string?> GetClosestOfficialArchiveVersion()
{
if (closestUrl is not null)
{
return closestVersion;
}
_ = await GetClosestOfficialArchiveUrl();
return closestVersion;
}
}

View file

@ -1,57 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Build.Framework;
public class GetValidArchiveItems : Microsoft.Build.Utilities.Task
{
[Required]
public required ITaskItem[] ArchiveItems { get; init; }
[Required]
public required string ArchiveName { get; init; }
[Output]
public ITaskItem[] ValidArchiveItems { get; set; } = [];
public override bool Execute()
{
List<ITaskItem> archiveItems = new();
foreach (var item in ArchiveItems)
{
var filename = Path.GetFileName(item.ItemSpec);
try
{
// Ensure the version and RID info can be parsed from the item
_ = Archive.GetInfoFromFileName(filename, ArchiveName);
archiveItems.Add(item);
}
catch (ArgumentException e)
{
Log.LogMessage($"'{item.ItemSpec}' is not a valid archive name: '{e.Message}'");
continue;
}
}
switch (archiveItems.Count)
{
case 0:
Log.LogMessage(MessageImportance.High, "No valid archive items found");
ValidArchiveItems = [];
return false;
case 1:
Log.LogMessage(MessageImportance.High, $"{archiveItems[0]} is the only valid archive item found");
ValidArchiveItems = archiveItems.ToArray();
break;
default:
archiveItems.Sort((a, b) => a.ItemSpec.Length - b.ItemSpec.Length);
Log.LogMessage(MessageImportance.High, $"Multiple valid archive items found: '{string.Join("', '", archiveItems)}'");
ValidArchiveItems = archiveItems.ToArray();
break;
}
return true;
}
}

View file

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" PrivateAssets="all" ExcludeAssets="Runtime" Version="$(MicrosoftBuildVersion)" />
</ItemGroup>
</Project>

View file

@ -1,257 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Copied from https://github.com/dotnet/arcade/blob/db45698020f58f88eef75b23b2598a59872918f6/src/Microsoft.DotNet.VersionTools/lib/src/BuildManifest/VersionIdentifier.cs
// Conflicting MSBuild versions and some customizations make it difficult to use the Arcade assembly.
public static class VersionIdentifier
{
private static readonly HashSet<string> _knownTags = new HashSet<string>
{
"alpha",
"beta",
"preview",
"prerelease",
"servicing",
"rtm",
"rc"
};
private static readonly SortedDictionary<string, string> _sequencesToReplace =
new SortedDictionary<string, string>
{
{ "-.", "." },
{ "..", "." },
{ "--", "-" },
{ "//", "/" },
{ "_.", "." }
};
private const string _finalSuffix = "final";
private static readonly char[] _delimiters = new char[] { '.', '-', '_' };
/// <summary>
/// Identify the version of an asset.
///
/// Asset names can come in two forms:
/// - Blobs that include the full path
/// - Packages that do not include any path elements.
///
/// There may be multiple different version numbers in a blob path.
/// This method starts at the last segment of the path and works backward to find a version number.
/// </summary>
/// <param name="assetName">Asset name</param>
/// <returns>Version, or null if none is found.</returns>
public static string? GetVersion(string assetName)
{
string[] pathSegments = assetName.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string? potentialVersion = null;
for (int i = pathSegments.Length - 1; i >= 0; i--)
{
potentialVersion = GetVersionForSingleSegment(pathSegments[i]);
if (potentialVersion != null)
{
return potentialVersion;
}
}
return potentialVersion;
}
/// <summary>
/// Identify the version number of an asset segment.
/// </summary>
/// <param name="assetPathSegment">Asset segment</param>
/// <returns>Version number, or null if none was found</returns>
/// <remarks>
/// Identifying versions is not particularly easy. To constrain the problem,
/// we apply the following assumptions which are generally valid for .NET Core.
/// - We always have major.minor.patch, and it always begins the version string.
/// - The only pre-release or build metadata labels we use begin with the _knownTags shown above.
/// - We use additional numbers in our version numbers after the initial
/// major.minor.patch-prereleaselabel.prereleaseiteration segment,
/// but any non-numeric element will end the version string.
/// - The <see cref="_delimiters"/> we use in versions and file names are ., -, and _.
/// </remarks>
private static string? GetVersionForSingleSegment(string assetPathSegment)
{
// Find the start of the version number by finding the major.minor.patch.
// Scan the string forward looking for a digit preceded by one of the delimiters,
// then look for a minor.patch, completing the major.minor.patch. Continue to do so until we get
// to something that is NOT major.minor.patch (this is necessary because we sometimes see things like:
// VS.Redist.Common.NetCore.Templates.x86.2.2.3.0.101-servicing-014320.nupkg
// Continue iterating until we find ALL potential versions. Return the one that is the latest in the segment
// This is to deal with files with multiple major.minor.patchs in the file name, for example:
// Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100.Msi.x64.6.0.0-rc.1.21380.2.symbols.nupkg
int currentIndex = 0;
// Stack of major.minor.patch.
Stack<(int versionNumber, int index)> majorMinorPatchStack = new Stack<(int, int)>(3);
string? majorMinorPatch = null;
int majorMinorPatchIndex = 0;
StringBuilder versionSuffix = new StringBuilder();
char prevDelimiterCharacter = char.MinValue;
char nextDelimiterCharacter = char.MinValue;
Dictionary<int, string> majorMinorPatchDictionary = new Dictionary<int, string>();
while (true)
{
string nextSegment;
prevDelimiterCharacter = nextDelimiterCharacter;
int nextDelimiterIndex = assetPathSegment.IndexOfAny(_delimiters, currentIndex);
if (nextDelimiterIndex != -1)
{
nextDelimiterCharacter = assetPathSegment[nextDelimiterIndex];
nextSegment = assetPathSegment.Substring(currentIndex, nextDelimiterIndex - currentIndex);
}
else
{
nextSegment = assetPathSegment.Substring(currentIndex);
}
// If we have not yet found the major/minor/patch, then there are four cases:
// - There have been no potential major/minor/patch numbers found and the current segment is a number. Push onto the majorMinorPatch stack
// and continue.
// - There has been at least one number found, but less than 3, and the current segment not a number or not preceded by '.'. In this case,
// we should clear out the stack and continue the search.
// - There have been at least 2 numbers found and the current segment is a number and preceded by '.'. Push onto the majorMinorPatch stack and continue
// - There have been at least 3 numbers found and the current segment is not a number or not preceded by '-'. In this case, we can call this the major minor
// patch number and no longer need to continue searching
if (majorMinorPatch == null)
{
bool isNumber = int.TryParse(nextSegment, out int potentialVersionSegment);
if ((majorMinorPatchStack.Count == 0 && isNumber) ||
(majorMinorPatchStack.Count > 0 && prevDelimiterCharacter == '.' && isNumber))
{
majorMinorPatchStack.Push((potentialVersionSegment, currentIndex));
}
// Check for partial major.minor.patch cases, like: 2.2.bar or 2.2-100.bleh
else if (majorMinorPatchStack.Count > 0 && majorMinorPatchStack.Count < 3 &&
(prevDelimiterCharacter != '.' || !isNumber))
{
majorMinorPatchStack.Clear();
}
// Determine whether we are done with major.minor.patch after this update.
if (majorMinorPatchStack.Count >= 3 && (prevDelimiterCharacter != '.' || !isNumber || nextDelimiterIndex == -1))
{
// Done with major.minor.patch, found. Pop the top 3 elements off the stack.
(int patch, int patchIndex) = majorMinorPatchStack.Pop();
(int minor, int minorIndex) = majorMinorPatchStack.Pop();
(int major, int majorIndex) = majorMinorPatchStack.Pop();
majorMinorPatch = $"{major}.{minor}.{patch}";
majorMinorPatchIndex = majorIndex;
}
}
// Don't use else, so that we don't miss segments
// in case we are just deciding that we've finished major minor patch.
if (majorMinorPatch != null)
{
// Now look at the next segment. If it looks like it could be part of a version, append to what we have
// and continue. If it can't, then we're done.
//
// Cases where we should break out and be done:
// - We have an empty pre-release label and the delimiter is not '-'.
// - We have an empty pre-release label and the next segment does not start with a known tag.
// - We have a non-empty pre-release label and the current segment is not a number and also not 'final'
// A corner case of versioning uses .final to represent a non-date suffixed final pre-release version:
// 3.1.0-preview.10.final
if (versionSuffix.Length == 0 &&
(prevDelimiterCharacter != '-' || !_knownTags.Any(tag => nextSegment.StartsWith(tag, StringComparison.OrdinalIgnoreCase))))
{
majorMinorPatchDictionary.Add(majorMinorPatchIndex, majorMinorPatch);
majorMinorPatch = null;
versionSuffix = new StringBuilder();
}
else if (versionSuffix.Length != 0 && !int.TryParse(nextSegment, out int potentialVersionSegment) && nextSegment != _finalSuffix)
{
majorMinorPatchDictionary.Add(majorMinorPatchIndex, $"{majorMinorPatch}{versionSuffix.ToString()}");
majorMinorPatch = null;
versionSuffix = new StringBuilder();
}
else
{
// Append the delimiter character and then the current segment
versionSuffix.Append(prevDelimiterCharacter);
versionSuffix.Append(nextSegment);
}
}
if (nextDelimiterIndex != -1)
{
currentIndex = nextDelimiterIndex + 1;
}
else
{
break;
}
}
if (majorMinorPatch != null)
{
majorMinorPatchDictionary.Add(majorMinorPatchIndex, $"{majorMinorPatch}{versionSuffix.ToString()}");
}
if (!majorMinorPatchDictionary.Any())
{
return null;
}
int maxKey = majorMinorPatchDictionary.Keys.Max();
return majorMinorPatchDictionary[maxKey];
}
/// <summary>
/// Given an asset name, remove all .NET Core version numbers (as defined by GetVersionForSingleSegment)
/// from the string
/// </summary>
/// <param name="assetName">Asset</param>
/// <returns>Asset name without versions</returns>
public static string RemoveVersions(string assetName, string replacement = "")
{
string[] pathSegments = assetName.Split('/', '\\');
// Remove the version number from each segment, then join back together and
// remove any useless character sequences.
for (int i = 0; i < pathSegments.Length; i++)
{
if (!string.IsNullOrEmpty(pathSegments[i]))
{
string? versionForSegment = GetVersionForSingleSegment(pathSegments[i]);
if (versionForSegment != null)
{
pathSegments[i] = pathSegments[i].Replace(versionForSegment, replacement);
}
}
}
// Continue replacing things until there is nothing left to replace.
string assetWithoutVersions = string.Join("/", pathSegments);
bool anyReplacements = true;
while (anyReplacements)
{
string replacementIterationResult = assetWithoutVersions;
foreach (var sequence in _sequencesToReplace)
{
replacementIterationResult = replacementIterationResult.Replace(sequence.Key, sequence.Value);
}
anyReplacements = replacementIterationResult != assetWithoutVersions;
assetWithoutVersions = replacementIterationResult;
}
return assetWithoutVersions;
}
public static bool AreVersionlessEqual(string assetName1, string assetName2)
{
return RemoveVersions(assetName1, "{VERSION}") == RemoveVersions(assetName2, "{VERSION}");
}
}

View file

@ -1,8 +1,5 @@
<Project>
<UsingTask AssemblyFile="$(SdkArchiveDiffTasksAssembly)" TaskName="GetValidArchiveItems" />
<UsingTask AssemblyFile="$(SdkArchiveDiffTasksAssembly)" TaskName="GetClosestOfficialSdk" />
<PropertyGroup>
<UnifiedBuildValidationTestsDir>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'test', 'Microsoft.DotNet.UnifiedBuild.Tests'))</UnifiedBuildValidationTestsDir>
<UnifiedBuildValidationTestsProject>$([MSBuild]::NormalizeDirectory('$(UnifiedBuildValidationTestsDir)', 'Microsoft.DotNet.UnifiedBuild.Tests'))</UnifiedBuildValidationTestsProject>
@ -14,39 +11,15 @@
<PropertyGroup>
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
<SdkBaselineValidationVerbosity Condition="'$(SdkBaselineValidationVerbosity)' == ''">normal</SdkBaselineValidationVerbosity>
</PropertyGroup>
<GetValidArchiveItems ArchiveItems="@(SdkTarballItem)"
ArchiveName="dotnet-sdk">
<Output TaskParameter="ValidArchiveItems"
ItemName="_BuiltSdkArchivePath"/>
</GetValidArchiveItems>
<!-- There should only be 1 SDK archive -->
<Error Text="Multiple valid dotnet-sdk archives found."
Condition="'@(_BuiltSdkArchivePath->Count())' != '1'" />
<GetClosestOfficialSdk BuiltArchivePath="@(_BuiltSdkArchivePath)" Condition="'$(BaselineMsftArchivePath)' == ''">
<Output TaskParameter="ClosestOfficialArchivePath"
PropertyName="BaselineMsftArchivePath" />
</GetClosestOfficialSdk>
<PropertyGroup>
<_BuiltSdkArchivePath>@(_BuiltSdkArchivePath)</_BuiltSdkArchivePath>
</PropertyGroup>
<!-- Multiple loggers are specified so that results are captured in trx and pipelines can fail with AzDO pipeline warnings -->
<Exec Command="$(DotnetTool) test $(UnifiedBuildValidationTestsDir) --logger:trx -c $(Configuration) -p:VSTestUseMSBuildOutput=false"
IgnoreStandardErrorWarningFormat="true"
EnvironmentVariables="
UNIFIED_BUILD_VALIDATION_SDK_TARBALL_PATH=$(_BuiltSdkArchivePath);
UNIFIED_BUILD_VALIDATION_MSFT_SDK_TARBALL_PATH=$(BaselineMsftArchivePath);
UNIFIED_BUILD_VALIDATION_SOURCEBUILT_ARTIFACTS_PATH=$(SourceBuiltArtifactsPath);
UNIFIED_BUILD_VALIDATION_SDK_TARBALL_PATH=$(SdkTarballItem);
UNIFIED_BUILD_VALIDATION_TARGET_RID=$(TargetRid);
UNIFIED_BUILD_VALIDATION_PORTABLE_RID=$(PortableRid);
UNIFIED_BUILD_VALIDATION_CUSTOM_PACKAGES_PATH=$(CustomSourceBuiltPackagesPath);
UNIFIED_BUILD_VALIDATION_WARN_SDK_CONTENT_DIFFS=true;
UNIFIED_BUILD_VALIDATION_BUILD_VERSION=$(SdkTarballPath);
$(CustomTestEnvVars)" />
</Target>

View file

@ -44,6 +44,8 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests
public static void CompareBaselineContents(string baselineFileName, string actualContents, ITestOutputHelper outputHelper, bool warnOnDiffs = false, string baselineSubDir = "")
{
string actualFilePath = Path.Combine(TestBase.LogsDirectory, $"Updated{baselineFileName}");
if (!actualContents.EndsWith(Environment.NewLine))
actualContents += Environment.NewLine;
File.WriteAllText(actualFilePath, actualContents);
CompareFiles(GetBaselineFilePath(baselineFileName, baselineSubDir), actualFilePath, outputHelper, warnOnDiffs);
@ -90,8 +92,8 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests
public static string GetBaselineFilePath(string baselineFileName, string baselineSubDir = "") =>
Path.Combine(GetAssetsDirectory(), "baselines", baselineSubDir, baselineFileName);
public static string RemoveRids(string diff, bool isPortable = false) =>
isPortable ? diff.Replace(Config.PortableRid, "portable-rid") : diff.Replace(Config.TargetRid, "banana-rid");
public static string RemoveRids(string diff, string portableRid, string targetRid, bool isPortable = false) =>
isPortable ? diff.Replace(portableRid, "portable-rid") : diff.Replace(targetRid, "banana-rid");
public static string RemoveVersions(string source)
{
@ -100,7 +102,7 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests
string result = Regex.Replace(source, $@"{pathSeparator}(net|roslyn)[1-9]+\.[0-9]+{pathSeparator}", match =>
{
string wordPart = match.Groups[1].Value;
return $"{Path.DirectorySeparatorChar}{wordPart}{NonSemanticVersionPlaceholder}{Path.DirectorySeparatorChar}";
return $"{'/'}{wordPart}{NonSemanticVersionPlaceholder}{'/'}";
});
// Remove semantic versions

View file

@ -4,46 +4,78 @@
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
internal static class Config
public class Config : IDisposable
{
public const string DotNetDirectoryEnv = "UNIFIED_BUILD_VALIDATION_DOTNET_DIR";
public const string IncludeArtifactsSizeEnv = "UNIFIED_BUILD_VALIDATION_INCLUDE_ARTIFACTSSIZE";
public Config()
{
BuildVersion = Environment.GetEnvironmentVariable(BuildVersionEnv) ?? throw new InvalidOperationException($"'{BuildVersionEnv}' must be specified");
PortableRid = Environment.GetEnvironmentVariable(PortableRidEnv) ?? throw new InvalidOperationException($"'{PortableRidEnv}' must be specified");
UbSdkArchivePath = Environment.GetEnvironmentVariable(UbSdkTarballPathEnv) ?? throw new InvalidOperationException($"'{UbSdkTarballPathEnv}' must be specified");
TargetRid = Environment.GetEnvironmentVariable(TargetRidEnv) ?? throw new InvalidOperationException($"'{TargetRidEnv}' must be specified");
TargetArchitecture = TargetRid.Split('-')[1];
WarnOnSdkContentDiffs = bool.TryParse(Environment.GetEnvironmentVariable(WarnSdkContentDiffsEnv), out bool warnOnSdkContentDiffs) && warnOnSdkContentDiffs;
MsftSdkArchivePath = Environment.GetEnvironmentVariable(MsftSdkTarballPathEnv) ?? DownloadMsftSdkArchive().Result;
}
public const string BuildVersionEnv = "UNIFIED_BUILD_VALIDATION_BUILD_VERSION";
public const string MsftSdkTarballPathEnv = "UNIFIED_BUILD_VALIDATION_MSFT_SDK_TARBALL_PATH";
public const string PoisonReportPathEnv = "UNIFIED_BUILD_VALIDATION_POISON_REPORT_PATH";
public const string PortableRidEnv = "UNIFIED_BUILD_VALIDATION_PORTABLE_RID";
public const string PrereqsPathEnv = "UNIFIED_BUILD_VALIDATION_PREREQS_PATH";
public const string CustomPackagesPathEnv = "UNIFIED_BUILD_VALIDATION_CUSTOM_PACKAGES_PATH";
public const string SdkTarballPathEnv = "UNIFIED_BUILD_VALIDATION_SDK_TARBALL_PATH";
public const string UbSdkTarballPathEnv = "UNIFIED_BUILD_VALIDATION_SDK_TARBALL_PATH";
public const string SourceBuiltArtifactsPathEnv = "UNIFIED_BUILD_VALIDATION_SOURCEBUILT_ARTIFACTS_PATH";
public const string TargetRidEnv = "UNIFIED_BUILD_VALIDATION_TARGET_RID";
public const string WarnSdkContentDiffsEnv = "UNIFIED_BUILD_VALIDATION_WARN_SDK_CONTENT_DIFFS";
public const string WarnLicenseScanDiffsEnv = "UNIFIED_BUILD_VALIDATION_WARN_LICENSE_SCAN_DIFFS";
public const string RunningInCIEnv = "UNIFIED_BUILD_VALIDATION_RUNNING_IN_CI";
public const string LicenseScanPathEnv = "UNIFIED_BUILD_VALIDATION_LICENSE_SCAN_PATH";
public static string DotNetDirectory { get; } =
Environment.GetEnvironmentVariable(DotNetDirectoryEnv) ?? Path.Combine(Directory.GetCurrentDirectory(), ".dotnet");
public static string? MsftSdkTarballPath { get; } = Environment.GetEnvironmentVariable(MsftSdkTarballPathEnv);
public static string PortableRid { get; } = Environment.GetEnvironmentVariable(PortableRidEnv) ??
throw new InvalidOperationException($"'{Config.PortableRidEnv}' must be specified");
public static string? PrereqsPath { get; } = Environment.GetEnvironmentVariable(PrereqsPathEnv);
public static string? CustomPackagesPath { get; } = Environment.GetEnvironmentVariable(CustomPackagesPathEnv);
public static string? SdkTarballPath { get; } = Environment.GetEnvironmentVariable(SdkTarballPathEnv);
public static string? SourceBuiltArtifactsPath { get; } = Environment.GetEnvironmentVariable(SourceBuiltArtifactsPathEnv);
public static string TargetRid { get; } = Environment.GetEnvironmentVariable(TargetRidEnv) ??
throw new InvalidOperationException($"'{Config.TargetRidEnv}' must be specified");
public static string TargetArchitecture { get; } = TargetRid.Split('-')[1];
public static bool WarnOnSdkContentDiffs { get; } =
bool.TryParse(Environment.GetEnvironmentVariable(WarnSdkContentDiffsEnv), out bool warnOnSdkContentDiffs) && warnOnSdkContentDiffs;
public static bool WarnOnLicenseScanDiffs { get; } =
bool.TryParse(Environment.GetEnvironmentVariable(WarnLicenseScanDiffsEnv), out bool warnOnLicenseScanDiffs) && warnOnLicenseScanDiffs;
public string? MsftSdkArchivePath { get; }
public string BuildVersion { get; }
public string PortableRid { get; }
public string UbSdkArchivePath { get; }
public string TargetRid { get; }
public string TargetArchitecture { get; }
public bool WarnOnSdkContentDiffs { get; }
string? _downloadedMsftSdkPath = null;
// Indicates whether the tests are being run in the context of a CI pipeline
public static bool RunningInCI { get; } =
bool.TryParse(Environment.GetEnvironmentVariable(RunningInCIEnv), out bool runningInCI) && runningInCI;
static string GetArchiveExtension(string path)
{
if (path.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
return ".zip";
if (path.EndsWith(".tar.gz", StringComparison.InvariantCultureIgnoreCase))
return ".tar.gz";
throw new InvalidOperationException($"Path does not have a valid archive extenions: '{path}'");
}
public static string? LicenseScanPath { get; } = Environment.GetEnvironmentVariable(LicenseScanPathEnv);
public async Task<string> DownloadMsftSdkArchive()
{
var client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
var channel = BuildVersion[..5] + "xx";
var akaMsUrl = $"https://aka.ms/dotnet/{channel}/daily/dotnet-sdk-{TargetRid}{GetArchiveExtension(UbSdkArchivePath)}";
var redirectResponse = await client.GetAsync(akaMsUrl);
// aka.ms returns a 301 for valid redirects and a 302 to Bing for invalid URLs
if (redirectResponse.StatusCode != HttpStatusCode.Moved)
{
throw new InvalidOperationException($"Could not find download link for Microsoft built sdk at '{akaMsUrl}'");
}
var closestUrl = redirectResponse.Headers.Location!.ToString();
HttpResponseMessage packageResponse = await client.GetAsync(closestUrl);
var packageUriPath = packageResponse.RequestMessage!.RequestUri!.LocalPath;
_downloadedMsftSdkPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + Path.GetFileName(packageUriPath));
using (var file = File.Create(_downloadedMsftSdkPath))
{
await packageResponse.Content.CopyToAsync(file);
}
return _downloadedMsftSdkPath;
}
public void Dispose()
{
if (_downloadedMsftSdkPath != null)
{
File.Delete(_downloadedMsftSdkPath);
}
}
}

View file

@ -1,341 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Sockets;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
internal class DotNetHelper
{
private static readonly object s_lockObj = new();
public static string DotNetPath { get; } = Path.Combine(Config.DotNetDirectory, "dotnet");
public static string PackagesDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), "packages");
public static string ProjectsDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), $"projects-{DateTime.Now:yyyyMMddHHmmssffff}");
private ITestOutputHelper OutputHelper { get; }
public bool IsMonoRuntime { get; }
public DotNetHelper(ITestOutputHelper outputHelper)
{
OutputHelper = outputHelper;
lock (s_lockObj)
{
if (!Directory.Exists(Config.DotNetDirectory))
{
if (!File.Exists(Config.SdkTarballPath))
{
throw new InvalidOperationException($"Tarball path '{Config.SdkTarballPath}' specified in {Config.SdkTarballPath} does not exist.");
}
Directory.CreateDirectory(Config.DotNetDirectory);
Utilities.ExtractTarball(Config.SdkTarballPath, Config.DotNetDirectory, outputHelper);
}
IsMonoRuntime = DetermineIsMonoRuntime(Config.DotNetDirectory);
// if (!Directory.Exists(ProjectsDirectory))
// {
// Directory.CreateDirectory(ProjectsDirectory);
// InitNugetConfig();
// }
// if (!Directory.Exists(PackagesDirectory))
// {
// Directory.CreateDirectory(PackagesDirectory);
// }
}
}
private static void InitNugetConfig()
{
bool useLocalPackages = !string.IsNullOrEmpty(Config.PrereqsPath);
string nugetConfigPrefix = useLocalPackages ? "local" : "online";
string nugetConfigPath = Path.Combine(ProjectsDirectory, "NuGet.Config");
File.Copy(
Path.Combine(BaselineHelper.GetAssetsDirectory(), $"{nugetConfigPrefix}.NuGet.Config"),
nugetConfigPath);
if (useLocalPackages)
{
// When using local packages this feed is always required. It contains packages that are
// not produced by source-build but are required by the various project templates.
if (!Directory.Exists(Config.PrereqsPath))
{
throw new InvalidOperationException(
$"Prereqs path '{Config.PrereqsPath}' specified in {Config.PrereqsPathEnv} does not exist.");
}
string nugetConfig = File.ReadAllText(nugetConfigPath);
nugetConfig = nugetConfig.Replace("SMOKE_TEST_PACKAGE_FEED", Config.PrereqsPath);
// This package feed is optional. You can use an additional feed of source-built packages to run the
// smoke-tests as offline as possible.
if (Config.CustomPackagesPath != null)
{
if (!Directory.Exists(Config.CustomPackagesPath))
{
throw new ArgumentException($"Specified --with-packages {Config.CustomPackagesPath} does not exist.");
}
nugetConfig = nugetConfig.Replace("CUSTOM_PACKAGE_FEED", Config.CustomPackagesPath);
}
else
{
nugetConfig = string.Join(Environment.NewLine, nugetConfig.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Where(s => !s.Contains("CUSTOM_PACKAGE_FEED")).ToArray());
}
File.WriteAllText(nugetConfigPath, nugetConfig);
}
}
public void ExecuteCmd(string args, string? workingDirectory = null, Action<Process>? processConfigCallback = null,
int? expectedExitCode = 0, int millisecondTimeout = -1)
{
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess(
DotNetPath,
args,
OutputHelper,
configureCallback: (process) => configureProcess(process, workingDirectory),
millisecondTimeout: millisecondTimeout);
if (expectedExitCode != null) {
ExecuteHelper.ValidateExitCode(executeResult, (int) expectedExitCode);
}
void configureProcess(Process process, string? workingDirectory)
{
ConfigureProcess(process, workingDirectory);
processConfigCallback?.Invoke(process);
}
}
public static void ConfigureProcess(Process process, string? workingDirectory)
{
if (workingDirectory != null)
{
process.StartInfo.WorkingDirectory = workingDirectory;
}
process.StartInfo.EnvironmentVariables["DOTNET_CLI_TELEMETRY_OPTOUT"] = "1";
process.StartInfo.EnvironmentVariables["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "1";
process.StartInfo.EnvironmentVariables["DOTNET_ROOT"] = Config.DotNetDirectory;
process.StartInfo.EnvironmentVariables["NUGET_PACKAGES"] = PackagesDirectory;
process.StartInfo.EnvironmentVariables["PATH"] = $"{Config.DotNetDirectory}:{Environment.GetEnvironmentVariable("PATH")}";
}
public void ExecuteBuild(string projectName) =>
ExecuteCmd($"build {GetBinLogOption(projectName, "build")}", GetProjectDirectory(projectName));
/// <summary>
/// Create a new .NET project and return the path to the created project folder.
/// </summary>
public string ExecuteNew(string projectType, string name, string? language = null, string? customArgs = null)
{
string projectDirectory = GetProjectDirectory(name);
string options = $"--name {name} --output {projectDirectory}";
if (language != null)
{
options += $" --language \"{language}\"";
}
if (string.IsNullOrEmpty(customArgs))
{
options += $" {customArgs}";
}
ExecuteCmd($"new {projectType} {options}");
return projectDirectory;
}
public void ExecutePublish(string projectName, DotNetTemplate template, bool? selfContained = null, string? rid = null, bool trimmed = false, bool readyToRun = false)
{
string options = string.Empty;
string binlogDifferentiator = string.Empty;
if (selfContained.HasValue)
{
options += $"--self-contained {selfContained.Value.ToString().ToLowerInvariant()}";
if (selfContained.Value)
{
binlogDifferentiator += "self-contained";
if (!string.IsNullOrEmpty(rid))
{
options += $" -r {rid}";
binlogDifferentiator += $"-{rid}";
}
if (trimmed)
{
options += " /p:PublishTrimmed=true";
binlogDifferentiator += "-trimmed";
}
if (readyToRun)
{
options += " /p:PublishReadyToRun=true";
binlogDifferentiator += "-R2R";
}
}
}
string projDir = GetProjectDirectory(projectName);
string publishDir = Path.Combine(projDir, "bin", "publish");
ExecuteCmd(
$"publish {options} {GetBinLogOption(projectName, "publish", binlogDifferentiator)} -o {publishDir}",
projDir);
if (template == DotNetTemplate.Console)
{
ExecuteCmd($"{projectName}.dll", publishDir, expectedExitCode: 0);
}
else if (template == DotNetTemplate.ClassLib || template == DotNetTemplate.BlazorWasm)
{
// Can't run the published output of classlib (no entrypoint) or WASM (needs a server)
}
// Assume it is a web-based template
else
{
ExecuteWebDll(projectName, publishDir, template);
}
}
public void ExecuteRun(string projectName) =>
ExecuteCmd($"run {GetBinLogOption(projectName, "run")}", GetProjectDirectory(projectName));
public void ExecuteRunWeb(string projectName, DotNetTemplate template)
{
// 'dotnet run' exit code differs between CoreCLR and Mono (https://github.com/dotnet/sdk/issues/30095).
int expectedExitCode = IsMonoRuntime ? 143 : 0;
ExecuteWeb(
projectName,
$"run --no-launch-profile {GetBinLogOption(projectName, "run")}",
GetProjectDirectory(projectName),
template,
expectedExitCode);
}
public void ExecuteWebDll(string projectName, string workingDirectory, DotNetTemplate template) =>
ExecuteWeb(projectName, $"{projectName}.dll", workingDirectory, template, expectedExitCode: 0);
public void ExecuteTest(string projectName) =>
ExecuteCmd($"test {GetBinLogOption(projectName, "test")}", GetProjectDirectory(projectName));
private void ExecuteWeb(string projectName, string args, string workingDirectory, DotNetTemplate template, int expectedExitCode)
{
WebAppValidator validator = new(OutputHelper, template);
ExecuteCmd(
args,
workingDirectory,
processConfigCallback: validator.Validate,
expectedExitCode: expectedExitCode,
millisecondTimeout: 30000);
Assert.True(validator.IsValidated);
if (validator.ValidationException is not null)
{
throw validator.ValidationException;
}
}
private static string GetBinLogOption(string projectName, string command, string? differentiator = null)
{
string fileName = $"{projectName}-{command}";
if (!string.IsNullOrEmpty(differentiator))
{
fileName += $"-{differentiator}";
}
return $"/bl:{Path.Combine(TestBase.LogsDirectory, $"{fileName}.binlog")}";
}
private static bool DetermineIsMonoRuntime(string dotnetRoot)
{
string sharedFrameworkRoot = Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App");
if (!Directory.Exists(sharedFrameworkRoot))
{
return false;
}
string? version = Directory.GetDirectories(sharedFrameworkRoot).FirstOrDefault();
if (version is null)
{
return false;
}
string sharedFramework = Path.Combine(sharedFrameworkRoot, version);
// Check the presence of one of the mono header files.
return File.Exists(Path.Combine(sharedFramework, "mono-gc.h"));
}
private static string GetProjectDirectory(string projectName) => Path.Combine(ProjectsDirectory, projectName);
public static bool ShouldPublishComplex() =>
!string.Equals(Config.TargetArchitecture,"ppc64le") && !string.Equals(Config.TargetArchitecture,"s390x");
private class WebAppValidator
{
private readonly ITestOutputHelper _outputHelper;
private readonly DotNetTemplate _template;
public WebAppValidator(ITestOutputHelper outputHelper, DotNetTemplate template)
{
_outputHelper = outputHelper;
_template = template;
}
public bool IsValidated { get; set; }
public Exception? ValidationException { get; set; }
private static int GetAvailablePort()
{
TcpListener listener = new(IPAddress.Loopback, 0);
listener.Start();
int port = ((IPEndPoint)listener.LocalEndpoint).Port;
listener.Stop();
return port;
}
public void Validate(Process process)
{
int port = GetAvailablePort();
process.StartInfo.EnvironmentVariables.Add("ASPNETCORE_HTTP_PORTS", port.ToString());
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
try
{
if (e.Data?.Contains("Application started. Press Ctrl+C to shut down.") ?? false)
{
_outputHelper.WriteLine("Detected app has started. Sending web request to validate...");
using HttpClient httpClient = new();
string url = $"http://localhost:{port}";
if (_template == DotNetTemplate.WebApi)
{
url += "/WeatherForecast";
}
using HttpResponseMessage resultMsg = httpClient.GetAsync(new Uri(url)).Result;
_outputHelper.WriteLine($"Status code returned: {resultMsg.StatusCode}");
resultMsg.EnsureSuccessStatusCode();
IsValidated = true;
ExecuteHelper.ExecuteProcessValidateExitCode("kill", $"-s TERM {process.Id}", _outputHelper);
}
}
catch (Exception ex)
{
ValidationException = ex;
}
});
}
}
}

View file

@ -1,21 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
public enum DotNetTemplate
{
Console,
ClassLib,
XUnit,
NUnit,
MSTest,
Web,
Mvc,
Razor,
BlazorWasm,
WebApi,
WebApp,
Worker,
}

View file

@ -12,7 +12,15 @@ using Microsoft.DotNet.SourceBuild.SmokeTests;
public class Exclusions
{
string _rid = Config.TargetRid;
public const string UbPrefix = "ub";
public const string MsftPrefix = "msft";
public Exclusions(string rid)
{
_rid = rid;
}
string _rid;
string[] GetRidSpecificExclusionFileNames(string path)
{
@ -30,17 +38,42 @@ public class Exclusions
return fileNames;
}
public IEnumerable<string> RemoveContentDiffFileExclusions(IEnumerable<string> files, string? prefix = null)
{
var exclusions = GetFileExclusions(prefix);
Func<string, bool> condition = f => !IsFileExcluded(f, exclusions, prefix);
return files.Where(condition);
}
public IEnumerable<string> RemoveAssemblyVersionFileExclusions(IEnumerable<string> files, string? prefix = null)
{
var exclusions = GetFileExclusions(prefix).Concat(GetNativeDllExclusions(prefix)).Concat(GetAssemblyVersionExclusions(prefix));
Func<string, bool> condition = f => !IsFileExcluded(f, exclusions, prefix);
return files.Where(condition);
}
//public List<string> UbFileExclusions => _ubFileExclusions ??= GetFileExclusions(UbPrefix);
//List<string>? _ubFileExclusions = null;
//public List<string> UbAssemblyVersionExclusions => _ubAssemblyVersionExclusions ??= UbFileExclusions.Concat(GetAssemblyVersionExclusions(UbPrefix)).Concat(GetNativeDllExclusions(UbPrefix)).ToList();
//List<string>? _ubAssemblyVersionExclusions = null;
//public List<string> MsftFileExclusions => _msftFileExclusions ??= GetFileExclusions(MsftPrefix);
//List<string>? _msftFileExclusions = null;
//public List<string> MsftAssemblyVersionExclusions => _msftAssemblyVersionExclusions ??= MsftFileExclusions.Concat(GetAssemblyVersionExclusions(MsftPrefix)).Concat(GetNativeDllExclusions(MsftPrefix)).ToList();
//List<string>? _msftAssemblyVersionExclusions = null;
public List<string> GetFileExclusions(string? prefix = null) => GetRidSpecificExclusionFileNames("SdkFileDiffExclusions.txt").SelectMany(f => Utilities.TryParseExclusionsFile(f, prefix)).ToList();
public List<string> GetAssemblyVersionExclusions(string? prefix = null) => GetRidSpecificExclusionFileNames("SdkAssemblyVersionDiffExclusions.txt").SelectMany(f => Utilities.TryParseExclusionsFile(f, prefix)).ToList();
public List<string> GetNativeDllExclusions(string? prefix = null) => GetRidSpecificExclusionFileNames("NativeDlls.txt").SelectMany(f => Utilities.TryParseExclusionsFile(f, prefix)).ToList();
public string GetBaselineFileDiffFileName() => GetRidSpecificExclusionFileNames("MsftToSbSdkFiles.diff").Last();
string NormalizePath(string path)
static string NormalizePath(string path)
{
return path.Replace('\\', '/');
}
bool IsFileExcluded(string file, string? prefix = null)
=> GetFileExclusions(prefix).Any(exclusion => FileSystemName.MatchesSimpleExpression(exclusion, NormalizePath(file)));
public bool IsFileExcluded(string file, IEnumerable<string> exclusions, string? prefix = null)
=> exclusions.Any(exclusion => FileSystemName.MatchesSimpleExpression(exclusion, NormalizePath(file)));
}

View file

@ -19,12 +19,13 @@ using Xunit.Abstractions;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
[Trait("Category", "SdkContent")]
public class SdkContentTests : SdkTests
public class SdkContentTests : TestBase
{
private const string MsftSdkType = "msft";
private const string SourceBuildSdkType = "sb";
public SdkContentTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
Exclusions Exclusions;
public SdkContentTests(ITestOutputHelper outputHelper, Config config) : base(outputHelper, config)
{
Exclusions = new(Config.TargetRid);
}
/// <Summary>
/// Verifies the file layout of the source built sdk tarball to the Microsoft build.
@ -33,39 +34,39 @@ public class SdkContentTests : SdkTests
/// This makes the baseline durable between releases. This does mean however, entries
/// in the baseline may appear identical if the diff is version specific.
/// </Summary>
[SkippableFact(new[] { Config.MsftSdkTarballPathEnv, Config.SdkTarballPathEnv }, skipOnNullOrWhiteSpaceEnv: true)]
[Fact]
public void CompareMsftToSbFileList()
{
const string msftFileListingFileName = "msftSdkFiles.txt";
const string sbFileListingFileName = "sbSdkFiles.txt";
WriteTarballFileList(Config.MsftSdkTarballPath, msftFileListingFileName, isPortable: true, MsftSdkType);
WriteTarballFileList(Config.SdkTarballPath, sbFileListingFileName, isPortable: true, SourceBuildSdkType);
WriteTarballFileList(Config.MsftSdkArchivePath, msftFileListingFileName, isPortable: true, Exclusions.MsftPrefix);
WriteTarballFileList(Config.UbSdkArchivePath, sbFileListingFileName, isPortable: true, Exclusions.UbPrefix);
string diff = BaselineHelper.DiffFiles(msftFileListingFileName, sbFileListingFileName, OutputHelper);
diff = RemoveDiffMarkers(diff);
BaselineHelper.CompareBaselineContents(new Exclusions().GetBaselineFileDiffFileName(), diff, OutputHelper, Config.WarnOnSdkContentDiffs);
BaselineHelper.CompareBaselineContents(Exclusions.GetBaselineFileDiffFileName(), diff, OutputHelper, Config.WarnOnSdkContentDiffs);
}
[SkippableFact(new[] { Config.MsftSdkTarballPathEnv, Config.SdkTarballPathEnv }, skipOnNullOrWhiteSpaceEnv: true)]
public void CompareMsftToSbAssemblyVersions()
[Fact]
public async Task CompareMsftToSbAssemblyVersions()
{
Assert.NotNull(Config.MsftSdkTarballPath);
Assert.NotNull(Config.SdkTarballPath);
Assert.NotNull(Config.MsftSdkArchivePath);
Assert.NotNull(Config.UbSdkArchivePath);
DirectoryInfo tempDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
try
{
DirectoryInfo sbSdkDir = Directory.CreateDirectory(Path.Combine(tempDir.FullName, SourceBuildSdkType));
Utilities.ExtractTarball(Config.SdkTarballPath, sbSdkDir.FullName, OutputHelper);
DirectoryInfo sbSdkDir = Directory.CreateDirectory(Path.Combine(tempDir.FullName, Exclusions.UbPrefix));
Utilities.ExtractTarball(Config.UbSdkArchivePath, sbSdkDir.FullName, OutputHelper);
DirectoryInfo msftSdkDir = Directory.CreateDirectory(Path.Combine(tempDir.FullName, MsftSdkType));
Utilities.ExtractTarball(Config.MsftSdkTarballPath, msftSdkDir.FullName, OutputHelper);
DirectoryInfo msftSdkDir = Directory.CreateDirectory(Path.Combine(tempDir.FullName, Exclusions.MsftPrefix));
Utilities.ExtractTarball(Config.MsftSdkArchivePath, msftSdkDir.FullName, OutputHelper);
var t1 = Task.Run(() => GetSdkAssemblyVersions(sbSdkDir.FullName));
var t2 = Task.Run(() => GetSdkAssemblyVersions(msftSdkDir.FullName));
Task.WaitAll(t1, t2);
Dictionary<string, Version?> sbSdkAssemblyVersions = t1.Result;
Dictionary<string, Version?> msftSdkAssemblyVersions = t2.Result;
var results = await Task.WhenAll(t1, t2);
Dictionary<string, Version?> sbSdkAssemblyVersions = results[0];
Dictionary<string, Version?> msftSdkAssemblyVersions = results[1];
RemoveExcludedAssemblyVersionPaths(sbSdkAssemblyVersions, msftSdkAssemblyVersions);
@ -85,22 +86,22 @@ public class SdkContentTests : SdkTests
}
}
private static void RemoveExcludedAssemblyVersionPaths(Dictionary<string, Version?> sbSdkAssemblyVersions, Dictionary<string, Version?> msftSdkAssemblyVersions)
private void RemoveExcludedAssemblyVersionPaths(Dictionary<string, Version?> sbSdkAssemblyVersions, Dictionary<string, Version?> msftSdkAssemblyVersions)
{
IEnumerable<string> assemblyVersionDiffFilters = GetSdkAssemblyVersionDiffExclusionFilters()
IEnumerable<string> assemblyVersionDiffFilters = Exclusions.GetAssemblyVersionExclusions()
.Select(filter => filter.TrimStart("./".ToCharArray()));
// Remove entries that are not in both. If they should be in both, the mismatch will be caught in another test
foreach(var kvp in sbSdkAssemblyVersions)
foreach (var kvp in sbSdkAssemblyVersions)
{
if (msftSdkAssemblyVersions.ContainsKey(kvp.Key))
if (!msftSdkAssemblyVersions.ContainsKey(kvp.Key))
{
sbSdkAssemblyVersions.Remove(kvp.Key);
}
}
foreach(var kvp in msftSdkAssemblyVersions)
foreach (var kvp in msftSdkAssemblyVersions)
{
if (sbSdkAssemblyVersions.ContainsKey(kvp.Key))
if (!sbSdkAssemblyVersions.ContainsKey(kvp.Key))
{
msftSdkAssemblyVersions.Remove(kvp.Key);
}
@ -145,27 +146,13 @@ public class SdkContentTests : SdkTests
return null;
}
private string FindMatchingFilePath(string rootDir, Matcher matcher, string representativeFile)
private Dictionary<string, Version?> GetSdkAssemblyVersions(string sbSdkPath, string? prefix = null)
{
foreach (string file in Directory.EnumerateFiles(rootDir, "*", SearchOption.AllDirectories))
{
if (matcher.Match(rootDir, file).HasMatches)
{
return file;
}
}
Assert.Fail($"Unable to find matching file for '{representativeFile}' in '{rootDir}'.");
return string.Empty;
}
private Dictionary<string, Version?> GetSdkAssemblyVersions(string sbSdkPath)
{
Exclusions ex = new Exclusions();
IEnumerable<string> exclusionFilters = GetSdkDiffExclusionFilters(SourceBuildSdkType)
.Concat(GetKnownNativeFiles())
Exclusions ex = Exclusions;
IEnumerable<string> exclusionFilters = ex.GetFileExclusions(prefix)
.Concat(ex.GetNativeDllExclusions(prefix))
.Concat(ex.GetAssemblyVersionExclusions(prefix))
.Select(filter => filter.TrimStart("./".ToCharArray()));
List<string> knownNativeFiles = Utilities.ParseExclusionsFile("NativeDlls-win-any.txt").ToList();
ConcurrentDictionary<string, Version?> sbSdkAssemblyVersions = new();
List<Task> tasks = new List<Task>();
foreach (string dir in Directory.EnumerateDirectories(sbSdkPath, "*", SearchOption.AllDirectories).Append(sbSdkPath))
@ -180,7 +167,7 @@ public class SdkContentTests : SdkTests
{
string relativePath = Path.GetRelativePath(sbSdkPath, file);
string normalizedPath = BaselineHelper.RemoveVersions(relativePath);
if (!Utilities.IsFileExcluded(normalizedPath, exclusionFilters))
if (!ex.IsFileExcluded(normalizedPath, exclusionFilters))
{
try
{
@ -197,32 +184,6 @@ public class SdkContentTests : SdkTests
});
tasks.Add(t);
}
//foreach (string file in Directory.EnumerateFiles(sbSdkPath, "*", SearchOption.AllDirectories))
//{
// string fileExt = Path.GetExtension(file);
// if (fileExt.Equals(".dll", StringComparison.OrdinalIgnoreCase) ||
// fileExt.Equals(".exe", StringComparison.OrdinalIgnoreCase))
// {
// string relativePath = Path.GetRelativePath(sbSdkPath, file);
// string normalizedPath = BaselineHelper.RemoveVersions(relativePath);
// if (!Utilities.IsFileExcluded(normalizedPath, exclusionFilters))
// {
// var t = Task.Run(() =>
// {
// try
// {
// AssemblyName assemblyName = AssemblyName.GetAssemblyName(file);
// sbSdkAssemblyVersions.Add(normalizedPath, GetVersion(assemblyName));
// }
// catch (BadImageFormatException)
// {
// Console.WriteLine($"BadImageFormatException: {file}");
// }
// });
// tasks.Add(t);
// }
// }
//}
Task.WaitAll(tasks.ToArray());
return sbSdkAssemblyVersions.ToDictionary();
}
@ -235,32 +196,20 @@ public class SdkContentTests : SdkTests
}
string fileListing = Utilities.GetTarballContentNames(tarballPath).Aggregate((a, b) => $"{a}{Environment.NewLine}{b}");
fileListing = BaselineHelper.RemoveRids(fileListing, isPortable);
fileListing = BaselineHelper.RemoveRids(fileListing, Config.PortableRidEnv, Config.TargetRid, isPortable);
fileListing = BaselineHelper.RemoveVersions(fileListing);
IEnumerable<string> files = fileListing.Split(Environment.NewLine).OrderBy(path => path);
files = RemoveExclusions(files, GetSdkDiffExclusionFilters(sdkType));
files = Exclusions.RemoveContentDiffFileExclusions(files, sdkType);
File.WriteAllLines(outputFileName, files);
}
private static IEnumerable<string> RemoveExclusions(IEnumerable<string> files, IEnumerable<string> exclusions) =>
files.Where(item => !Utilities.IsFileExcluded(item, exclusions));
private static IEnumerable<string> GetSdkDiffExclusionFilters(string sdkType) =>
Utilities.ParseExclusionsFile("SdkFileDiffExclusions.txt", sdkType);
private static IEnumerable<string> GetSdkAssemblyVersionDiffExclusionFilters() =>
Utilities.ParseExclusionsFile("SdkAssemblyVersionDiffExclusions.txt");
private static IEnumerable<string> GetKnownNativeFiles() =>
Utilities.ParseExclusionsFile("NativeDlls-win-any.txt");
private static string RemoveDiffMarkers(string source)
{
Regex indexRegex = new("^index .*", RegexOptions.Multiline);
string result = indexRegex.Replace(source, "index ------------");
Regex diffSegmentRegex = new("^@@ .* @@", RegexOptions.Multiline);
return diffSegmentRegex.Replace(result, "@@ ------------ @@");
return diffSegmentRegex.Replace(result, "@@ ------------ @@").ReplaceLineEndings();
}
}

View file

@ -1,20 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit.Abstractions;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
/// <summary>
/// Shared base class for all SDK-based smoke tests.
/// </summary>
public abstract class SdkTests : TestBase
{
internal DotNetHelper DotNetHelper { get; }
protected SdkTests(ITestOutputHelper outputHelper) : base(outputHelper)
{
DotNetHelper = new DotNetHelper(outputHelper);
}
}

View file

@ -1,53 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Linq;
using Xunit;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
/// <summary>
/// A Fact that will be skipped based on the specified environment variable's value.
/// </summary>
internal class SkippableFactAttribute : FactAttribute
{
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpaceEnv = false, bool skipOnTrueEnv = false, bool skipOnFalseEnv = false, string[] skipArchitectures = null) =>
EvaluateSkips(skipOnNullOrWhiteSpaceEnv, skipOnTrueEnv, skipOnFalseEnv, skipArchitectures, (skip) => Skip = skip, envName);
public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpaceEnv = false, bool skipOnTrueEnv = false, bool skipOnFalseEnv = false, string[] skipArchitectures = null) =>
EvaluateSkips(skipOnNullOrWhiteSpaceEnv, skipOnTrueEnv, skipOnFalseEnv, skipArchitectures, (skip) => Skip = skip, envNames);
public static void EvaluateSkips(bool skipOnNullOrWhiteSpaceEnv, bool skipOnTrueEnv, bool skipOnFalseEnv, string[] skipArchitectures, Action<string> setSkip, params string[] envNames)
{
foreach (string envName in envNames)
{
string? envValue = Environment.GetEnvironmentVariable(envName);
if (skipOnNullOrWhiteSpaceEnv && string.IsNullOrWhiteSpace(envValue))
{
setSkip($"Skipping because `{envName}` is null or whitespace");
break;
}
else if (skipOnTrueEnv && bool.TryParse(envValue, out bool boolValue) && boolValue)
{
setSkip($"Skipping because `{envName}` is set to True");
break;
}
else if (skipOnFalseEnv && (!bool.TryParse(envValue, out boolValue) || !boolValue))
{
setSkip($"Skipping because `{envName}` is set to False or an invalid value");
break;
}
}
if (skipArchitectures != null) {
string? arch = Config.TargetArchitecture;
if (skipArchitectures.Contains(arch))
{
setSkip($"Skipping because arch is `{arch}`");
}
}
}
}

View file

@ -3,20 +3,22 @@
// See the LICENSE file in the project root for more information.
using System.IO;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
public abstract class TestBase
public abstract class TestBase : IClassFixture<Config>
{
protected Config Config;
public static string LogsDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), "logs");
public ITestOutputHelper OutputHelper { get; }
public TestBase(ITestOutputHelper outputHelper)
public TestBase(ITestOutputHelper outputHelper, Config config)
{
OutputHelper = outputHelper;
Config = config;
if (!Directory.Exists(LogsDirectory))
{
Directory.CreateDirectory(LogsDirectory);

View file

@ -75,7 +75,7 @@ public static class Utilities
{
// TarFile doesn't properly handle hard links (https://github.com/dotnet/runtime/pull/85378#discussion_r1221817490),
// use 'tar' instead.
if (tarballPath.EndsWith(".tar.gz", StringComparison.OrdinalIgnoreCase) || tarballPath.EndsWith(".tgz", StringComparison.OrdinalIgnoreCase))
if (tarballPath.EndsWith(".tar.gz", StringComparison.InvariantCultureIgnoreCase) || tarballPath.EndsWith(".tgz", StringComparison.InvariantCultureIgnoreCase))
{
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {tarballPath} -C {outputDir}", outputHelper);
}
@ -85,7 +85,7 @@ public static class Utilities
}
else
{
throw new InvalidOperationException($"Unsupported tarball format: {tarballPath}");
throw new InvalidOperationException($"Unsupported archive format: {tarballPath}");
}
}
@ -98,16 +98,16 @@ public static class Utilities
using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
using TarReader reader = new(decompressorStream);
TarEntry entry;
TarEntry? entry;
while ((entry = reader.GetNextEntry()) is not null)
{
if (matcher.Match(entry.Name).HasMatches)
{
string outputPath = Path.Join(outputDir, entry.Name);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
Directory.CreateDirectory(Path.GetDirectoryName(outputPath)!);
using FileStream outputFileStream = File.Create(outputPath);
entry.DataStream.CopyTo(outputFileStream);
entry.DataStream!.CopyTo(outputFileStream);
break;
}
}
@ -130,12 +130,16 @@ public static class Utilities
using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
using TarReader reader = new(decompressorStream);
TarEntry entry;
TarEntry? entry;
while ((entry = reader.GetNextEntry()) is not null)
{
yield return entry.Name;
}
}
else
{
throw new InvalidOperationException($"Unsupported archive format: {tarballPath}");
}
}
public static void ExtractNupkg(string package, string outputDir)
@ -146,7 +150,7 @@ public static class Utilities
foreach (ZipArchiveEntry entry in zip.Entries)
{
string outputPath = Path.Combine(outputDir, entry.FullName);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
Directory.CreateDirectory(Path.GetDirectoryName(outputPath)!);
entry.ExtractToFile(outputPath);
}
}

View file

@ -1,4 +1,4 @@
# Contains the list of files which are .dll's or .exe's but are not managed assemblies and should not have their assembly version checked
# Contains the list of native .dll and .exe files that shouldn't have their assembly version checked.
#
# This list is processed using FileSystemName.MatchesSimpleExpression
#
@ -46,4 +46,4 @@
./packs/Microsoft.NETCore.App.Host.win-x86/x.y.z/runtimes/win-x86/native/singlefilehost.exe
./packs/Microsoft.NETCore.App.Host.win-arm64/x.y.z/runtimes/win-arm64/native/singlefilehost.exe
./shared/Microsoft.NETCore.App/x.y.z/System.IO.Compression.Native.dll
./dotnet.exe
./dotnet.exe

View file

@ -1,7 +1,4 @@
# Contains the list of files whose assembly versions are to be excluded from comparison between the MSFT & SB SDK.
# These exclusions only take effect if the assembly version of the file in the SB SDK is equal to or greater than
# the version in the MSFT SDK. If the version is less, the file will show up in the results as this is not a scenario
# that is valid for shipping.
# Contains the list of native .dll and .exe files that shouldn't have their assembly version checked.
#
# This list is processed using FileSystemName.MatchesSimpleExpression
#
@ -11,4 +8,4 @@
#
# We do not want to filter-out folder entries, therefore, we should use: '?*' and not just '*'
./shared/Microsoft.NETCore.App/x.y.z/mscordaccore_amd64_amd64_x.y.z.dll
./shared/Microsoft.NETCore.App/x.y.z/mscordaccore_amd64_amd64_x.y.z.dll

View file

@ -1,7 +1,4 @@
# Contains the list of files whose assembly versions are to be excluded from comparison between the MSFT & SB SDK.
# These exclusions only take effect if the assembly version of the file in the SB SDK is equal to or greater than
# the version in the MSFT SDK. If the version is less, the file will show up in the results as this is not a scenario
# that is valid for shipping.
# Contains the list of native .dll and .exe files that shouldn't have their assembly version checked.
#
# This list is processed using FileSystemName.MatchesSimpleExpression
#

View file

@ -1,24 +0,0 @@
# This list is processed using FileSystemName.MatchesSimpleExpression
#
# Format
# {msft|sb},<path> [# comment]
# msft = Microsoft built SDK
# sb = source-built SDK
#
# Examples
# 'folder/*' matches 'folder/' and 'folder/abc'
# 'folder/?*' matches 'folder/abc' but not 'folder/'
msft,./sdk/x.y.z/TestHostNetFramework/x64/msdia140.dll
msft,./sdk/x.y.z/TestHostNetFramework/x86/msdia140.dll
msft,./sdk/x.y.z/datacollector.dll
sb,./sdk/x.y.z/TestHostNetFramework/x64/msdia140.dll
sb,./sdk/x.y.z/TestHostNetFramework/x86/msdia140.dll
sb,./sdk/x.y.z/datacollector.dll
msft,./sdk/x.y.z/Containers/containerize/*
sb,./sdk/x.y.z/Containers/containerize/*
msft,./sdk/x.y.z/Containers/tasks/net472/*
sb,./sdk/x.y.z/Containers/tasks/net472/*

View file

@ -3,41 +3,10 @@ index ------------
--- a/msftSdkFiles.txt
+++ b/sbSdkFiles.txt
@@ ------------ @@
./packs/Microsoft.AspNetCore.App.Ref/x.y.z/ref\netx.y\System.Security.Cryptography.Xml.xml
./packs/Microsoft.AspNetCore.App.Ref/x.y.z/ref\netx.y\System.Threading.RateLimiting.dll
./packs/Microsoft.AspNetCore.App.Ref/x.y.z/ref\netx.y\System.Threading.RateLimiting.xml
-./packs/Microsoft.NETCore.App.Host.linux-x64/
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/apphost
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/coreclr_delegates.h
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/hostfxr.h
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/libnethost.a
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/libnethost.so
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/nethost.h
-./packs/Microsoft.NETCore.App.Host.linux-x64/x.y.z/runtimes/linux-x64/native/singlefilehost
+./packs/Microsoft.NETCore.App.Host.banana-rid/
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/apphost
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/coreclr_delegates.h
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/hostfxr.h
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/libnethost.a
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/libnethost.so
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/nethost.h
+./packs/Microsoft.NETCore.App.Host.banana-rid/x.y.z/runtimes/banana-rid/native/singlefilehost
./packs/Microsoft.NETCore.App.Ref/
./packs/Microsoft.NETCore.App.Ref/x.y.z/
./packs/Microsoft.NETCore.App.Ref/x.y.z/analyzers/
@@ ------------ @@
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/runtimes/win/lib/
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/runtimes/win/lib\netx.y\
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/runtimes/win/lib\netx.y\System.Diagnostics.EventLog.dll
-./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/runtimes/win/lib\netx.y\System.Diagnostics.EventLog.Messages.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/runtimes/win/lib\netx.y\System.Security.Cryptography.Pkcs.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/runtimes/win/lib\netx.y\System.Windows.Extensions.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools\netx.y\any/System.CodeDom.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/runtimes/win/lib/
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/runtimes/win/lib/netx.y/
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/runtimes/win/lib/netx.y/System.Diagnostics.EventLog.dll
+./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/runtimes/win/lib/netx.y/System.Diagnostics.EventLog.Messages.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/runtimes/win/lib/netx.y/System.Security.Cryptography.Pkcs.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/runtimes/win/lib/netx.y/System.Windows.Extensions.dll
./sdk/x.y.z/DotnetTools/dotnet-watch/x.y.z/tools/netx.y/any/System.CodeDom.dll