Skip to content

Commit edc51ee

Browse files
authored
[automated] Merge branch 'release/8.0.3xx' => 'main' (#39786)
2 parents c36eda5 + a147448 commit edc51ee

File tree

153 files changed

+3713
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+3713
-391
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftNETCoreAppRefPackageVersion)"/>
4444
<PackageVersion Include="Microsoft.FSharp.Compiler" Version="$(MicrosoftFSharpCompilerPackageVersion)" />
4545
<PackageVersion Include="Microsoft.Net.Compilers.Toolset.Framework" Version="$(MicrosoftNetCompilersToolsetVersion)" />
46+
<PackageVersion Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
4647
<PackageVersion Include="Microsoft.NET.HostModel" Version="$(MicrosoftNETHostModelVersion)" />
4748
<PackageVersion Include="Microsoft.NET.Sdk.Razor.SourceGenerators.Transport" Version="$(MicrosoftNETSdkRazorSourceGeneratorsTransportPackageVersion)" />
4849
<PackageVersion Include="Microsoft.NETCore.DotNetHostResolver" Version="$(MicrosoftNETCoreDotNetHostResolverPackageVersion)" />

documentation/general/workloads/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Other documentation for workloads is in this repo:
2020
- [Grouping multiple packs into one MSI](https://github.com/dotnet/sdk/issues/21741)
2121
- [Handling workload assets across major .NET versions](cross-version-workloads.md)
2222
- [Workload Clean Command](workload-clean.md)
23+
- [Workload MSI Installation Tests](/test/dotnet-MsiInstallation.Tests/README.md)

sdk.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Build.Contain
475475
EndProject
476476
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SDDLTests", "test\SDDLTests\SDDLTests.csproj", "{FEA8B7B5-901B-4A3A-948F-7E5F54F09FF5}"
477477
EndProject
478+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-MsiInstallation.Tests", "test\dotnet-MsiInstallation.Tests\dotnet-MsiInstallation.Tests.csproj", "{36975025-857B-45F0-AB39-904B521A6713}"
479+
EndProject
478480
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compatibility", "Compatibility", "{44E564E1-AE0D-4313-A4E9-CBF2109397E3}"
479481
EndProject
480482
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compatibility", "Compatibility", "{3AD322BF-405B-4A53-9858-51CF66E8509F}"
@@ -913,6 +915,10 @@ Global
913915
{D7495CE7-64E5-4715-9304-799A41EC1D71}.Debug|Any CPU.Build.0 = Debug|Any CPU
914916
{D7495CE7-64E5-4715-9304-799A41EC1D71}.Release|Any CPU.ActiveCfg = Release|Any CPU
915917
{D7495CE7-64E5-4715-9304-799A41EC1D71}.Release|Any CPU.Build.0 = Release|Any CPU
918+
{36975025-857B-45F0-AB39-904B521A6713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
919+
{36975025-857B-45F0-AB39-904B521A6713}.Debug|Any CPU.Build.0 = Debug|Any CPU
920+
{36975025-857B-45F0-AB39-904B521A6713}.Release|Any CPU.ActiveCfg = Release|Any CPU
921+
{36975025-857B-45F0-AB39-904B521A6713}.Release|Any CPU.Build.0 = Release|Any CPU
916922
EndGlobalSection
917923
GlobalSection(SolutionProperties) = preSolution
918924
HideSolutionNode = FALSE
@@ -1081,6 +1087,7 @@ Global
10811087
{85A01ACB-CC90-45EF-8F6C-AFC2B9F31126} = {3AD322BF-405B-4A53-9858-51CF66E8509F}
10821088
{7382A1CB-AA9A-4136-A548-17D7A67C6B0C} = {71A9F549-0EB6-41F9-BC16-4A6C5007FC91}
10831089
{D7495CE7-64E5-4715-9304-799A41EC1D71} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
1090+
{36975025-857B-45F0-AB39-904B521A6713} = {580D1AE7-AA8F-4912-8B76-105594E00B3B}
10841091
EndGlobalSection
10851092
GlobalSection(ExtensibilityGlobals) = postSolution
10861093
SolutionGuid = {FB8F26CE-4DE6-433F-B32A-79183020BBD6}

src/Cli/Microsoft.DotNet.Cli.Utils/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ public static class Constants
2828
public static readonly string AnyRid = "any";
2929

3030
public static readonly string RestoreInteractiveOption = "--interactive";
31+
public static readonly string workloadSetVersionFileName = "workloadVersion.txt";
3132
}
3233
}

