Skip to content

Commit 3d6fa49

Browse files
authored
Merge pull request #740 from dotnet-script/feature/net8
Support .NET 8.0
2 parents 129488f + a44d71f commit 3d6fa49

File tree

14 files changed

+61
-16
lines changed

14 files changed

+61
-16
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v3
1111
- name: Install .Net Core
12-
uses: actions/setup-dotnet@v2
12+
uses: actions/setup-dotnet@v3
1313
with:
1414
dotnet-version: |
1515
6.0.x
1616
7.0.x
17+
8.0.x
1718
include-prerelease: true
1819
- name: Install dotnet-script
1920
run: dotnet tool install dotnet-script --global
@@ -27,11 +28,12 @@ jobs:
2728
steps:
2829
- uses: actions/checkout@v3
2930
- name: Install .Net Core
30-
uses: actions/setup-dotnet@v2
31+
uses: actions/setup-dotnet@v3
3132
with:
3233
dotnet-version: |
3334
6.0.x
3435
7.0.x
36+
8.0.x
3537
include-prerelease: true
3638
- name: Install dotnet-script
3739
run: dotnet tool install dotnet-script --global
@@ -45,11 +47,12 @@ jobs:
4547
steps:
4648
- uses: actions/checkout@v3
4749
- name: Install .Net Core
48-
uses: actions/setup-dotnet@v2
50+
uses: actions/setup-dotnet@v3
4951
with:
5052
dotnet-version: |
5153
6.0.x
5254
7.0.x
55+
8.0.x
5356
include-prerelease: true
5457
- name: Install dotnet-script
5558
run: dotnet tool install dotnet-script --global

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.100",
3+
"version": "8.0.100-rc.2.23502.2",
44
"rollForward": "latestFeature"
55
}
66
}

src/Dotnet.Script.Core/Dotnet.Script.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<Description>A cross platform library allowing you to run C# (CSX) scripts with support for debugging and inline NuGet packages. Based on Roslyn.</Description>
5-
<VersionPrefix>1.4.0</VersionPrefix>
5+
<VersionPrefix>1.5.0</VersionPrefix>
66
<Authors>filipw</Authors>
7-
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
7+
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
88
<AssemblyName>Dotnet.Script.Core</AssemblyName>
99
<PackageId>Dotnet.Script.Core</PackageId>
1010
<PackageTags>script;csx;csharp;roslyn</PackageTags>

src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<RepositoryUrl>https://github.com/dotnet-script/dotnet-script.git</RepositoryUrl>
99
<RepositoryType>git</RepositoryType>
1010
<PackageTags>script;csx;csharp;roslyn;nuget</PackageTags>
11-
<Version>1.4.0</Version>
11+
<Version>1.5.0</Version>
1212
<Description>A MetadataReferenceResolver that allows inline nuget references to be specified in script(csx) files.</Description>
1313
<Authors>dotnet-script</Authors>
1414
<Company>dotnet-script</Company>

src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<RepositoryUrl>https://github.com/dotnet-script/dotnet-script.git</RepositoryUrl>
1212
<RepositoryType>git</RepositoryType>
1313
<PackageTags>script;csx;csharp;roslyn;omnisharp</PackageTags>
14-
<Version>1.4.0</Version>
14+
<Version>1.5.0</Version>
1515
<LangVersion>latest</LangVersion>
1616
<SignAssembly>true</SignAssembly>
1717
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>

src/Dotnet.Script.DependencyModel/Environment/ScriptEnvironment.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,16 @@ private static string GetProcessArchitecture()
133133
private static string GetRuntimeIdentifier()
134134
{
135135
var platformIdentifier = GetPlatformIdentifier();
136+
137+
#if NET8_0
138+
return $"{platformIdentifier}-{GetProcessArchitecture()}";
139+
#endif
140+
136141
if (platformIdentifier == "osx" || platformIdentifier == "linux")
137142
{
138143
return $"{platformIdentifier}-{GetProcessArchitecture()}";
139144
}
145+
140146
var runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier();
141147
return runtimeIdentifier;
142148
}

src/Dotnet.Script.DependencyModel/ProjectSystem/csproj.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<OutputType>Exe</OutputType>
44
<TargetFramework>net5.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
6+
<UseRidGraph>true</UseRidGraph>
67
</PropertyGroup>
78
<ItemGroup>
89
</ItemGroup>

