Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified build assets filter #46831

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ public class JoinVerticals : Microsoft.Build.Utilities.Task
private const string _packagesFolderName = "packages";
private const int _retryCount = 10;

private readonly HashSet<string> _excludeAssets = new HashSet<string>(
[
"Microsoft.Diagnostics.NETCore.Client",
"Microsoft.NET.Sdk.Aspire.Manifest-8.0.100"
], StringComparer.OrdinalIgnoreCase);

public override bool Execute()
{
ExecuteAsync().GetAwaiter().GetResult();
Expand All @@ -92,7 +86,8 @@ private async Task ExecuteAsync()
string mainVerticalName = mainVerticalManifest.VerticalName!;

JoinVerticalsAssetSelector joinVerticalsAssetSelector = new JoinVerticalsAssetSelector();
List<AssetVerticalMatchResult> selectedVerticals = joinVerticalsAssetSelector.SelectAssetMatchingVertical(manifests, _excludeAssets).ToList();

List<AssetVerticalMatchResult> selectedVerticals = joinVerticalsAssetSelector.SelectAssetMatchingVertical(manifests).ToList();

var notMatchedAssets = selectedVerticals.Where(o => o.MatchType == AssetVerticalMatchType.NotSpecified).ToList();
Log.LogMessage(MessageImportance.High, $"### {notMatchedAssets.Count()} Assets not properly matched to vertical: ###");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,23 @@ public JoinVerticalsAssetSelector(JoinVerticalsConfig? config = null)
_config = config ?? JoinVerticalsConfig.GetDefaultConfig();
}

public IEnumerable<AssetVerticalMatchResult> SelectAssetMatchingVertical(IEnumerable<BuildAssetsManifest> verticalManifests, HashSet<string>? excludeAssetsByName = null)
// Temporary solution to exclude some assets from Unified Build
private bool ExcludeAsset(AssetVerticalMatchResult assetVerticalMatch)
{
return
// Skip packages with stable version
// - this can be removed after this issue is resolved: https://github.com/dotnet/source-build/issues/4892
StringComparer.OrdinalIgnoreCase.Equals(assetVerticalMatch.AssetId, "Microsoft.Diagnostics.NETCore.Client") ||
StringComparer.OrdinalIgnoreCase.Equals(assetVerticalMatch.AssetId, "Microsoft.NET.Sdk.Aspire.Manifest-8.0.100") ||
// Skip all Nuget packaged as they are missing UB version suffix +100 patch version
// - this can be removed after this issue is resolved: https://github.com/dotnet/source-build/issues/4894
StringComparer.OrdinalIgnoreCase.Equals(assetVerticalMatch.Asset.RepoOrigin, "nuget-client") ||
// Skip productVersion.txt files from all repos except sdk
// - this can be removed after this issue is resolved: https://github.com/dotnet/source-build/issues/4596
(assetVerticalMatch.AssetId.Contains("/productVersion.txt", StringComparison.OrdinalIgnoreCase) && (assetVerticalMatch.Asset.RepoOrigin != "sdk"));
}

public IEnumerable<AssetVerticalMatchResult> SelectAssetMatchingVertical(IEnumerable<BuildAssetsManifest> verticalManifests)
{
bool IsExternalAsset(ManifestAsset asset)
{
Expand All @@ -58,24 +74,25 @@ bool IsExternalAsset(ManifestAsset asset)
{
string assetId = assetGroup.Key;

if (excludeAssetsByName != null && excludeAssetsByName.Contains(assetId))
{
continue;
}

int verticalsCount = assetGroup.Count();
var verticalNames = assetGroup.Select(o => o.manifest.VerticalName!).ToList();
if (verticalsCount > 0)
{
(AssetVerticalMatchType matchType, string verticalName) = SelectVerticalForAsset(verticalNames);
yield return new AssetVerticalMatchResult

AssetVerticalMatchResult assetVerticalMatch = new AssetVerticalMatchResult
{
AssetId = assetGroup.Key,
MatchType = matchType,
VerticalName = verticalName,
Asset = assetGroup.FirstOrDefault(o => VerticalNameMatches(o.manifest.VerticalName, verticalName)).asset,
OtherVerticals = assetGroup.Select(o => o.manifest.VerticalName!).Where(o => !VerticalNameMatches(o, verticalName)).ToList()
};

if (!ExcludeAsset(assetVerticalMatch))
{
yield return assetVerticalMatch;
}
}
}
}
Expand Down
Loading