|
1 | 1 | //css_engine csc |
2 | 2 | //css_include global-usings |
3 | | -using csscript; |
4 | 3 | using System; |
| 4 | +using static System.Console; |
5 | 5 | using System.Diagnostics; |
| 6 | +using static System.Environment; |
6 | 7 | using System.Linq; |
| 8 | +using static System.Reflection.Assembly; |
7 | 9 | using System.Text.Json; |
8 | 10 | using System.Text.Json.Nodes; |
9 | | -using static System.Console; |
10 | | -using static System.Environment; |
11 | | -using static System.Reflection.Assembly; |
| 11 | +using csscript; |
12 | 12 |
|
13 | 13 | var arg1 = args.FirstOrDefault(); |
14 | 14 |
|
|
20 | 20 |
|
21 | 21 | WriteLine($@"v{version} ({Environment.GetEnvironmentVariable("EntryScript")})"); |
22 | 22 | WriteLine($"Sets the script engine target runtime to one of the available .NET deployments."); |
23 | | - WriteLine($" css -self-rt [-help] "); |
| 23 | + WriteLine($" css -self-rt [-l] [-help] "); |
| 24 | + WriteLine($" -l - set the latest available version of runtime."); |
| 25 | + WriteLine($" -help - print this help information."); |
24 | 26 | return; |
25 | 27 | } |
26 | 28 |
|
27 | 29 | // =============================================== |
28 | 30 |
|
29 | | -Console.WriteLine("Available .NET runtimes:"); |
| 31 | +WriteLine("Available .NET runtimes:"); |
30 | 32 |
|
31 | 33 | var sdk_list = "dotnet".run("--list-runtimes") // Microsoft.NETCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] |
32 | 34 | .Split(NewLine) |
|
42 | 44 | WriteLine($"{line.Index}: {line.Version}"); |
43 | 45 | } |
44 | 46 |
|
| 47 | +var selectLatest = args.Contains("-l"); |
| 48 | + |
45 | 49 | WriteLine(); |
46 | 50 | Write("Enter the index of the desired target runtime version: "); |
47 | | -var input = ReadLine(); |
| 51 | +var input = ""; |
| 52 | + |
| 53 | +if (selectLatest) |
| 54 | +{ |
| 55 | + input = sdk_list.Count().ToString(); |
| 56 | + Write(input); |
| 57 | +} |
| 58 | +else |
| 59 | +{ |
| 60 | + input = ReadLine(); |
| 61 | +} |
48 | 62 |
|
49 | 63 | if (int.TryParse(input, out int index)) |
50 | 64 | { |
|
0 commit comments