src/Cli/Microsoft.DotNet.Cli.Utils/PathUtility.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ public static bool TryDeleteDirectory(string directoryPath)
9797
}
9898
}
9999

100+
/// <summary>
101+
/// Deletes the provided file. Then deletes the parent directory if empty
102+
/// and continues to its parent until it fails. Returns whether it succeeded
103+
/// in deleting the file it was intended to delete.
104+
/// </summary>
105+
public static bool DeleteFileAndEmptyParents(string path)
106+
{
107+
if (!File.Exists(path))
108+
{
109+
return false;
110+
}
111+
112+
File.Delete(path);
113+
var dir = Path.GetDirectoryName(path);
114+
115+
while (!Directory.EnumerateFileSystemEntries(dir).Any())
116+
{
117+
Directory.Delete(dir);
118+
dir = Path.GetDirectoryName(dir);
119+
}
120+
121+
return !File.Exists(path);
122+
}
123+
100124
/// <summary>
101125
/// Returns childItem relative to directory, with Path.DirectorySeparatorChar as separator
102126
/// </summary>

src/Cli/dotnet/Installer/Windows/InstallMessageDispatcher.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,21 @@ public InstallResponseMessage SendUpdateWorkloadModeRequest(SdkFeatureBand sdkFe
192192
UseWorkloadSets = newMode,
193193
});
194194
}
195+
196+
/// <summary>
197+
/// Send an <see cref="InstallRequestMessage"/> to adjust the workload set version used for installing and updating workloads
198+
/// </summary>
199+
/// <param name="sdkFeatureBand">The SDK feature band of the install state file to write</param>
200+
/// <param name="newVersion">The workload set version</param>
201+
/// <returns></returns>
202+
public InstallResponseMessage SendUpdateWorkloadSetRequest(SdkFeatureBand sdkFeatureBand, string newVersion)
203+
{
204+
return Send(new InstallRequestMessage
205+
{
206+
RequestType = InstallRequestType.AdjustWorkloadSetVersion,
207+
SdkFeatureBand = sdkFeatureBand.ToString(),
208+
WorkloadSetVersion = newVersion,
209+
});
210+
}
195211
}
196212
}

src/Cli/dotnet/Installer/Windows/InstallRequestMessage.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ public bool UseWorkloadSets
128128
get; set;
129129
}
130130

131+
/// <summary>
132+
/// The workload set version
133+
/// </summary>
134+
public string WorkloadSetVersion
135+
{
136+
get; set;
137+
}
138+
131139
/// <summary>
132140
/// Converts a deserialized array of bytes into an <see cref="InstallRequestMessage"/>.
133141
/// </summary>

src/Cli/dotnet/Installer/Windows/InstallRequestType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,10 @@ public enum InstallRequestType
6969
/// Changes the workload mode
7070
/// </summary>
7171
AdjustWorkloadMode,
72+
73+
/// <summary>
74+
/// Changes the workload set version
75+
/// </summary>
76+
AdjustWorkloadSetVersion,
7277
}
7378
}

src/Cli/dotnet/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public static int Main(string[] args)
4343

4444
bool perfLogEnabled = Env.GetEnvironmentVariableAsBool("DOTNET_CLI_PERF_LOG", false);
4545

