Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f9d957f
Eliminate redundant existence checks in workload resolver
mhutch Jun 3, 2021
b8ade8e
Implement workload redirects
mhutch Jun 9, 2021
a22e8d0
Fix 'avaliable' typo
mhutch Jun 9, 2021
e7a3eb2
Allow deferred opening of workload manifest stream
mhutch Jun 9, 2021
cf013d2
Add workload resolver method to determine updated workloads
mhutch Jun 9, 2021
3374ec9
Replace workload TempDirResolver with more generic OverlayResolver
mhutch Jun 10, 2021
0a8238c
Improve diagnosability of manifest conflicts
mhutch Jun 10, 2021
accd669
Improve workload composition errors
mhutch Jun 22, 2021
ed81dd4
Nullability checks in workload manifest reader tests
mhutch Jun 22, 2021
3d64056
Stronger typing of workload/pack ids in public API
mhutch Jun 22, 2021
a6cd134
Disable workload redirects for now
mhutch Jul 1, 2021
0254d95
Improve WorkloadResolver.GetPacksInWorkload
mhutch Jul 2, 2021
15d527f
Fix available workloads returned by resolver
mhutch Jul 2, 2021
619304d
Include workload ID in exception when resolver cannot find it
mhutch Jul 2, 2021
d867fef
Hide WorkloadResolver.GetPackPath in favor of ResolvePackPath
mhutch Jul 2, 2021
536f67c
When suggesting workloads, only consider available workloads
mhutch Jul 2, 2021
e4b36e3
Localize remaining workload composition errors
mhutch Jul 13, 2021
d75137c
Simplify WorkloadResolver.GetInstalledManifests
mhutch Jul 14, 2021
c9d64aa
Fix ResolvePackPath returning empty workload pack ids
mhutch Jul 15, 2021
48720b8
Check updated composition error messages in workload tests
mhutch Jul 15, 2021
0537ca7
Don't assume missing workload packs can always be satisfied
mhutch Jul 17, 2021
f4ed4c7
Fix accidental removal that broke workload search tests
mhutch Jul 19, 2021
b736168
Fix error message argument indices
dsplaisted Jul 18, 2021
4d4f3ef
Fix workload mocks to use correct manifest IDs
dsplaisted Jul 18, 2021
9f15943
Update test now that mock workload manifest has right ID
dsplaisted Jul 19, 2021
88fc6b4
Generate correct error message when trying to install a workload whic…
dsplaisted Jul 19, 2021
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
5 changes: 4 additions & 1 deletion src/Cli/dotnet/Installer/Windows/WorkloadPackRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#nullable disable

using System;

using Microsoft.NET.Sdk.WorkloadManifestReader;

using NuGet.Versioning;

namespace Microsoft.DotNet.Installer.Windows
Expand All @@ -25,7 +28,7 @@ public string ProviderKeyName
/// <summary>
/// The ID of the workload pack.
/// </summary>
public string PackId
public WorkloadPackId PackId
{
get;
set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<data name="BundleUpToDateMessage" xml:space="preserve">
<value>Up to date.</value>
</data>
<data name="NewPatchAvaliableMessage" xml:space="preserve">
<data name="NewPatchAvailableMessage" xml:space="preserve">
<value>Patch {0} is available.</value>
</data>
<data name="OutOfSupportMessage" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private string GetRuntimeStatusMessage(NetRuntimeInfo runtime)
}
else if (NewerRuntimePatchExists(runtime))
{
return string.Format(LocalizableStrings.NewPatchAvaliableMessage, NewestRuntimePatchVersion(runtime));
return string.Format(LocalizableStrings.NewPatchAvailableMessage, NewestRuntimePatchVersion(runtime));
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions src/Cli/dotnet/commands/dotnet-sdk/check/SdkOutputWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public void PrintSdkInfo()

table.PrintRows(_sdkInfo.OrderBy(sdk => sdk.Version), l => _reporter.WriteLine(l));

if (NewFeatureBandAvaliable())
if (NewFeatureBandAvailable())
{
_reporter.WriteLine();
_reporter.WriteLine(string.Format(LocalizableStrings.NewFeatureBandMessage, NewestFeatureBandAvaliable()));
_reporter.WriteLine(string.Format(LocalizableStrings.NewFeatureBandMessage, NewestFeatureBandAvailable()));
}
}

