Skip to content

Commit 1254344

Browse files
committed
Include installer library assembly informational version in user agent
1 parent 9baf4b4 commit 1254344

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Net;
88
using System.Net.Http;
99
using System.Net.Http.Headers;
10+
using System.Reflection;
1011
using System.Security.Cryptography;
1112
using System.Text;
1213
using System.Threading;
@@ -67,8 +68,12 @@ private static HttpClient CreateDefaultHttpClient()
6768
Timeout = TimeSpan.FromMinutes(10)
6869
};
6970

70-
// Set user-agent to identify dnup in telemetry
71-
client.DefaultRequestHeaders.UserAgent.ParseAdd("dnup-dotnet-installer");
71+
// Set user-agent to identify dnup in telemetry, including version
72+
var informationalVersion = typeof(DotnetArchiveDownloader).Assembly
73+
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
74+
string userAgent = informationalVersion == null ? "dotnetup-dotnet-installer" : $"dnup-dotnet-installer/{informationalVersion}";
75+
76+
client.DefaultRequestHeaders.UserAgent.ParseAdd(userAgent);
7277

7378
return client;
7479
}

0 commit comments

Comments
 (0)