Fix Assembly string empty on Publish
This commit is contained in:
@ -8,16 +8,34 @@ namespace CShocker.Devices.Additional;
|
||||
|
||||
public static class ApiHttpClient
|
||||
{
|
||||
internal static HttpResponseMessage MakeAPICall(HttpMethod method, string uri, string? jsonContent, ILogger? logger = null, params ValueTuple<string, string>[] customHeaders)
|
||||
private static readonly ProductInfoHeaderValue UserAgent = GetUserAgent();
|
||||
|
||||
private static ProductInfoHeaderValue GetUserAgent()
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
ProductInfoHeaderValue userAgent = new (fvi.ProductName ?? fvi.FileName, fvi.ProductVersion);
|
||||
FileVersionInfo fvi;
|
||||
if (assembly.Location == String.Empty)
|
||||
{
|
||||
DirectoryInfo dir = new (AppContext.BaseDirectory);
|
||||
FileInfo? f = dir.GetFiles("*.exe").FirstOrDefault();
|
||||
if (f is null)
|
||||
return new("CShocker", "Release");
|
||||
fvi = FileVersionInfo.GetVersionInfo(f.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
}
|
||||
return new (fvi.ProductName ?? fvi.FileName, fvi.ProductVersion);
|
||||
}
|
||||
|
||||
internal static HttpResponseMessage MakeAPICall(HttpMethod method, string uri, string? jsonContent, ILogger? logger = null, params ValueTuple<string, string>[] customHeaders)
|
||||
{
|
||||
HttpRequestMessage request = new (method, uri)
|
||||
{
|
||||
Headers =
|
||||
{
|
||||
UserAgent = { userAgent },
|
||||
UserAgent = { UserAgent },
|
||||
Accept = { new MediaTypeWithQualityHeaderValue("application/json") },
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user