Expand All @@ -52,7 +52,7 @@ private string GetSdkStatusMessage(NetSdkInfo sdk)
}
else if (NewerSdkPatchExists(sdk))
{
return string.Format(LocalizableStrings.NewPatchAvaliableMessage, NewestSdkPatchVersion(sdk));
return string.Format(LocalizableStrings.NewPatchAvailableMessage, NewestSdkPatchVersion(sdk));
}
else
{
Expand Down Expand Up @@ -86,12 +86,12 @@ private ReleaseVersion NewestSdkPatchVersion(NetSdkInfo bundle)
}
}

private bool NewFeatureBandAvaliable()
private bool NewFeatureBandAvailable()
{
return NewestFeatureBandAvaliable() > _sdkInfo.Select(sdk => sdk.Version).Max();
return NewestFeatureBandAvailable() > _sdkInfo.Select(sdk => sdk.Version).Max();
}

private ReleaseVersion NewestFeatureBandAvaliable()
private ReleaseVersion NewestFeatureBandAvailable()
{
return _productCollection.OrderByDescending(product => product.ProductVersion).First().LatestSdkVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<target state="new">Try out the newest .NET SDK features with .NET {0}.</target>
<note />
</trans-unit>
<trans-unit id="NewPatchAvaliableMessage">
<trans-unit id="NewPatchAvailableMessage">
<source>Patch {0} is available.</source>
<target state="new">Patch {0} is available.</target>
<note />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.DotNet.Workloads.Workload.Install.InstallRecord;
using Microsoft.Extensions.EnvironmentAbstractions;
using System.Collections.Generic;
using Microsoft.NET.Sdk.WorkloadManifestReader;

namespace Microsoft.DotNet.Workloads.Workload.Install
{
Expand All @@ -20,6 +21,6 @@ internal interface IWorkloadPackInstaller : IInstaller

void GarbageCollectInstalledWorkloadPacks();

IEnumerable<(string Id, string Version)> GetInstalledPacks(SdkFeatureBand sdkFeatureBand);
IEnumerable<(WorkloadPackId Id, string Version)> GetInstalledPacks(SdkFeatureBand sdkFeatureBand);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private IReadOnlyDictionary<string, List<WorkloadPackRecord>> GetWorkloadPackRec
WorkloadPackRecord record = new WorkloadPackRecord
{
ProviderKeyName = (string)packVersionKey.GetValue("DependencyProviderKey"),
PackId = packId,
PackId = new NET.Sdk.WorkloadManifestReader.WorkloadPackId(packId),
PackVersion = new NuGetVersion(packVersion),
ProductCode = (string)packVersionKey.GetValue("ProductCode"),
ProductVersion = new Version((string)packVersionKey.GetValue("ProductVersion"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@ public void GarbageCollectInstalledWorkloadPacks()
}
}

public IEnumerable<(string, string)> GetInstalledPacks(SdkFeatureBand sdkFeatureBand)
public IEnumerable<(WorkloadPackId, string)> GetInstalledPacks(SdkFeatureBand sdkFeatureBand)
{
var installedPacksDir = Path.Combine(_workloadMetadataDir, _installedPacksDir, "v1");
if (!Directory.Exists(installedPacksDir))
{
return Enumerable.Empty<(string, string)>();
return Enumerable.Empty<(WorkloadPackId, string)>();
}
return Directory.GetDirectories(installedPacksDir)
.Where(packIdDir => HasFeatureBandMarkerFile(packIdDir, sdkFeatureBand))
.SelectMany(packIdPath => Directory.GetDirectories(packIdPath))
.Select(packVersionPath => (Path.GetFileName(Path.GetDirectoryName(packVersionPath)), Path.GetFileName(packVersionPath)));
.Select(packVersionPath => (new WorkloadPackId(Path.GetFileName(Path.GetDirectoryName(packVersionPath))), Path.GetFileName(packVersionPath)));
}

public void Shutdown()
Expand All @@ -376,7 +376,7 @@ private IEnumerable<string> GetExpectedPackInstallRecords(SdkFeatureBand sdkFeat
{
var installedWorkloads = _installationRecordRepository.GetInstalledWorkloads(sdkFeatureBand);
return installedWorkloads
.SelectMany(workload => _workloadResolver.GetPacksInWorkload(workload.ToString()))
.SelectMany(workload => _workloadResolver.GetPacksInWorkload(workload))
.Select(pack => _workloadResolver.TryGetPackInfo(pack))
.Where(pack => pack != null)
.Select(packInfo => GetPackInstallRecordPath(packInfo, sdkFeatureBand));
Expand All @@ -387,7 +387,7 @@ private PackInfo GetPackInfo(string packRecordDir)
// Expected path: <DOTNET ROOT>/metadata/workloads/installedpacks/v1/<Pack ID>/<Pack Version>/
var idRecordPath = Path.GetDirectoryName(packRecordDir);
var packId = Path.GetFileName(idRecordPath);
var packInfo = _workloadResolver.TryGetPackInfo(packId);
var packInfo = _workloadResolver.TryGetPackInfo(new WorkloadPackId(packId));
if (packInfo != null && packInfo.Version.Equals(Path.GetFileName(packRecordDir)))
{
return packInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ public void GarbageCollectInstalledWorkloadPacks()
IEnumerable<SdkFeatureBand> installedFeatureBands = GetInstalledFeatureBands();
IEnumerable<WorkloadId> installedWorkloads = RecordRepository.GetInstalledWorkloads(_sdkFeatureBand);
IEnumerable<PackInfo> expectedWorkloadPacks = installedWorkloads
.SelectMany(workload => _workloadResolver.GetPacksInWorkload(workload.ToString()))
.SelectMany(workload => _workloadResolver.GetPacksInWorkload(workload))
.Select(pack => _workloadResolver.TryGetPackInfo(pack))
.Where(pack => pack != null);
IEnumerable<string> expectedPackIds = expectedWorkloadPacks.Select(p => p.Id);
IEnumerable<WorkloadPackId> expectedPackIds = expectedWorkloadPacks.Select(p => p.Id);

foreach (PackInfo expectedPack in expectedWorkloadPacks)
{
Expand Down Expand Up @@ -219,7 +219,7 @@ public void GarbageCollectInstalledWorkloadPacks()

public InstallationUnit GetInstallationUnit() => InstallationUnit.Packs;

public IEnumerable<(string, string)> GetInstalledPacks(SdkFeatureBand sdkFeatureBand)
public IEnumerable<(WorkloadPackId, string)> GetInstalledPacks(SdkFeatureBand sdkFeatureBand)
{
string dependent = $"{DependentPrefix},{sdkFeatureBand},{HostArchitecture}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ internal class WorkloadInstallCommand : CommandBase
private readonly IReadOnlyCollection<string> _workloadIds;
private readonly IInstaller _workloadInstaller;
private IWorkloadResolver _workloadResolver;
private IWorkloadManifestProvider _workloadManifestProvider;
private readonly INuGetPackageDownloader _nugetPackageDownloader;
private readonly IWorkloadManifestUpdater _workloadManifestUpdater;
private readonly ReleaseVersion _sdkVersion;
Expand Down Expand Up @@ -80,8 +79,8 @@ public WorkloadInstallCommand(
_packageSourceLocation = string.IsNullOrEmpty(configOption) && (sourceOption == null || !sourceOption.Any()) ? null :
new PackageSourceLocation(string.IsNullOrEmpty(configOption) ? null : new FilePath(configOption), sourceFeedOverrides: sourceOption);

_workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString());
_workloadResolver = workloadResolver ?? WorkloadResolver.Create(_workloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
var _sdkWorkloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(_dotnetPath, _sdkVersion.ToString());
_workloadResolver = workloadResolver ?? WorkloadResolver.Create(_sdkWorkloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
var sdkFeatureBand = new SdkFeatureBand(_sdkVersion);
var tempPackagesDir = new DirectoryPath(Path.Combine(_tempDirPath, "dotnet-sdk-advertising-temp"));
var restoreActionConfig = _parseResult.ToRestoreActionConfig();
Expand All @@ -95,26 +94,26 @@ public WorkloadInstallCommand(
_workloadResolver, _verbosity, _nugetPackageDownloader, _dotnetPath, _tempDirPath,
_packageSourceLocation, restoreActionConfig, elevationRequired: !_printDownloadLinkOnly && string.IsNullOrWhiteSpace(_downloadToCacheOption));
_userHome = userHome ?? CliFolderPathCalculator.DotnetHomePath;
_workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(_reporter, _workloadManifestProvider, _workloadResolver, _nugetPackageDownloader, _userHome, _tempDirPath, _packageSourceLocation);
_workloadManifestUpdater = workloadManifestUpdater ?? new WorkloadManifestUpdater(_reporter, _sdkWorkloadManifestProvider, _workloadResolver, _nugetPackageDownloader, _userHome, _tempDirPath, _packageSourceLocation);

ValidateWorkloadIdsInput();
}

private void ValidateWorkloadIdsInput()
{
var avaliableWorkloads = _workloadResolver.GetAvaliableWorkloads();
var availableWorkloads = _workloadResolver.GetAvailableWorkloads();
foreach (var workloadId in _workloadIds)
{
if (avaliableWorkloads.Select(workload => workload.Id.ToString()).Contains(workloadId))
if (!availableWorkloads.Select(workload => workload.Id.ToString()).Contains(workloadId))
{
if (!_workloadResolver.IsWorkloadPlatformCompatible(new WorkloadId(workloadId)))
if (_workloadResolver.IsPlatformIncompatibleWorkload(new WorkloadId(workloadId)))
{
throw new GracefulException(string.Format(LocalizableStrings.WorkloadNotSupportedOnPlatform, workloadId));
}
}
else
{
throw new GracefulException(string.Format(LocalizableStrings.WorkloadNotRecognized, workloadId));
else
{
throw new GracefulException(string.Format(LocalizableStrings.WorkloadNotRecognized, workloadId));
}
}
}
}
Expand Down Expand Up @@ -318,8 +317,8 @@ private async Task UseTempManifestsToResolvePacksAsync(DirectoryPath tempPath, b
return;
}
await _workloadManifestUpdater.ExtractManifestPackagesToTempDirAsync(manifestPackagePaths, tempPath);
_workloadManifestProvider = new TempDirectoryWorkloadManifestProvider(tempPath.Value, _sdkVersion.ToString());
_workloadResolver = _workloadResolver.CreateTempDirResolver(_workloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
var overlayProvider = new TempDirectoryWorkloadManifestProvider(tempPath.Value, _sdkVersion.ToString());
_workloadResolver = _workloadResolver.CreateOverlayResolver(overlayProvider);
}

private async Task DownloadToOfflineCacheAsync(IEnumerable<WorkloadId> workloadIds, DirectoryPath offlineCache, bool skipManifestUpdate, bool includePreviews)
Expand All @@ -332,8 +331,8 @@ private async Task DownloadToOfflineCacheAsync(IEnumerable<WorkloadId> workloadI
{
tempManifestDir = Path.Combine(offlineCache.Value, "temp-manifests");
await _workloadManifestUpdater.ExtractManifestPackagesToTempDirAsync(manifestPackagePaths, new DirectoryPath(tempManifestDir));
_workloadManifestProvider = new TempDirectoryWorkloadManifestProvider(tempManifestDir, _sdkVersion.ToString());
_workloadResolver = _workloadResolver.CreateTempDirResolver(_workloadManifestProvider, _dotnetPath, _sdkVersion.ToString());
var overlayProvider = new TempDirectoryWorkloadManifestProvider(tempManifestDir, _sdkVersion.ToString());
_workloadResolver = _workloadResolver.CreateOverlayResolver(overlayProvider);
}
else
{
Expand Down Expand Up @@ -374,7 +373,7 @@ private IEnumerable<PackInfo> GetPacksToInstall(IEnumerable<WorkloadId> workload
{
var installedPacks = _workloadInstaller.GetPackInstaller().GetInstalledPacks(_sdkFeatureBand);
return workloadIds
.SelectMany(workloadId => _workloadResolver.GetPacksInWorkload(workloadId.ToString()))
.SelectMany(workloadId => _workloadResolver.GetPacksInWorkload(workloadId))
.Distinct()
.Select(packId => _workloadResolver.TryGetPackInfo(packId))
.Where(pack => pack != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, bool in
using (FileStream fsSource = new FileStream(manifestPath, FileMode.Open, FileAccess.Read))
{
var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestId.ToString(), fsSource);
return (new ManifestVersion(manifest.Version), manifest.Workloads);
return (new ManifestVersion(manifest.Version), manifest.Workloads.Values.OfType<WorkloadDefinition>().ToDictionary(w => w.Id));
}
}

Expand Down
Loading