Skip to content

Commit acc14d3

Browse files
authored
Merge pull request #17455 from sfoslund/ManifestUpdates
Workload manifest updates PR feedback
2 parents a389127 + 9d03044 commit acc14d3

26 files changed

+164
-62
lines changed

src/Cli/dotnet/NugetPackageInstaller/NuGetPackageDownloader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ await GetPackageMetadataAsync(packageId.ToString(), packageVersion, packagesSour
7272

7373
if (resource == null)
7474
{
75-
throw new NuGetPackageInstallerException(
75+
throw new NuGetPackageNotFoundException(
7676
string.Format(LocalizableStrings.FailedToLoadNuGetSource, source.Source));
7777
}
7878

src/Cli/dotnet/NugetPackageInstaller/ToolPackageException.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,19 @@ public NuGetPackageInstallerException(string message, Exception innerException)
1919
{
2020
}
2121
}
22+
23+
internal class NuGetPackageNotFoundException : NuGetPackageInstallerException
24+
{
25+
public NuGetPackageNotFoundException()
26+
{
27+
}
28+
29+
public NuGetPackageNotFoundException(string message) : base(message)
30+
{
31+
}
32+
33+
public NuGetPackageNotFoundException(string message, Exception innerException) : base(message, innerException)
34+
{
35+
}
36+
}
2237
}

src/Cli/dotnet/commands/dotnet-workload/install/IWorkloadManifestUpdater.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
using System.Collections.Generic;
55
using System.Threading.Tasks;
6-
using Microsoft.DotNet.Workloads.Workload.Install.InstallRecord;
76

87
namespace Microsoft.DotNet.Workloads.Workload.Install
98
{
109
internal interface IWorkloadManifestUpdater
1110
{
12-
Task UpdateAdvertisingManifestsAsync(SdkFeatureBand featureBand, bool includePreviews);
11+
Task UpdateAdvertisingManifestsAsync(bool includePreviews);
1312

14-
IEnumerable<(ManifestId manifestId, ManifestVersion existingVersion, ManifestVersion newVersion)> CalculateManifestUpdates(SdkFeatureBand featureBand);
13+
IEnumerable<(ManifestId manifestId, ManifestVersion existingVersion, ManifestVersion newVersion)> CalculateManifestUpdates();
1514
}
1615
}

src/Cli/dotnet/commands/dotnet-workload/install/LocalizableStrings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@
214214
<value>Updated advertising manifest {0}.</value>
215215
</data>
216216
<data name="FailedAdManifestUpdate" xml:space="preserve">
217-
<value>Failed to update the advertising manifest {0}: {1}</value>
217+
<value>Failed to update the advertising manifest {0}: {1}.</value>
218+
</data>
219+
<data name="AdManifestPackageDoesNotExist" xml:space="preserve">
220+
<value>Failed to update advertising manifest, manifest package for {0} does not exist.</value>
218221
</data>
219222
<data name="ManifestDoesNotExist" xml:space="preserve">
220223
<value>No manifest with id {0} exists.</value>

src/Cli/dotnet/commands/dotnet-workload/install/WorkloadInstallCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ public void InstallWorkloads(IEnumerable<WorkloadId> workloadIds, bool skipManif
177177
var installedWorkloads = _workloadInstaller.GetWorkloadInstallationRecordRepository().GetInstalledWorkloads(featureBand);
178178
workloadIds = workloadIds.Concat(installedWorkloads).Distinct();
179179

180-
_workloadManifestUpdater.UpdateAdvertisingManifestsAsync(featureBand, includePreviews).Wait();
181-
manifestsToUpdate = _workloadManifestUpdater.CalculateManifestUpdates(featureBand);
180+
_workloadManifestUpdater.UpdateAdvertisingManifestsAsync(includePreviews).Wait();
181+
manifestsToUpdate = _workloadManifestUpdater.CalculateManifestUpdates();
182182
}
183183