src/Dotnet.Script.Tests/Dotnet.Script.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
44
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>

src/Dotnet.Script.Tests/InteractiveRunnerTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public async Task ShouldCompileAndExecuteWithWebSdk()
1919
{
2020
@"#r ""sdk:Microsoft.NET.Sdk.Web""",
2121
"using Microsoft.AspNetCore.Builder;",
22-
"var a = WebApplication.Create();",
23-
@"a.GetType()",
22+
@"typeof(WebApplication)",
2423
"#exit"
2524
};
2625

src/Dotnet.Script.Tests/ScriptExecutionTests.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.IO;
3+
using System.Reflection;
4+
using System.Runtime.InteropServices;
35
using System.Text;
46
using Dotnet.Script.DependencyModel.Environment;
57
using Dotnet.Script.Shared.Tests;
@@ -479,13 +481,34 @@ public void ShouldSetCurrentContextualReflectionContext()
479481
Assert.Contains("Dotnet.Script.Core.ScriptAssemblyLoadContext", output);
480482
}
481483

484+
#if NET6_0
485+
[Fact]
486+
public void ShouldCompileAndExecuteWithWebSdk()
487+
{
488+
var processResult = ScriptTestRunner.Default.ExecuteFixture("WebApiNet6", "--no-cache");
489+
Assert.Equal(0, processResult.ExitCode);
490+
}
491+
#endif
492+
493+
#if NET7_0
482494
[Fact]
483495
public void ShouldCompileAndExecuteWithWebSdk()
484496
{
485497
var processResult = ScriptTestRunner.Default.ExecuteFixture("WebApi", "--no-cache");
486498
Assert.Equal(0, processResult.ExitCode);
487499
}
488-
500+
#endif
501+
502+
#if NET8_0
503+
// .NET 8.0 only works with isolated load context
504+
[Fact]
505+
public void ShouldCompileAndExecuteWithWebSdk()
506+
{
507+
var processResult = ScriptTestRunner.Default.ExecuteFixture("WebApi", "--no-cache --isolated-load-context");
508+
Assert.Equal(0, processResult.ExitCode);
509+
}
510+
#endif
511+
489512
[Fact]
490513
public void ShouldThrowExceptionWhenSdkIsNotSupported()
491514
{

src/Dotnet.Script.Tests/ScriptPublisherTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public void SimplePublishTest()
4949
public void SimplePublishTestToDifferentRuntimeId()
5050
{
5151
using var workspaceFolder = new DisposableFolder();
52+
#if NET8_0
53+
var runtimeId = _scriptEnvironment.RuntimeIdentifier == "win-x64" ? "osx-x64" : "win10-x64";
54+
#else
5255
var runtimeId = _scriptEnvironment.RuntimeIdentifier == "win10-x64" ? "osx-x64" : "win10-x64";
56+
#endif
5357
var code = @"WriteLine(""hello world"");";
5458
var mainPath = Path.Combine(workspaceFolder.Path, "main.csx");
5559
File.WriteAllText(mainPath, code);
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#r "sdk:Microsoft.NET.Sdk.Web"
2+
#r "nuget:Microsoft.Extensions.DependencyInjection.Abstractions, 8.0.0-rc.2.23479.6"
23

34
using Microsoft.AspNetCore.Builder;
45

5-
var a = WebApplication.Create();
6-
a.MapGet("/", () => "Hello world");
6+
var builder = WebApplication.CreateBuilder();
7+
var app = builder.Build();
8+
9+
app.MapGet("/", () => "Hello World!");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#r "sdk:Microsoft.NET.Sdk.Web"
2+
3+
using Microsoft.AspNetCore.Builder;
4+
5+
var a = WebApplication.Create();
6+
a.MapGet("/", () => "Hello world");

src/Dotnet.Script/Dotnet.Script.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<Description>Dotnet CLI tool allowing you to run C# (CSX) scripts.</Description>
5-
<VersionPrefix>1.4.0</VersionPrefix>
5+
<VersionPrefix>1.5.0</VersionPrefix>
66
<Authors>filipw</Authors>
77
<PackageId>Dotnet.Script</PackageId>
8-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
8+
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
99
<DebugType>portable</DebugType>
1010
<AssemblyName>dotnet-script</AssemblyName>
1111
<OutputType>Exe</OutputType>

0 commit comments

Comments
 (0)