Skip to content

Commit ba6226d

Browse files
Use DotNet command template
1 parent ec2a4e2 commit ba6226d

File tree

78 files changed

+12404
-1426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+12404
-1426
lines changed

Build/Program.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,16 @@
191191
Environment.SetEnvironmentVariable("PATH", pathEnvVar);
192192
}
193193

194-
var installTool = new DotNetCustom("tool", "install", toolPackageId, "-g", "--version", packageVersion.ToString(), "--add-source", Path.Combine(outputDir, "CSharpInteractive.Tool"))
194+
await new DotNetBuild()
195+
.WithProject(Path.Combine("Samples", "MySampleLib"))
196+
.WithShortName($"Building sample")
197+
.BuildAsync().EnsureSuccess();
198+
199+
var installTool = new DotNetToolInstall()
200+
.WithPackage(toolPackageId)
201+
.WithGlobal(true)
202+
.WithVersion(packageVersion.ToString())
203+
.AddSources(Path.Combine(outputDir, "CSharpInteractive.Tool"))
195204
.WithShortName("Installing tool");
196205

197206
installTool.Run(output =>
@@ -202,7 +211,8 @@
202211

203212
new DotNetCustom("csi", "/?").WithShortName("Checking tool").Run().EnsureSuccess();
204213

205-
var uninstallTemplates = new DotNetCustom("new", "uninstall", templatesPackageId)
214+
var uninstallTemplates = new DotNetNewUninstall()
215+
.WithPackage(templatesPackageId)
206216
.WithShortName("Uninstalling template");
207217

208218
uninstallTemplates.Run(output =>
@@ -211,7 +221,9 @@
211221
WriteLine(output.Line);
212222
}).EnsureSuccess(_ => true);
213223

214-
var installTemplates = new DotNetCustom("new", "install", $"{templatesPackageId}::{packageVersion.ToString()}", "--nuget-source", templateOutputDir)
224+
var installTemplates = new DotNetNewInstall()
225+
.WithPackage($"{templatesPackageId}::{packageVersion.ToString()}")
226+
.AddSources(templateOutputDir)
215227
.WithShortName("Installing template");
216228

217229
installTemplates.WithShortName(installTemplates.ShortName).Run().EnsureSuccess();
@@ -222,7 +234,7 @@
222234

