Skip to content

Commit 71c8b7f

Browse files
Improved build
1 parent 2727421 commit 71c8b7f

File tree

3 files changed

+48
-44
lines changed

3 files changed

+48
-44
lines changed

Build/Program.cs

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -215,43 +215,8 @@
215215
.WithShortName("Installing template");
216216

217217
installTemplates.WithShortName(installTemplates.ShortName).Run().EnsureSuccess();
218-
219-
foreach (var framework in frameworks)
220-
{
221-
var buildProjectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]);
222-
Directory.CreateDirectory(buildProjectDir);
223-
var sampleProjectName = $"sample project for {framework}";
224-
try
225-
{
226-
var sampleProjectDir = Path.Combine("Samples", "MySampleLib", "MySampleLib.Tests");
227-
new DotNetNew("build", $"--version={packageVersion}", "-T", framework, "--no-restore")
228-
.WithWorkingDirectory(buildProjectDir)
229-
.WithShortName($"Creating a new {sampleProjectName}")
230-
.Run().EnsureSuccess();
231-
232-
new DotNetBuild()
233-
.WithProject(buildProjectDir)
234-
.WithSources(defaultNuGetSource, Path.Combine(outputDir, "CSharpInteractive"))
235-
.WithShortName($"Building the {sampleProjectName}")
236-
.Build().EnsureSuccess();
237-
238-
new DotNetRun()
239-
.WithProject(buildProjectDir)
240-
.WithNoBuild(true)
241-
.WithWorkingDirectory(sampleProjectDir)
242-
.WithShortName($"Running a build for the {sampleProjectName}")
243-
.Run().EnsureSuccess();
244-
245-
new DotNetCustom("csi", Path.Combine(buildProjectDir, "Program.csx"))
246-
.WithWorkingDirectory(sampleProjectDir)
247-
.WithShortName($"Running a build as a C# script for the {sampleProjectName}")
248-
.Run().EnsureSuccess();
249-
}
250-
finally
251-
{
252-
Directory.Delete(buildProjectDir, true);
253-
}
254-
}
218+
await Task.WhenAll(
219+
frameworks.Select(framework => CheckCompatibilityAsync(framework, packageVersion, defaultNuGetSource, outputDir)));
255220

256221
if (!string.IsNullOrWhiteSpace(apiKey) && packageVersion.Release != "dev" && packageVersion.Release != "dev")
257222
{
@@ -290,4 +255,45 @@
290255

291256
return 0;
292257

258+
async Task CheckCompatibilityAsync(
259+
string framework,
260+
NuGetVersion nuGetVersion,
261+
string nuGetSource,
262+
string output)
263+
{
264+
var buildProjectDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()[..4]);
265+
Directory.CreateDirectory(buildProjectDir);
266+
var sampleProjectName = $"sample project for {framework}";
267+
try
268+
{
269+
var sampleProjectDir = Path.Combine("Samples", "MySampleLib", "MySampleLib.Tests");
270+
await new DotNetNew("build", $"--version={nuGetVersion}", "-T", framework, "--no-restore")
271+
.WithWorkingDirectory(buildProjectDir)
272+
.WithShortName($"Creating a new {sampleProjectName}")
273+
.RunAsync().EnsureSuccess();
274+
275+
await new DotNetBuild()
276+
.WithProject(buildProjectDir)
277+
.WithSources(nuGetSource, Path.Combine(output, "CSharpInteractive"))
278+
.WithShortName($"Building the {sampleProjectName}")
279+
.BuildAsync().EnsureSuccess();
280+
281+
await new DotNetRun()
282+
.WithProject(buildProjectDir)
283+
.WithNoBuild(true)
284+
.WithWorkingDirectory(sampleProjectDir)
285+
.WithShortName($"Running a build for the {sampleProjectName}")
286+
.RunAsync().EnsureSuccess();
287+
288+
await new DotNetCustom("csi", Path.Combine(buildProjectDir, "Program.csx"))
289+
.WithWorkingDirectory(sampleProjectDir)
290+
.WithShortName($"Running a build as a C# script for the {sampleProjectName}")
291+
.RunAsync().EnsureSuccess();
292+
}
293+
finally
294+
{
295+
Directory.Delete(buildProjectDir, true);
296+
}
297+
}
298+
293299
internal record PackageInfo(string Id, string Package, bool Publish);

CSharpInteractive.HostApi/BuildMessage.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ public record BuildMessage(
4242
int? EndLineNumber = default,
4343
DotNetMessageImportance? Importance = default)
4444
{
45-
private readonly Lazy<TestResult?> _testResult = new(() =>
46-
ServiceMessage != null && TryGetTestState(ServiceMessage.Name, out var testState)
47-
? CreateResult(CreateKey(ServiceMessage), ServiceMessage, testState)
48-
: default(TestResult?));
49-
5045
/// <summary>
5146
/// Contains the result of test execution when <see cref="State"/> is set to <see cref="BuildMessageState.TestResult"/>.
5247
/// </summary>
53-
public TestResult? TestResult => _testResult.Value;
48+
public TestResult? TestResult =>
49+
ServiceMessage != null && TryGetTestState(ServiceMessage.Name, out var testState)
50+
? CreateResult(CreateKey(ServiceMessage), ServiceMessage, testState)
51+
: default(TestResult?);
5452

5553
/// <inheritdoc />
5654
public override string ToString() => Text;

CSharpInteractive/Core/BuildOutputProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public IEnumerable<BuildMessage> Convert(Output output, IBuildContext context)
1212
foreach (var message in serviceMessageParser.ParseServiceMessages(output.Line).Where(message => message != default))
1313
{
1414
var buildMessage = new BuildMessage(output, BuildMessageState.ServiceMessage, message);
15-
if (buildMessage.TestResult is not null)
15+
if (buildMessage.TestResult.HasValue)
1616
{
1717
buildMessage = buildMessage.WithState(BuildMessageState.TestResult);
1818
}

0 commit comments

Comments
 (0)