184184
InstallWorkloadsWithInstallRecord(workloadIds, featureBand, manifestsToUpdate);
@@ -232,7 +232,7 @@ private void InstallWorkloadsWithInstallRecord(
232232
rollback: () => {
233233
try
234234
{
235-
_reporter.WriteLine(LocalizableStrings.RollingBackInstall);
235+
_reporter.WriteLine(LocalizableStrings.RollingBackInstall);
236236

237237
foreach (var manifest in manifestsToUpdate)
238238
{

src/Cli/dotnet/commands/dotnet-workload/install/WorkloadManifestUpdater.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ internal class WorkloadManifestUpdater : IWorkloadManifestUpdater
1919
private readonly IReporter _reporter;
2020
private readonly IWorkloadManifestProvider _workloadManifestProvider;
2121
private readonly INuGetPackageDownloader _nugetPackageDownloader;
22+
private readonly SdkFeatureBand _sdkFeatureBand;
2223
private readonly string _userHome;
2324

2425
public WorkloadManifestUpdater(
@@ -31,25 +32,26 @@ public WorkloadManifestUpdater(
3132
_workloadManifestProvider = workloadManifestProvider;
3233
_userHome = userHome;
3334
_nugetPackageDownloader = nugetPackageDownloader;
35+
_sdkFeatureBand = new SdkFeatureBand(_workloadManifestProvider.GetSdkFeatureBand());
3436
}
3537

36-
public async Task UpdateAdvertisingManifestsAsync(SdkFeatureBand featureBand, bool includePreviews)
38+
public async Task UpdateAdvertisingManifestsAsync(bool includePreviews)
3739
{
3840
var manifests = GetInstalledManifestIds();
3941
foreach (var manifest in manifests)
4042
{
41-
await UpdateAdvertisingManifestAsync(manifest, featureBand, includePreviews);
43+
await UpdateAdvertisingManifestAsync(manifest, includePreviews);
4244
}
4345
}
4446

45-
public IEnumerable<(ManifestId manifestId, ManifestVersion existingVersion, ManifestVersion newVersion)> CalculateManifestUpdates(SdkFeatureBand featureBand)
47+
public IEnumerable<(ManifestId manifestId, ManifestVersion existingVersion, ManifestVersion newVersion)> CalculateManifestUpdates()
4648
{
4749
var manifestUpdates = new List<(ManifestId, ManifestVersion, ManifestVersion)>();
4850
var currentManifestIds = GetInstalledManifestIds();
4951
foreach (var manifestId in currentManifestIds)
5052
{
5153
var currentManifestVersion = GetInstalledManifestVersion(manifestId);
52-
var adManifestVersion = GetAdvertisingManifestVersion(featureBand, manifestId);
54+
var adManifestVersion = GetAdvertisingManifestVersion(manifestId);
5355
if (adManifestVersion == null)
5456
{
5557
continue;
@@ -76,14 +78,22 @@ private IEnumerable<ManifestId> GetInstalledManifestIds()
7678
return manifests;
7779
}
7880

79-
private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, SdkFeatureBand featureBand, bool includePreviews)
81+
private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, bool includePreviews)
8082
{
8183
string packagePath = null;
8284
string extractionPath = null;
85+
8386
try
8487
{
85-
var adManifestPath = GetAdvertisingManifestPath(featureBand, manifestId);
86-
packagePath = await _nugetPackageDownloader.DownloadPackageAsync(GetManifestPackageId(featureBand, manifestId), includePreview: includePreviews);
88+
var adManifestPath = GetAdvertisingManifestPath(_sdkFeatureBand, manifestId);
89+
try
90+
{
91+
packagePath = await _nugetPackageDownloader.DownloadPackageAsync(GetManifestPackageId(_sdkFeatureBand, manifestId), includePreview: includePreviews);
92+
}
93+
catch (NuGetPackageNotFoundException)
94+
{
95+
_reporter.WriteLine(string.Format(LocalizableStrings.AdManifestPackageDoesNotExist, manifestId));
96+
}
8797
extractionPath = Path.Combine(_userHome, ".dotnet", "sdk-advertising-temp", $"{manifestId}-extracted");
8898
Directory.CreateDirectory(extractionPath);
8999
var resultingFiles = await _nugetPackageDownloader.ExtractPackageAsync(packagePath, extractionPath);
@@ -96,6 +106,7 @@ private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, SdkFeat
96106
FileAccessRetrier.RetryOnMoveAccessFailure(() => Directory.Move(Path.Combine(extractionPath, "data"), adManifestPath));
97107

98108
_reporter.WriteLine(string.Format(LocalizableStrings.AdManifestUpdated, manifestId));
109+
99110
}
100111
catch (Exception e)
101112
{
@@ -126,9 +137,9 @@ private async Task UpdateAdvertisingManifestAsync(ManifestId manifestId, SdkFeat
126137
}
127138
}
128139

129-
private ManifestVersion GetAdvertisingManifestVersion(SdkFeatureBand featureBand, ManifestId manifestId)
140+
private ManifestVersion GetAdvertisingManifestVersion(ManifestId manifestId)
130141
{
131-
var manifestPath = Path.Combine(GetAdvertisingManifestPath(featureBand, manifestId), "WorkloadManifest.json");
142+
var manifestPath = Path.Combine(GetAdvertisingManifestPath(_sdkFeatureBand, manifestId), "WorkloadManifest.json");
132143
if (!File.Exists(manifestPath))
133144
{
134145
return null;

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.cs.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="cs" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.de.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="de" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.es.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="es" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.fr.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="fr" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.it.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="it" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ja.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="ja" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.ko.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="ko" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

src/Cli/dotnet/commands/dotnet-workload/install/xlf/LocalizableStrings.pl.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
33
<file datatype="xml" source-language="en" target-language="pl" original="../LocalizableStrings.resx">
44
<body>
5+
<trans-unit id="AdManifestPackageDoesNotExist">
6+
<source>Failed to update advertising manifest, manifest package for {0} does not exist.</source>
7+
<target state="new">Failed to update advertising manifest, manifest package for {0} does not exist.</target>
8+
<note />
9+
</trans-unit>
510
<trans-unit id="AdManifestUpdated">
611
<source>Updated advertising manifest {0}.</source>
712
<target state="new">Updated advertising manifest {0}.</target>
813
<note />
914
</trans-unit>
1015
<trans-unit id="FailedAdManifestUpdate">
11-
<source>Failed to update the advertising manifest {0}: {1}</source>
12-
<target state="new">Failed to update the advertising manifest {0}: {1}</target>
16+
<source>Failed to update the advertising manifest {0}: {1}.</source>
17+
<target state="new">Failed to update the advertising manifest {0}: {1}.</target>
1318
<note />
1419
</trans-unit>
1520
<trans-unit id="FailedToInstallWorkloadManifest">

0 commit comments

Comments
 (0)