Skip to content

Commit 002b66f

Browse files
Support for .NET SDK 9
2 parents a2848db + 58e7a87 commit 002b66f

22 files changed

+961
-1677
lines changed

Build/Build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>$(Framework)</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<IsPackable>false</IsPackable>

Build/Program.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
const string packageId = "CSharpInteractive";
99
const string toolPackageId = "dotnet-csi";
1010
const string templatesPackageId = "CSharpInteractive.Templates";
11-
var frameworks = new[] {"net6.0", "net7.0", "net8.0", "net9.0"};
1211

1312
var currentDir = Environment.CurrentDirectory;
1413
if (!File.Exists(solutionFile))
@@ -40,6 +39,19 @@
4039

4140
Info(packageVersion.ToString());
4241

42+
const int minSdk = 6;
43+
var maxSdk = minSdk;
44+
new DotNet().WithVersion(true)
45+
.Run(output => maxSdk = NuGetVersion.Parse(output.Line).Major)
46+
.EnsureSuccess();
47+
48+
var allFrameworks = Enumerable.Range(6, maxSdk - minSdk + 1).Select(i => $"net{i}.0").ToArray();
49+
var frameworks = string.Join(";", allFrameworks);
50+
var framework = $"net{maxSdk}.0";
51+
52+
Info($"frameworks: {frameworks}");
53+
Info($"framework: {framework}");
54+
4355
var packages = new[]
4456
{
4557
new PackageInfo(
@@ -226,9 +238,9 @@
226238
.AddSources(templateOutputDir)
227239
.Run().EnsureSuccess();
228240

229-
foreach (var framework in frameworks)
241+
foreach (var checkingFramework in allFrameworks)
230242
{
231-
CheckCompatibilityAsync(framework, packageVersion, defaultNuGetSource, outputDir);
243+
CheckCompatibilityAsync(checkingFramework, packageVersion, defaultNuGetSource, outputDir);
232244
}
233245

234246
if (!skipTests && (integrationTests || dockerLinuxTests))
@@ -263,7 +275,7 @@
263275
return 0;
264276

265277
void CheckCompatibilityAsync(
266-
string framework,
278+
string checkingFramework,
267279
NuGetVersion nuGetVersion,
268280
string nuGetSource,
269281
string output)
@@ -276,7 +288,7 @@ void CheckCompatibilityAsync(
276288
new DotNetNew()
277289
.WithTemplateName("build")
278290
.WithNoRestore(true)
279-
.WithArgs($"--version={nuGetVersion}", "-T", framework)
291+
.WithArgs($"--version={nuGetVersion}", "-T", checkingFramework)
280292
.WithWorkingDirectory(buildProjectDir)
281293
.Run().EnsureSuccess();
282294

@@ -289,7 +301,7 @@ void CheckCompatibilityAsync(
289301
.WithWorkingDirectory(buildProjectDir)
290302
.WithNoRestore(true)
291303
.WithNoBuild(true)
292-
.WithFramework(framework)
304+
.WithFramework(checkingFramework)
293305
.Run().EnsureSuccess();
294306

295307
new DotNetCsi()

CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,21 @@ public static CommandLine AddProps(this CommandLine cmd, string propertyName, pa
145145
// ReSharper disable once UnusedParameter.Global
146146
public static string[] ToArgs<T>(this T value, string name, string collectionSeparator)
147147
{
148+
var valueStr = value?.ToString();
149+
if (string.IsNullOrWhiteSpace(valueStr))
150+
{
151+
return [];
152+
}
153+
148154
if (!string.IsNullOrWhiteSpace(collectionSeparator))
149155
{
150156
return [$"{name}{collectionSeparator}{value}"];
151157
}
152158

153-
var valueStr = value?.ToString();
154-
return string.IsNullOrWhiteSpace(valueStr) ? [] : [name, valueStr!];
159+
return [name, valueStr!];
155160
}
156161

157-
public static string[] ToArgs<T>(this IEnumerable<(string name, T value) > values, string name, string separator)
162+
public static string[] ToArgs<T>(this IEnumerable<(string name, T value)> values, string name, string separator)
158163
{
159164
return values.SelectMany(i => new [] { name, $"{i.name}{separator}{i.value}"}).ToArray();
160165
}

CSharpInteractive.Tests/CSharpInteractive.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;$(Framework)</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<DefineConstants>$(DefineConstants);PUREDI_API_SUPPRESSION</DefineConstants>

CSharpInteractive.Tests/Integration/TeamCityScriptRunTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@ public void ShouldSendBuildProblemWhenScripIsUncompleted()
126126
result.ExitCode.ShouldBe(1);
127127
result.StdErr.ShouldBeEmpty();
128128
var messages = result.StdOut.ParseMessages();
129-
messages.ShouldContainBuildProblem(i => i.Contains("; expected"), i => i.Contains("CS1002"));
129+
messages.ShouldContainBuildProblem(i => i.Contains("script.csx(1,9): error CS1002"), i => i.Contains("CS1002"));
130130
}
131131
}

0 commit comments

Comments
 (0)