Fix Assembly string empty on Publish
This commit is contained in:
parent
b497117b62
commit
c55592cd90
12
.idea/.idea.CShocker/.idea/riderPublish.xml
generated
Normal file
12
.idea/.idea.CShocker/.idea/riderPublish.xml
generated
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="LocationsWithSilentDeleteHolder">
|
||||||
|
<option name="locations">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/CShocker/bin/Release/net9.0/win-x64" />
|
||||||
|
<option value="$PROJECT_DIR$/CShocker/bin/Release/net9.0/linux-x64/publish" />
|
||||||
|
<option value="$PROJECT_DIR$/CShocker/bin/Release/net9.0/win-x64/publish" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -6,7 +6,7 @@
|
|||||||
<Authors>Glax</Authors>
|
<Authors>Glax</Authors>
|
||||||
<RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl>
|
<RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<Version>3.0.0</Version>
|
<Version>3.0.1</Version>
|
||||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||||
<LangVersion>latestmajor</LangVersion>
|
<LangVersion>latestmajor</LangVersion>
|
||||||
<PackageProjectUrl>https://github.com/C9Glax/CShocker</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/C9Glax/CShocker</PackageProjectUrl>
|
||||||
|
@ -8,16 +8,30 @@ namespace CShocker.Devices.Additional;
|
|||||||
|
|
||||||
public static class ApiHttpClient
|
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();
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
if (assembly.Location == String.Empty)
|
||||||
|
{
|
||||||
|
DirectoryInfo dir = new (AppContext.BaseDirectory);
|
||||||
|
FileInfo? f = dir.GetFiles("*.exe").FirstOrDefault();
|
||||||
|
if (f is null)
|
||||||
|
return new("CShocker", "Release");
|
||||||
|
assembly = Assembly.LoadFrom(f.FullName);
|
||||||
|
}
|
||||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||||
ProductInfoHeaderValue userAgent = new (fvi.ProductName ?? fvi.FileName, fvi.ProductVersion);
|
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)
|
HttpRequestMessage request = new (method, uri)
|
||||||
{
|
{
|
||||||
Headers =
|
Headers =
|
||||||
{
|
{
|
||||||
UserAgent = { userAgent },
|
UserAgent = { UserAgent },
|
||||||
Accept = { new MediaTypeWithQualityHeaderValue("application/json") },
|
Accept = { new MediaTypeWithQualityHeaderValue("application/json") },
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user