From 513d288a5d0d71e36b19e9f7c49816f1aea57d58 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Mon, 3 Jul 2017 10:15:53 +0100 Subject: [PATCH] Use GetRandomFileName instead of GetTempFileName. Fixes #1060 --- appveyor.yml | 2 +- src/Microsoft.AspNetCore.NodeServices/Util/StringAsTempFile.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f40e66a..7de4d7c 100755 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ install: - ps: $urlCurrent = "https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.0-preview2-006497/dotnet-sdk-2.0.0-preview2-006497-win-x64.zip" - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk" - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null - - ps: $tempFileCurrent = [System.IO.Path]::GetTempFileName() + - ps: $tempFileCurrent = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName()) - ps: (New-Object System.Net.WebClient).DownloadFile($urlCurrent, $tempFileCurrent) - ps: Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($tempFileCurrent, $env:DOTNET_INSTALL_DIR) - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" diff --git a/src/Microsoft.AspNetCore.NodeServices/Util/StringAsTempFile.cs b/src/Microsoft.AspNetCore.NodeServices/Util/StringAsTempFile.cs index c15bca3..c4aea7f 100644 --- a/src/Microsoft.AspNetCore.NodeServices/Util/StringAsTempFile.cs +++ b/src/Microsoft.AspNetCore.NodeServices/Util/StringAsTempFile.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.NodeServices /// A token that indicates when the host application is stopping. public StringAsTempFile(string content, CancellationToken applicationStoppingToken) { - FileName = Path.GetTempFileName(); + FileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); File.WriteAllText(FileName, content); // Because .NET finalizers don't reliably run when the process is terminating, also