Skip to content

Commit 11bc116

Browse files
Mohammad DehghanMohammad Dehghan
authored andcommitted
Fix FileNotFoundException when starting first server
1 parent 96ebaf6 commit 11bc116

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

SG.CodeCoverage.Recorder/RecordingController/RuntimeConfig.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace SG.CodeCoverage.Recorder.RecordingController
1010
{
1111
public class RuntimeConfig
1212
{
13-
public List<RunningProcess> Processes { get; set; }
13+
public List<RunningProcess> Processes { get; set; } = new List<RunningProcess>();
1414

1515
public static string GetDefaultFileName()
1616
{
@@ -28,7 +28,11 @@ public void Save()
2828
public static void Update(int port)
2929
{
3030
var path = GetDefaultFileName();
31-
var runtimeConfig = Load(path);
31+
RuntimeConfig runtimeConfig;
32+
if (File.Exists(path))
33+
runtimeConfig = Load(path);
34+
else
35+
runtimeConfig = new RuntimeConfig();
3236
var id = Process.GetCurrentProcess().Id;
3337
runtimeConfig.Processes.RemoveAll(p => p.ID == id);
3438
runtimeConfig.Processes.Add(new RunningProcess(id, port));

0 commit comments

Comments
 (0)