Skip to content

Commit 58ab487

Browse files
DotNet command template
1 parent ec2a4e2 commit 58ab487

File tree

219 files changed

+18402
-2190
lines changed

Some content is hidden

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

219 files changed

+18402
-2190
lines changed

.run/Get version.run.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Get version" type="DotNetProject" factoryName=".NET Project" folderName="Scripts">
3+
<option name="EXE_PATH" value="$PROJECT_DIR$/CSharpInteractive/bin/Debug/CSharpInteractive.Tool/net8.0/dotnet-csi.dll" />
4+
<option name="PROGRAM_PARAMETERS" value="--version" />
5+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Samples/Scripts" />
6+
<option name="PASS_PARENT_ENVS" value="1" />
7+
<option name="USE_EXTERNAL_CONSOLE" value="0" />
8+
<option name="USE_MONO" value="0" />
9+
<option name="RUNTIME_ARGUMENTS" value="" />
10+
<option name="PROJECT_PATH" value="$PROJECT_DIR$/CSharpInteractive/CSharpInteractive.Tool.csproj" />
11+
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
12+
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
13+
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="0" />
14+
<option name="PROJECT_KIND" value="DotNetCore" />
15+
<option name="PROJECT_TFM" value="net8.0" />
16+
<method v="2">
17+
<option name="Build" />
18+
</method>
19+
</configuration>
20+
</component>

Build/Program.cs

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
false)
5959
};
6060

61-
new DotNetToolRestore().WithShortName("Restoring tools").Run().EnsureSuccess();
61+
new DotNetToolRestore().Run().EnsureSuccess();
6262

6363
new DotNetClean()
6464
.WithProject(solutionFile)
@@ -173,8 +173,9 @@
173173
}
174174
}
175175

176-
var uninstallTool = new DotNetCustom("tool", "uninstall", toolPackageId, "-g")
177-
.WithShortName("Uninstalling tool");
176+
var uninstallTool = new DotNetToolUninstall()
177+
.WithPackage(toolPackageId)
178+
.WithGlobal(true);
178179

179180
if (uninstallTool.Run(_ => { }).ExitCode != 0)
180181
{
@@ -191,42 +192,49 @@
191192
Environment.SetEnvironmentVariable("PATH", pathEnvVar);
192193
}
193194

194-
var installTool = new DotNetCustom("tool", "install", toolPackageId, "-g", "--version", packageVersion.ToString(), "--add-source", Path.Combine(outputDir, "CSharpInteractive.Tool"))
195-
.WithShortName("Installing tool");
195+
await new DotNetBuild()
196+
.WithProject(Path.Combine("Samples", "MySampleLib"))
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"));
196204

197205
installTool.Run(output =>
198206
{
199207
output.Handled = true;
200208
WriteLine(output.Line);
201209
}).EnsureSuccess(_ => true);
202210

203-
new DotNetCustom("csi", "/?").WithShortName("Checking tool").Run().EnsureSuccess();
211+
new DotNetCsi().WithVersion(true).WithShortName("Checking csi tool").Run().EnsureSuccess();
204212

205-
var uninstallTemplates = new DotNetCustom("new", "uninstall", templatesPackageId)
206-
.WithShortName("Uninstalling template");
213+
var uninstallTemplates = new DotNetNewUninstall()
214+
.WithPackage(templatesPackageId);
207215

208216
uninstallTemplates.Run(output =>
209217
{
210218
output.Handled = true;
211219
WriteLine(output.Line);
212220
}).EnsureSuccess(_ => true);
213221

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

217-
installTemplates.WithShortName(installTemplates.ShortName).Run().EnsureSuccess();
226+
installTemplates.Run().EnsureSuccess();
218227
foreach (var framework in frameworks)
219228
{
220229
await CheckCompatibilityAsync(framework, packageVersion, defaultNuGetSource, outputDir);
221230
}
222231

223232
if (!string.IsNullOrWhiteSpace(apiKey) && packageVersion.Release != "dev" && packageVersion.Release != "dev")
224233
{
225-
var push = new DotNetNuGetPush().WithApiKey(apiKey).WithSources(defaultNuGetSource);
234+
var push = new DotNetNuGetPush().WithApiKey(apiKey).WithSource(defaultNuGetSource);
226235
foreach (var package in packages.Where(i => i.Publish))
227236
{
228237
push.WithPackage(package.Package)
229-
.WithShortName($"Pushing {Path.GetFileName(package.Package)}")
230238
.Build().EnsureSuccess();
231239
}
232240
}
@@ -269,27 +277,28 @@ async Task CheckCompatibilityAsync(
269277
try
270278
{
271279
var sampleProjectDir = Path.Combine("Samples", "MySampleLib", "MySampleLib.Tests");
272-
await new DotNetNew("build", $"--version={nuGetVersion}", "-T", framework, "--no-restore")
280+
await new DotNetNew()
281+
.WithTemplateName("build")
282+
.WithNoRestore(true)
283+
.WithArgs($"--version={nuGetVersion}", "-T", framework)
273284
.WithWorkingDirectory(buildProjectDir)
274-
.WithShortName($"Creating a new {sampleProjectName}")
275285
.RunAsync().EnsureSuccess();
276286

277287
await new DotNetBuild()
278288
.WithProject(buildProjectDir)
279289
.WithSources(nuGetSource, Path.Combine(output, "CSharpInteractive"))
280-
.WithShortName($"Building the {sampleProjectName}")
281290
.BuildAsync().EnsureSuccess();
282291

283292
await new DotNetRun()
284-
.WithProject(buildProjectDir)
293+
.WithWorkingDirectory(buildProjectDir)
294+
.WithNoRestore(true)
285295
.WithNoBuild(true)
286-
.WithWorkingDirectory(sampleProjectDir)
287-
.WithShortName($"Running a build for the {sampleProjectName}")
296+
.WithFramework(framework)
288297
.RunAsync().EnsureSuccess();
289298

290-
await new DotNetCustom("csi", Path.Combine(buildProjectDir, "Program.csx"))
299+
await new DotNetCsi()
300+
.WithScript(Path.Combine(buildProjectDir, "Program.csx"))
291301
.WithWorkingDirectory(sampleProjectDir)
292-
.WithShortName($"Running a build as a C# script for the {sampleProjectName}")
293302
.RunAsync().EnsureSuccess();
294303
}
295304
finally

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

0 commit comments

Comments
 (0)