Skip to content

Commit d51041d

Browse files
DAR: Allow caller to control VSASSERT path (#1489)
For other internal clients, it would be helpful if one could control the VSASSERT path, as this path is also used to write out where dump files are stored on Windows. This PR updates support to enable this.
1 parent 4aef1f4 commit d51041d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/DebugAdapterRunner/DebugAdapterRunner.cs

+20-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Diagnostics;
99
using System.Globalization;
1010
using System.IO;
11+
using System.Linq;
1112
using System.Text;
1213
using System.Threading;
1314

@@ -163,8 +164,25 @@ private void StartDebugAdapter(
163164

164165
if (redirectVSAssert)
165166
{
166-
_assertionFileName = Path.Combine(Path.GetTempPath(), string.Format(CultureInfo.InvariantCulture, "vsassert.{0}.txt", Guid.NewGuid()));
167-
startInfo.Environment["VSASSERT"] = _assertionFileName;
167+
string vsassertPath = null;
168+
169+
// First see if the caller already specified the assertion path
170+
if (additionalEnvironmentVariables != null)
171+
{
172+
vsassertPath = additionalEnvironmentVariables
173+
.Where(pair => pair.Key.Equals("VSASSERT", StringComparison.OrdinalIgnoreCase))
174+
.Select(pair => pair.Value)
175+
.FirstOrDefault();
176+
}
177+
178+
if (string.IsNullOrEmpty(vsassertPath))
179+
{
180+
// If the caller didn't specify a path, create a temporary one
181+
vsassertPath = Path.Combine(Path.GetTempPath(), string.Format(CultureInfo.InvariantCulture, "vsassert.{0}.txt", Guid.NewGuid()));
182+
startInfo.Environment["VSASSERT"] = vsassertPath;
183+
}
184+
185+
_assertionFileName = vsassertPath;
168186
}
169187

170188
if (additionalEnvironmentVariables != null)

0 commit comments

Comments
 (0)