-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (47 loc) · 1.83 KB
/
Program.cs
File metadata and controls
55 lines (47 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using HostApi;
using VsCodeInstallerHelper;
using VsCodeInstallerHelper.ConfigModels;
// Build a dotnet solution or project
switch (Args.Count)
{
case 0:
Error("No arguments provided. Please specify a config file in Yaml or Json format.");
return 1;
case > 1:
Error("To much arguments provided. Please specify a config file in Yaml or Json format.");
return 1;
}
var argConfigFile = Args [0];
ArgumentException.ThrowIfNullOrWhiteSpace(argConfigFile);
var configFilePath = argConfigFile;
var loadedConfigs = new List<LoadFileConfig>();
await ConfigLoading.LoadConfigs([configFilePath], loadedConfigs);
var mergedConfig = ConfigMerging.Merge(loadedConfigs);
if (mergedConfig is null)
{
Error("Merged config is null. Please check your config files.");
return 1;
}
if (mergedConfig.Executing is null)
{
Error("No 'Executing' field found in the merged config. Please specify the executable to run.");
return 1;
}
var workingDirectory = Path.IsPathFullyQualified(argConfigFile) ? Path.GetDirectoryName(argConfigFile) : Directory.GetCurrentDirectory();
if (workingDirectory is null)
{
Error("Failed to determine the working directory.");
return 1;
}
var resolveFullPath = mergedConfig.Configure?.ResolveFullPath ?? false;
var checkFileExists = mergedConfig.Configure?.CheckFileExists ?? false;
var executing = FileLikeArgsProcessing.UpdateFileSystemPath(mergedConfig.Executing, workingDirectory, true, false);
var executingParams = FileLikeArgsProcessing.UpdateFileArgs(mergedConfig.ExecuteParams, workingDirectory,
resolveFullPath, checkFileExists).ToArray();
var commandLine = new CommandLine(executing)
.WithWorkingDirectory(workingDirectory)
.WithArgs(executingParams)
.WithShortName(mergedConfig.Executing);
var result = await commandLine.RunAsync();
_ = result.EnsureSuccess();
return 0;