Skip to content

Commit

Permalink
Catch
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtn committed Aug 29, 2020
1 parent 2fc786a commit a7c5334
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/WinSW.Tests/WinSW.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net471;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks>net471;net5.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand All @@ -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>
Expand All @@ -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>

Expand Down
10 changes: 9 additions & 1 deletion src/WinSW/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ internal static int Main(string[] args)
AutoRefresh(config);
ServiceBase.Run(new WrapperService(config));
using var service = new WrapperService(config);
try
{
ServiceBase.Run(service);
}
catch
{
// handled in OnStart
}
}),
};

Expand Down
9 changes: 8 additions & 1 deletion src/WinSW/WrapperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,14 @@ private Process StartProcess(string executable, string? arguments, LogHandler? l

if (this.config.Priority is ProcessPriorityClass priority)
{
process.PriorityClass = priority;
try
{
process.PriorityClass = priority;
}
catch (InvalidOperationException)
{
// exited
}
}

if (logHandler != null)
Expand Down

0 comments on commit a7c5334

Please sign in to comment.