Skip to content

Commit

Permalink
Remove WindowsProcessSignaler's reliance on creating/deleting a temp …
Browse files Browse the repository at this point in the history
…directory
  • Loading branch information
madelson committed Dec 17, 2019
1 parent 117e005 commit 39bcc02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions MedallionShell/MedallionShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<PropertyGroup>
<RootNamespace>Medallion.Shell</RootNamespace>
<Version>1.6.0</Version>
<AssemblyVersion>1.6.0.0</AssemblyVersion>
<Version>1.6.1-alpha01</Version>
<AssemblyVersion>1.6.1.0</AssemblyVersion>
<FileVersion>1.6.0.0</FileVersion>
<Authors>Michael Adelson</Authors>
<Description>A lightweight, cross-platform library that simplifies working with processes in .NET</Description>
Expand Down Expand Up @@ -38,7 +38,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.Diagnostics.Process" version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
Expand Down
9 changes: 3 additions & 6 deletions MedallionShell/Signals/WindowsProcessSignaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ private static async Task<bool> SendSignalFromCurrentProcess(int processId, Nati

private static async Task<TemporaryExeFile> DeploySignalerExeAsync()
{
var tempDirectoryName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(tempDirectoryName);
const string SignalerExeName = "MedallionShell.ProcessSignaler.exe";
var exePath = Path.Combine(tempDirectoryName, SignalerExeName);
using (var resourceStream = Helpers.GetMedallionShellAssembly().GetManifestResourceStream(SignalerExeName))
const string SignalerExeNameWithoutExtension = "MedallionShell.ProcessSignaler";
var exePath = Path.Combine(Path.GetTempPath(), $"{SignalerExeNameWithoutExtension}_{Guid.NewGuid():N}.exe");
using (var resourceStream = Helpers.GetMedallionShellAssembly().GetManifestResourceStream(SignalerExeNameWithoutExtension + ".exe"))
using (var fileStream = new FileStream(exePath, FileMode.CreateNew, FileAccess.Write, FileShare.None, Constants.ByteBufferSize, useAsync: true))
{
await resourceStream.CopyToAsync(fileStream).ConfigureAwait(false);
Expand All @@ -142,7 +140,6 @@ public void Dispose()
if (toDelete != null)
{
File.Delete(toDelete);
Directory.Delete(System.IO.Path.GetDirectoryName(toDelete));
}
}
}
Expand Down

0 comments on commit 39bcc02

Please sign in to comment.