mirror of
https://github.com/winsw/winsw.git
synced 2025-12-10 18:37:28 +08:00
Catch
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net471;netcoreapp5.0</TargetFrameworks>
|
||||
<TargetFrameworks>net471;net5.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp5.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
|
||||
<PackageReference Include="System.Reflection.Metadata" Version="1.8.1" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
</ItemGroup>
|
||||
@@ -39,11 +39,11 @@
|
||||
|
||||
<Target Name="Copy" BeforeTargets="AfterBuild">
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
<_FilesToCopy Include="$(ArtifactsBinDir)WinSW\$(Configuration)\net5.0\WinSW.runtimeconfig*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp5.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
|
||||
<_FilesToCopy Include="$(ArtifactsBinDir)WinSW\$(Configuration)\net461\System.ValueTuple.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -102,7 +102,15 @@ namespace WinSW
|
||||
|
||||
AutoRefresh(config);
|
||||
|
||||
ServiceBase.Run(new WrapperService(config));
|
||||
using var service = new WrapperService(config);
|
||||
try
|
||||
{
|
||||
ServiceBase.Run(service);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// handled in OnStart
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
@@ -586,7 +586,14 @@ namespace WinSW
|
||||
|
||||
if (this.config.Priority is ProcessPriorityClass priority)
|
||||
{
|
||||
process.PriorityClass = priority;
|
||||
try
|
||||
{
|
||||
process.PriorityClass = priority;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// exited
|
||||
}
|
||||
}
|
||||
|
||||
if (logHandler != null)
|
||||
|
||||
Reference in New Issue
Block a user