Skip to content

Commit 91d8ac8

Browse files
committed
Merge remote-tracking branch 'upstream/dnup' into nagilson-nuget-pipeline
2 parents ae2f079 + 6c89278 commit 91d8ac8

21 files changed

+653
-732
lines changed

dnup.slnf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"src\\Installer\\dnup\\dnup.csproj",
66
"src\\Installer\\Microsoft.Dotnet.Installation\\Microsoft.Dotnet.Installation.csproj",
77
"test\\dnup.Tests\\dnup.Tests.csproj",
8+
"src\\Resolvers\\Microsoft.DotNet.NativeWrapper\\Microsoft.DotNet.NativeWrapper.csproj
89
]
910
}
10-
}
11+
}

src/Cli/dotnet/Telemetry/EnvironmentDetectionRule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public BooleanEnvironmentRule(params string[] variables)
3333

3434
public override bool IsMatch()
3535
{
36-
return _variables.Any(variable =>
36+
return _variables.Any(variable =>
3737
bool.TryParse(Environment.GetEnvironmentVariable(variable), out bool value) && value);
3838
}
3939
}
@@ -96,8 +96,8 @@ public EnvironmentDetectionRuleWithResult(T result, params string[] variables)
9696
/// <returns>The result value if the rule matches; otherwise, null.</returns>
9797
public T? GetResult()
9898
{
99-
return _variables.Any(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
100-
? _result
99+
return _variables.Any(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
100+
? _result
101101
: null;
102102
}
103-
}
103+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
3+
namespace Microsoft.Dotnet.Installation
4+
{
5+
/// <summary>
6+
/// Represents download progress information.
7+
/// </summary>
8+
public readonly struct DownloadProgress
9+
{
10+
/// <summary>
11+
/// Gets the number of bytes downloaded.
12+
/// </summary>
13+
public long BytesDownloaded { get; }
14+
15+
/// <summary>
16+
/// Gets the total number of bytes to download, if known.
17+
/// </summary>
18+
public long? TotalBytes { get; }
19+
20+
/// <summary>
21+
/// Gets the percentage of download completed, if total size is known.
22+
/// </summary>
23+
public double? PercentComplete => TotalBytes.HasValue ? (double)BytesDownloaded / TotalBytes.Value * 100 : null;
24+
25+
public DownloadProgress(long bytesDownloaded, long? totalBytes)
26+
{
27+
BytesDownloaded = bytesDownloaded;
28+
TotalBytes = totalBytes;
29+
}
30+
}
31+
}

src/Installer/Microsoft.Dotnet.Installation/Internal/ArchiveDotnetExtractor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ public void Commit(IEnumerable<ReleaseVersion> existingSdkVersions)
115115
{
116116
// When no-progress is enabled, install without progress display
117117
Console.WriteLine($"Installing .NET SDK {_resolvedVersion}...");
118-
118+
119119
// Extract archive directly to target directory with special handling for muxer
120120
var extractResult = ExtractArchiveDirectlyToTarget(_archivePath, _request.InstallRoot.Path!, existingSdkVersions, null);
121-
if (extractResult != null)
121+
if (extractResult is not null)
122122
{
123123
throw new InvalidOperationException($"Failed to install SDK: {extractResult}");
124124
}
125-
125+
126126
Console.WriteLine($"Installation of .NET SDK {_resolvedVersion} complete.");
127127
}
128128
else
@@ -135,7 +135,7 @@ public void Commit(IEnumerable<ReleaseVersion> existingSdkVersions)
135135

136136
// Extract archive directly to target directory with special handling for muxer
137137
var extractResult = ExtractArchiveDirectlyToTarget(_archivePath, _request.InstallRoot.Path!, existingSdkVersions, installTask);
138-
if (extractResult != null)
138+
if (extractResult is not null)
139139
{
140140
throw new InvalidOperationException($"Failed to install SDK: {extractResult}");
141141
}
@@ -204,7 +204,7 @@ private MuxerHandlingConfig ConfigureMuxerHandling(IEnumerable<ReleaseVersion> e
204204
long totalFiles = CountTarEntries(decompressedPath);
205205

206206
// Set progress maximum
207-
if (installTask != null)
207+
if (installTask is not null)
208208
{
209209
installTask.MaxValue = totalFiles > 0 ? totalFiles : 1;
210210
}
@@ -255,7 +255,7 @@ private long CountTarEntries(string tarPath)
255255
long totalFiles = 0;
256256
using var tarStream = File.OpenRead(tarPath);
257257
var tarReader = new TarReader(tarStream);
258-
while (tarReader.GetNextEntry() != null)
258+
while (tarReader.GetNextEntry() is not null)
259259
{
260260
totalFiles++;
261261
}
@@ -271,7 +271,7 @@ private void ExtractTarContents(string tarPath, string targetDir, MuxerHandlingC
271271
var tarReader = new TarReader(tarStream);
272272
TarEntry? entry;
273273

274-
while ((entry = tarReader.GetNextEntry()) != null)
274+
while ((entry = tarReader.GetNextEntry()) is not null)
275275
{
276276
if (entry.EntryType == TarEntryType.RegularFile)
277277
{

0 commit comments

Comments
 (0)