223235
if (!string.IsNullOrWhiteSpace(apiKey) && packageVersion.Release != "dev" && packageVersion.Release != "dev")
224236
{
225-
var push = new DotNetNuGetPush().WithApiKey(apiKey).WithSources(defaultNuGetSource);
237+
var push = new DotNetNuGetPush().WithApiKey(apiKey).WithSource(defaultNuGetSource);
226238
foreach (var package in packages.Where(i => i.Publish))
227239
{
228240
push.WithPackage(package.Package)
@@ -269,7 +281,10 @@ async Task CheckCompatibilityAsync(
269281
try
270282
{
271283
var sampleProjectDir = Path.Combine("Samples", "MySampleLib", "MySampleLib.Tests");
272-
await new DotNetNew("build", $"--version={nuGetVersion}", "-T", framework, "--no-restore")
284+
await new DotNetNew()
285+
.WithTemplateName("build")
286+
.WithNoRestore(true)
287+
.WithArgs($"--version={nuGetVersion}", "-T", framework)
273288
.WithWorkingDirectory(buildProjectDir)
274289
.WithShortName($"Creating a new {sampleProjectName}")
275290
.RunAsync().EnsureSuccess();
@@ -281,9 +296,10 @@ async Task CheckCompatibilityAsync(
281296
.BuildAsync().EnsureSuccess();
282297

283298
await new DotNetRun()
284-
.WithProject(buildProjectDir)
299+
.WithWorkingDirectory(buildProjectDir)
300+
.WithNoRestore(true)
285301
.WithNoBuild(true)
286-
.WithWorkingDirectory(sampleProjectDir)
302+
.WithFramework(framework)
287303
.WithShortName($"Running a build for the {sampleProjectName}")
288304
.RunAsync().EnsureSuccess();
289305

CSharpInteractive.HostApi/CSharpInteractive.HostApi.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,20 @@
3030
</None>
3131

3232
<Compile Update="CommandLines.cs">
33-
<DesignTime>True</DesignTime>
3433
<AutoGen>True</AutoGen>
34+
<DesignTime>True</DesignTime>
3535
<DependentUpon>CommandLines.tt</DependentUpon>
3636
</Compile>
3737

38-
<Compile Update="CommandLines.cs">
38+
<None Update="DotNetCommands.tt">
39+
<LastGenOutput>DotNetCommands.cs</LastGenOutput>
40+
<Generator>TextTemplatingFileGenerator</Generator>
41+
</None>
42+
43+
<Compile Update="DotNetCommands.cs">
3944
<AutoGen>True</AutoGen>
4045
<DesignTime>True</DesignTime>
41-
<DependentUpon>CommandLines.tt</DependentUpon>
46+
<DependentUpon>DotNetCommands.tt</DependentUpon>
4247
</Compile>
4348
</ItemGroup>
4449

CSharpInteractive.HostApi/CommandLines.cs

Lines changed: 4130 additions & 118 deletions
Large diffs are not rendered by default.

CSharpInteractive.HostApi/CommandLines.tt

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,85 @@
11
// ReSharper disable InconsistentNaming
22
namespace HostApi;
3-
3+
44
<#
55
var commandLineTypes = new[]
66
{
77
"CommandLine",
88

99
// Dotnet
10+
"DotNetCustom",
11+
"DotNet",
12+
"DotNetExec",
13+
"DotNetAddPackage",
14+
"DotNetListPackage",
15+
"DotNetRemovePackage",
16+
"DotNetAddReference",
17+
"DotNetListReference",
18+
"DotNetRemoveReference",
1019
"DotNetBuild",
1120
"DotNetBuildServerShutdown",
1221
"DotNetClean",
13-
"DotNetCustom",
22+
"DotNetDevCertsHttps",
23+
"MSBuild",
1424
"DotNetNew",
25+
"DotNetNewList",
26+
"DotNetNewSearch",
27+
"DotNetNewDetails",
28+
"DotNetNewInstall",
29+
"DotNetNewUninstall",
30+
"DotNetNewUpdate",
31+
"DotNetNuGetDelete",
32+
"DotNetNuGetLocalsClear",
33+
"DotNetNuGetLocalsList",
1534
"DotNetNuGetPush",
35+
"DotNetNuGetAddSource",
36+
"DotNetNuGetDisableSource",
37+
"DotNetNuGetEnableSource",
38+
"DotNetNuGetListSource",
39+
"DotNetNuGetRemoveSource",
40+
"DotNetNuGetUpdateSource",
41+
"DotNetNuGetVerify",
42+
"DotNetNuGetTrustList",
43+
"DotNetNuGetTrustSync",
44+
"DotNetNuGetTrustRemove",
45+
"DotNetNuGetTrustAuthor",
46+
"DotNetNuGetTrustRepository",
47+
"DotNetNuGetTrustCertificate",
48+
"DotNetNuGetTrustSource",
49+
"DotNetNuGetSign",
50+
"DotNetNuGetWhy",
51+
"DotNetNuConfigGet",
52+
"DotNetNuConfigSet",
53+
"DotNetNuConfigUnset",
54+
"DotNetNuConfigPaths",
55+
"DotNetPackageSearch",
1656
"DotNetPack",
1757
"DotNetPublish",
1858
"DotNetRestore",
1959
"DotNetRun",
60+
"DotNetSdkCheck",
61+
"DotNetSlnList",
62+
"DotNetSlnAdd",
63+
"DotNetSlnRemove",
64+
"DotNetStore",
2065
"DotNetTest",
66+
"DotNetToolInstall",
67+
"DotNetToolList",
2168
"DotNetToolRestore",
22-
"MSBuild",
69+
"DotNetToolRun",
70+
"DotNetToolSearch",
71+
"DotNetToolUninstall",
72+
"DotNetToolUpdate",
2373
"VSTest",
74+
"DotNetWorkload",
75+
"DotNetWorkloadConfig",
76+
"DotNetWorkloadInstall",
77+
"DotNetWorkloadList",
78+
"DotNetWorkloadRepair",
79+
"DotNetWorkloadRestore",
80+
"DotNetWorkloadSearch",
81+
"DotNetWorkloadUninstall",
82+
"DotNetWorkloadUpdate",
2483

2584
// Docker
2685
"DockerCustom",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace HostApi;
2+
3+
/// <summary>
4+
/// The type of dump.
5+
/// </summary>
6+
public enum DotNetBlameDumpType
7+
{
8+
/// <summary>
9+
/// None
10+
/// </summary>
11+
None,
12+
13+
/// <summary>
14+
/// Full
15+
/// </summary>
16+
Full,
17+
18+
/// <summary>
19+
/// Mini
20+
/// </summary>
21+
Mini
22+
}

CSharpInteractive.HostApi/DotNetBuild.cs

Lines changed: 0 additions & 115 deletions
This file was deleted.

CSharpInteractive.HostApi/DotNetBuildServer.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,17 @@ public enum DotNetBuildServer
2323
/// Razor build server
2424
/// </summary>
2525
Razor
26+
}
27+
28+
internal static class DotNetBuildServerExtensions
29+
{
30+
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
31+
public static string[] ToArgs(this IEnumerable<DotNetBuildServer> servers, string name, string collectionSeparator) =>
32+
servers.Select(server => server switch
33+
{
34+
DotNetBuildServer.MSBuild => "--msbuild",
35+
DotNetBuildServer.VbCsCompiler => "--vbcscompiler",
36+
DotNetBuildServer.Razor => "--razor",
37+
_ => throw new ArgumentOutOfRangeException()
38+
}).ToArray();
2639
}

0 commit comments

Comments
 (0)