46+
if (string.IsNullOrEmpty(Env.GetEnvironmentVariable("MSBUILDFAILONDRIVEENUMERATINGWILDCARD")))
47+
{
48+
Environment.SetEnvironmentVariable("MSBUILDFAILONDRIVEENUMERATINGWILDCARD", "1");
49+
}
50+
4651
// Avoid create temp directory with root permission and later prevent access in non sudo
4752
if (SudoEnvironmentDirectoryOverride.IsRunningUnderSudo())
4853
{

src/Cli/dotnet/commands/InstallingWorkloadCommand.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ internal abstract class InstallingWorkloadCommand : WorkloadCommandBase
3434
protected readonly SdkFeatureBand _sdkFeatureBand;
3535
protected readonly ReleaseVersion _targetSdkVersion;
3636
protected readonly string _fromRollbackDefinition;
37+
protected string _workloadSetVersion;
3738
protected readonly PackageSourceLocation _packageSourceLocation;
3839
protected readonly IWorkloadResolverFactory _workloadResolverFactory;
3940
protected IWorkloadResolver _workloadResolver;
@@ -96,6 +97,53 @@ protected static Dictionary<string, string> GetInstallStateContents(IEnumerable<
9697
manifestVersionUpdates.Select(update => new WorkloadManifestInfo(update.ManifestId.ToString(), update.NewVersion.ToString(), /* We don't actually use the directory here */ string.Empty, update.NewFeatureBand))
9798
).ToDictionaryForJson();
9899

100+
public static bool ShouldUseWorkloadSetMode(SdkFeatureBand sdkFeatureBand, string dotnetDir)
101+
{
102+
string path = Path.Combine(WorkloadInstallType.GetInstallStateFolder(sdkFeatureBand, dotnetDir), "default.json");
103+
var installStateContents = File.Exists(path) ? InstallStateContents.FromString(File.ReadAllText(path)) : new InstallStateContents();
104+
return installStateContents.UseWorkloadSets ?? false;
105+
}
106+
107+
protected IEnumerable<ManifestVersionUpdate> HandleWorkloadUpdateFromVersion(ITransactionContext context, DirectoryPath? offlineCache)
108+
{
109+
// Ensure workload set mode is set to 'workloadset'
110+
// Do not skip checking the mode first, as setting it triggers
111+
// an admin authorization popup for MSI-based installs.
112+
if (!ShouldUseWorkloadSetMode(_sdkFeatureBand, _dotnetPath))
113+
{
114+
_workloadInstaller.UpdateInstallMode(_sdkFeatureBand, true);
115+
}
116+
117+
_workloadManifestUpdater.DownloadWorkloadSet(_workloadSetVersion, offlineCache);
118+
return InstallWorkloadSet(context);
119+
}
120+
121+
public IEnumerable<ManifestVersionUpdate> InstallWorkloadSet(ITransactionContext context)
122+
{
123+
var advertisingPackagePath = Path.Combine(_userProfileDir, "sdk-advertising", _sdkFeatureBand.ToString(), "microsoft.net.workloads");
124+
if (File.Exists(Path.Combine(advertisingPackagePath, Constants.workloadSetVersionFileName)))
125+
{
126+
// This file isn't created in tests.
127+
PrintWorkloadSetTransition(File.ReadAllText(Path.Combine(advertisingPackagePath, Constants.workloadSetVersionFileName)));
128+
}
129+
var workloadSetPath = _workloadInstaller.InstallWorkloadSet(context, advertisingPackagePath);
130+
var files = Directory.EnumerateFiles(workloadSetPath, "*.workloadset.json");
131+
return _workloadManifestUpdater.ParseRollbackDefinitionFiles(files);
132+
}
133+
134+
private void PrintWorkloadSetTransition(string newVersion)
135+
{
136+
var currentVersion = _workloadResolver.GetWorkloadVersion();
137+
if (currentVersion == null)
138+
{
139+
Reporter.WriteLine(string.Format(Strings.NewWorkloadSet, newVersion));
140+
}
141+
else
142+
{
143+
Reporter.WriteLine(string.Format(Strings.WorkloadSetUpgrade, currentVersion, newVersion));
144+
}
145+
}
146+
99147
protected async Task<List<WorkloadDownload>> GetDownloads(IEnumerable<WorkloadId> workloadIds, bool skipManifestUpdate, bool includePreview, string downloadFolder = null,
100148
IReporter reporter = null, INuGetPackageDownloader packageDownloader = null)
101149
{
@@ -204,6 +252,11 @@ internal static class InstallingWorkloadCommandParser
204252
Hidden = true
205253
};
206254

255+
public static readonly CliOption<string> WorkloadSetVersionOption = new("--version")
256+
{
257+
Description = Strings.WorkloadSetVersionOptionDescription
258+
};
259+
207260
public static readonly CliOption<bool> PrintDownloadLinkOnlyOption = new("--print-download-link-only")
208261
{
209262
Description = Strings.PrintDownloadLinkOnlyDescription,

0 commit comments

Comments
 (0)