Undo the DRYness for CanonicalPackageName as it causes VS havoc

This commit is contained in:
Jordan Dominion
2024-11-16 19:46:50 -05:00
parent 6fe5e70c51
commit ec7bc64ed3
10 changed files with 22 additions and 39 deletions
@@ -4,7 +4,6 @@
using System.IO;
using System.ServiceProcess;
using Tgstation.Server.Common;
using Tgstation.Server.Host.Common;
using WixToolset.Dtf.WindowsInstaller;
@@ -14,6 +13,12 @@
/// </summary>
public static class InstallationExtensions
{
/// <summary>
/// Package name
/// </summary>
/// <remarks>As much as I'd like to use Tgstation.Server.Common.Constants.CanonicalPackageName here, attempting to reference it makes VS go crazy with fake errors.</remarks>
const string CanonicalPackageName = "tgstation-server";
/// <summary>
/// Attempts to detach stop the existing tgstation-server service if it exists.
/// </summary>
@@ -30,18 +35,18 @@
session.Log("Begin DetachStopTgsServiceIfRunning");
ServiceController serviceController = null;
session.Log($"Searching for {Constants.CanonicalPackageName} service...");
session.Log($"Searching for {CanonicalPackageName} service...");
try
{
foreach (var controller in ServiceController.GetServices())
if (controller.ServiceName == Constants.CanonicalPackageName)
if (controller.ServiceName == CanonicalPackageName)
serviceController = controller;
else
controller.Dispose();
if (serviceController == null || serviceController.Status != ServiceControllerStatus.Running)
{
session.Log($"{Constants.CanonicalPackageName} service not found. Continuing.");
session.Log($"{CanonicalPackageName} service not found. Continuing.");
return ActionResult.Success;
}
@@ -49,16 +54,16 @@
PipeCommands.CommandDetachingShutdown)
.Value;
session.Log($"{Constants.CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})...");
session.Log($"{CanonicalPackageName} service found. Sending command \"{PipeCommands.CommandDetachingShutdown}\" ({commandId})...");
serviceController.ExecuteCommand(commandId);
session.Log($"Command sent. Waiting for {Constants.CanonicalPackageName} service to stop...");
session.Log($"Command sent. Waiting for {CanonicalPackageName} service to stop...");
serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromMinutes(1));
var stopped = serviceController.Status == ServiceControllerStatus.Stopped;
session.Log($"{Constants.CanonicalPackageName} stopped {(stopped ? String.Empty : "un")}successfully.");
session.Log($"{CanonicalPackageName} stopped {(stopped ? String.Empty : "un")}successfully.");
return stopped
? ActionResult.Success
@@ -92,7 +97,7 @@
session.Log("Begin ApplyProductionAppsettingsIfNonExistant");
var programDataDirectory = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
Constants.CanonicalPackageName);
CanonicalPackageName);
var initialAppSettingsPath = Path.Combine(programDataDirectory, "appsettings.Initial.yml");
var productionAppSettingsPath = Path.Combine(programDataDirectory, "appsettings.Production.yml");
@@ -11,7 +11,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Tgstation.Server.Common\Tgstation.Server.Common.csproj" />
<ProjectReference Include="..\..\..\..\src\Tgstation.Server.Host.Common\Tgstation.Server.Host.Common.csproj">
<Private>True</Private>
</ProjectReference>
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
@@ -156,4 +155,3 @@ namespace Tgstation.Server.Common.Extensions
public static ValueTask WhenAll(params ValueTask[] tasks) => WhenAll((IReadOnlyList<ValueTask>)tasks);
}
}
#endif
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
using System;
using System;
namespace Tgstation.Server.Common.Extensions
{
@@ -25,4 +24,3 @@ namespace Tgstation.Server.Common.Extensions
}
}
}
#endif
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
using System;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
@@ -106,4 +105,3 @@ namespace Tgstation.Server.Common.Http
}
}
}
#endif
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
using System;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
@@ -50,4 +49,3 @@ namespace Tgstation.Server.Common.Http
=> httpClient.SendAsync(request, completionOption, cancellationToken);
}
}
#endif
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
using System;
using System;
using System.Net.Http.Headers;
namespace Tgstation.Server.Common.Http
@@ -40,4 +39,3 @@ namespace Tgstation.Server.Common.Http
}
}
}
#endif
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
namespace Tgstation.Server.Common.Http
namespace Tgstation.Server.Common.Http
{
/// <summary>
/// Creates <see cref="IHttpClient"/>s.
@@ -13,4 +12,3 @@ namespace Tgstation.Server.Common.Http
IHttpClient CreateClient();
}
}
#endif
@@ -1,5 +1,4 @@
#if NETSTANDARD2_0_OR_GREATER
using System;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
@@ -32,4 +31,3 @@ namespace Tgstation.Server.Common.Http
Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken);
}
}
#endif
@@ -2,7 +2,7 @@
<Import Project="../../build/NugetCommon.props" />
<PropertyGroup>
<TargetFrameworks>$(TgsNugetNetFramework);net2.0</TargetFrameworks>
<TargetFrameworks>$(TgsNugetNetFramework)</TargetFrameworks>
<Version>$(TgsCommonLibraryVersion)</Version>
<Nullable>enable</Nullable>
<Description>Common functions for tgstation-server.</Description>
@@ -10,7 +10,7 @@
<PackageReleaseNotes>$(TGS_NUGET_RELEASE_NOTES_COMMON)</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net2.0'">
<ItemGroup>
<!-- Usage: ValueTask netstandard backport -->
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
</ItemGroup>
@@ -24,11 +24,4 @@
<Message Text="Cleaning icons..." Importance="high" />
<Delete Files="../../artifacts/tgs.ico;../../artifacts/tgs.png" />
</Target>
<ItemGroup Condition="'$(TargetFramework)' == 'net2.022'">
<Compile Remove="Extensions\*.cs" />
<Compile Remove="Http\*.cs" />
<None Include="Extensions\*.cs" />
<None Include="Http\*.cs" />
</ItemGroup>
</Project>