Skip to content

Support .NET 8.0 #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install .Net Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
include-prerelease: true
- name: Install dotnet-script
run: dotnet tool install dotnet-script --global
Expand All @@ -27,11 +28,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install .Net Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
include-prerelease: true
- name: Install dotnet-script
run: dotnet tool install dotnet-script --global
Expand All @@ -45,11 +47,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install .Net Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
include-prerelease: true
- name: Install dotnet-script
run: dotnet tool install dotnet-script --global
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestFeature"
}
}
4 changes: 2 additions & 2 deletions src/Dotnet.Script.Core/Dotnet.Script.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>A cross platform library allowing you to run C# (CSX) scripts with support for debugging and inline NuGet packages. Based on Roslyn.</Description>
<VersionPrefix>1.4.0</VersionPrefix>
<VersionPrefix>1.5.0</VersionPrefix>
<Authors>filipw</Authors>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
<AssemblyName>Dotnet.Script.Core</AssemblyName>
<PackageId>Dotnet.Script.Core</PackageId>
<PackageTags>script;csx;csharp;roslyn</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RepositoryUrl>https://github.com/dotnet-script/dotnet-script.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>script;csx;csharp;roslyn;nuget</PackageTags>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<Description>A MetadataReferenceResolver that allows inline nuget references to be specified in script(csx) files.</Description>
<Authors>dotnet-script</Authors>
<Company>dotnet-script</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RepositoryUrl>https://github.com/dotnet-script/dotnet-script.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>script;csx;csharp;roslyn;omnisharp</PackageTags>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<LangVersion>latest</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,16 @@ private static string GetProcessArchitecture()
private static string GetRuntimeIdentifier()
{
var platformIdentifier = GetPlatformIdentifier();

#if NET8_0
return $"{platformIdentifier}-{GetProcessArchitecture()}";
#endif

if (platformIdentifier == "osx" || platformIdentifier == "linux")
{
return $"{platformIdentifier}-{GetProcessArchitecture()}";
}

var runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier();
return runtimeIdentifier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<UseRidGraph>true</UseRidGraph>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Tests/Dotnet.Script.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>
Expand Down
3 changes: 1 addition & 2 deletions src/Dotnet.Script.Tests/InteractiveRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public async Task ShouldCompileAndExecuteWithWebSdk()
{
@"#r ""sdk:Microsoft.NET.Sdk.Web""",
"using Microsoft.AspNetCore.Builder;",
"var a = WebApplication.Create();",
@"a.GetType()",
@"typeof(WebApplication)",
"#exit"
};

Expand Down
25 changes: 24 additions & 1 deletion src/Dotnet.Script.Tests/ScriptExecutionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using Dotnet.Script.DependencyModel.Environment;
using Dotnet.Script.Shared.Tests;
Expand Down Expand Up @@ -479,13 +481,34 @@ public void ShouldSetCurrentContextualReflectionContext()
Assert.Contains("Dotnet.Script.Core.ScriptAssemblyLoadContext", output);
}

#if NET6_0
[Fact]
public void ShouldCompileAndExecuteWithWebSdk()
{
var processResult = ScriptTestRunner.Default.ExecuteFixture("WebApiNet6", "--no-cache");
Assert.Equal(0, processResult.ExitCode);
}
#endif

#if NET7_0
[Fact]
public void ShouldCompileAndExecuteWithWebSdk()
{
var processResult = ScriptTestRunner.Default.ExecuteFixture("WebApi", "--no-cache");
Assert.Equal(0, processResult.ExitCode);
}

#endif

#if NET8_0
// .NET 8.0 only works with isolated load context
[Fact]
public void ShouldCompileAndExecuteWithWebSdk()
{
var processResult = ScriptTestRunner.Default.ExecuteFixture("WebApi", "--no-cache --isolated-load-context");
Assert.Equal(0, processResult.ExitCode);
}
#endif

[Fact]
public void ShouldThrowExceptionWhenSdkIsNotSupported()
{
Expand Down
4 changes: 4 additions & 0 deletions src/Dotnet.Script.Tests/ScriptPublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public void SimplePublishTest()
public void SimplePublishTestToDifferentRuntimeId()
{
using var workspaceFolder = new DisposableFolder();
#if NET8_0
var runtimeId = _scriptEnvironment.RuntimeIdentifier == "win-x64" ? "osx-x64" : "win10-x64";
#else
var runtimeId = _scriptEnvironment.RuntimeIdentifier == "win10-x64" ? "osx-x64" : "win10-x64";
#endif
var code = @"WriteLine(""hello world"");";
var mainPath = Path.Combine(workspaceFolder.Path, "main.csx");
File.WriteAllText(mainPath, code);
Expand Down
7 changes: 5 additions & 2 deletions src/Dotnet.Script.Tests/TestFixtures/WebApi/WebApi.csx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#r "sdk:Microsoft.NET.Sdk.Web"
#r "nuget:Microsoft.Extensions.DependencyInjection.Abstractions, 8.0.0-rc.2.23479.6"

using Microsoft.AspNetCore.Builder;

var a = WebApplication.Create();
a.MapGet("/", () => "Hello world");
var builder = WebApplication.CreateBuilder();
var app = builder.Build();

app.MapGet("/", () => "Hello World!");
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#r "sdk:Microsoft.NET.Sdk.Web"

using Microsoft.AspNetCore.Builder;

var a = WebApplication.Create();
a.MapGet("/", () => "Hello world");
4 changes: 2 additions & 2 deletions src/Dotnet.Script/Dotnet.Script.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Dotnet CLI tool allowing you to run C# (CSX) scripts.</Description>
<VersionPrefix>1.4.0</VersionPrefix>
<VersionPrefix>1.5.0</VersionPrefix>
<Authors>filipw</Authors>
<PackageId>Dotnet.Script</PackageId>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>dotnet-script</AssemblyName>
<OutputType>Exe</OutputType>
Expand Down