You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CSharpInteractive.HostApi/DotNetCommands.cs
+94-13Lines changed: 94 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,29 @@ namespace HostApi;
10
10
/// You specify the path to an application .dll file to run the application. To run the application means to find and execute the entry point, which in the case of console apps is the Main method. For example, dotnet myapp.dll runs the myapp application.
/// <param name="Args">Specifies the set of command line arguments to use when starting the tool.</param>
15
38
/// <param name="Vars">Specifies the set of environment variables that apply to this process and its child processes.</param>
@@ -94,6 +117,29 @@ public IStartInfo GetStartInfo(IHost host)
94
117
/// You specify the path to an application .dll file to run the application. To run the application means to find and execute the entry point, which in the case of console apps is the Main method. For example, dotnet myapp.dll runs the myapp application.
/// <param name="Args">Specifies the set of command line arguments to use when starting the tool.</param>
99
145
/// <param name="Vars">Specifies the set of environment variables that apply to this process and its child processes.</param>
@@ -614,16 +660,37 @@ public IStartInfo GetStartInfo(IHost host)
614
660
/// <p>
615
661
/// For executable projects targeting .NET Core 3.0 and later, library dependencies are copied to the output folder. This means that if there isn't any other publish-specific logic (such as Web projects have), the build output should be deployable.
/// <param name="Args">Specifies the set of command line arguments to use when starting the tool.</param>
629
696
/// <param name="Vars">Specifies the set of environment variables that apply to this process and its child processes.</param>
@@ -3772,20 +3839,34 @@ public IStartInfo GetStartInfo(IHost host)
3772
3839
/// <p>
3773
3840
/// To run the application, the dotnet run command resolves the dependencies of the application that are outside of the shared runtime from the NuGet cache. Because it uses cached dependencies, it's not recommended to use dotnet run to run applications in production. Instead, create a deployment using the dotnet publish command and deploy the published output.
var projectArg = new Arg("Project", "", "string", "The project or solution file to operate on. If not specified, the command searches the current directory for one. If more than one solution or project is found, an error is thrown.") { IsProject = true };
22
22
var solutionArg = new Arg("Solution", "", "string", "The solution file to use. If this argument is omitted, the command searches the current directory for one. If it finds no solution file or multiple solution files, the command fails.") { IsProject = true };
23
23
var propsArg = new Arg("Props", "--property", "IEnumerable<(string name, string value)>", "MSBuild options for setting properties.") { IsCollection = true };
@@ -85,7 +85,7 @@ using Internal;
85
85
new Arg("ListRuntimes", "--list-runtimes", "bool?", "Prints out a list of the installed .NET runtimes. An x86 version of the SDK lists only x86 runtimes, and an x64 version of the SDK lists only x64 runtimes."),
86
86
new Arg("ListSdks", "--list-sdks", "bool?", "Prints out a list of the installed .NET SDKs.")
87
87
]
88
-
),
88
+
) { Example = "DotNetScenario.cs.md" },
89
89
new(
90
90
"DotNetExec",
91
91
"Executes a dotnet application.",
@@ -106,7 +106,7 @@ using Internal;
106
106
new Arg("RuntimeConfig", "--runtimeconfig", "string", "Path to a runtimeconfig.json file. A runtimeconfig.json file contains run-time settings and is typically named <applicationname>.runtimeconfig.json."),
107
107
diagnosticsArg
108
108
]
109
-
),
109
+
) { Example = "DotNetExecScenario.cs.md" },
110
110
new(
111
111
"DotNetAddPackage",
112
112
"Adds or updates a package reference in a project file.",
@@ -229,15 +229,6 @@ using Internal;
229
229
paraStart,
230
230
"For executable projects targeting .NET Core 3.0 and later, library dependencies are copied to the output folder. This means that if there isn't any other publish-specific logic (such as Web projects have), the build output should be deployable.",
"new DotNetBuild().WithConfiguration(configuration)",
238
-
" .Build().EnsureSuccess();",
239
-
codeFinish,
240
-
exampleFinish,
241
232
CreateCliRef("dotnet-build")
242
233
],
243
234
["build", "$Project"],
@@ -267,7 +258,7 @@ using Internal;
267
258
diagnosticsArg
268
259
],
269
260
CommandTypes.Build
270
-
),
261
+
) { Example = "DotNetBuildScenario.cs.md" },
271
262
new(
272
263
"DotNetBuildServerShutdown",
273
264
"Shuts down build servers that are started from dotnet.",
@@ -1088,19 +1079,6 @@ using Internal;
1088
1079
paraStart,
1089
1080
"To run the application, the dotnet run command resolves the dependencies of the application that are outside of the shared runtime from the NuGet cache. Because it uses cached dependencies, it's not recommended to use dotnet run to run applications in production. Instead, create a deployment using the dotnet publish command and deploy the published output.",
1090
1081
paraFinish,
1091
-
exampleStart,
1092
-
codeStart,
1093
-
"new DotNetNew()",
1094
-
" .WithTemplateName(\"console\")",
1095
-
" .WithName(\"MyApp\")",
1096
-
" .WithForce(true)",
1097
-
" .Run().EnsureSuccess();",
1098
-
"",
1099
-
"",
1100
-
"new DotNetRun().WithWorkingDirectory(\"MyApp\")",
1101
-
" .Build().EnsureSuccess();",
1102
-
codeFinish,
1103
-
exampleFinish,
1104
1082
CreateCliRef("dotnet-run")
1105
1083
],
1106
1084
["run"],
@@ -1122,7 +1100,7 @@ using Internal;
1122
1100
verbosityArg,
1123
1101
diagnosticsArg
1124
1102
]
1125
-
),
1103
+
) { Example = "DotNetRunScenario.cs.md" },
1126
1104
new(
1127
1105
"DotNetSdkCheck",
1128
1106
"Lists the latest available version of the .NET SDK and .NET Runtime, for each feature band.",
@@ -1636,6 +1614,32 @@ using Internal;
1636
1614
/// <#= comment #>
1637
1615
<#
1638
1616
}
1617
+
1618
+
if (!string.IsNullOrWhiteSpace(command.Example))
1619
+
{
1620
+
var exampleLines = File.ReadAllLines(Path.Combine("..", "CSharpInteractive.Tests", "UsageScenarios", command.Example));
1621
+
if (exampleLines.Length > 0)
1622
+
{
1623
+
#>
1624
+
/// <#= exampleStart #>
1625
+
///<#= codeStart #>
1626
+
<#
1627
+
var doc = new XmlDocument();
1628
+
foreach (var exampleLine in exampleLines.Select(i => i.TrimEnd()))
1629
+
{
1630
+
var node = doc.CreateElement("root");
1631
+
node.InnerText = exampleLine;
1632
+
var line = node.InnerXml;
1633
+
#>
1634
+
/// <#= line #>
1635
+
<#
1636
+
}
1637
+
#>
1638
+
///<#= codeFinish #>
1639
+
/// <#= exampleFinish #>
1640
+
<#
1641
+
}
1642
+
}
1639
1643
#>
1640
1644
/// </summary>
1641
1645
/// <param name="Args">Specifies the set of command line arguments to use when starting the tool.</param>
@@ -1869,5 +1873,6 @@ public partial record <#= command.Name #>(
1869
1873
public Arg[] Args { get; } = Args;
1870
1874
public CommandTypes CommandTypes { get; } = CommandTypes;
1871
1875
public string[] AdditionalArgs { get; } = AdditionalArgs;
0 commit comments