Skip to content
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

Add net8.0 target framework #4502

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.100-rc.1.23463.5
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.100-rc.1.23463.5
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
Expand Down
9 changes: 9 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ steps:
performMultiLevelLookup: true
useGlobalJson: true

- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
packageType: 'sdk'
version: '8.0.100-rc.1.23463.5'
includePreviewVersions: true
performMultiLevelLookup: true
useGlobalJson: true

- task: CmdLine@2
displayName: 'Install DNT'
inputs:
Expand Down
6 changes: 6 additions & 0 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC

var newSteps = new List<GitHubActionsStep>(job.Steps);

// only need to list the ones that are missing from default image
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[]
{
"8.0.100-rc.1.23463.5"
}));

newSteps.Insert(0, new GitHubActionsUseGnuTarStep());
newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep());

Expand Down
3 changes: 2 additions & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void PublishConsoleProject(Project project, string[] targetFrameworks)

PublishConsoleProject(consoleX86Project, new[] { "net462" });
PublishConsoleProject(consoleProject, new[] { "net462" });
PublishConsoleProject(consoleCoreProject, new[] { "net6.0", "net7.0" });
PublishConsoleProject(consoleCoreProject, new[] { "net6.0", "net7.0", "net8.0" });

void CopyConsoleBinaries(AbsolutePath target)
{
Expand All @@ -250,6 +250,7 @@ void CopyConsoleBinaries(AbsolutePath target)
var consoleCoreDirectory = consoleCoreProject.Directory / "bin" / Configuration;
CopyDirectoryRecursively(consoleCoreDirectory / "net6.0" / "publish", target / "Net60");
CopyDirectoryRecursively(consoleCoreDirectory / "net7.0" / "publish", target / "Net70");
CopyDirectoryRecursively(consoleCoreDirectory / "net8.0" / "publish", target / "Net80");
}

Serilog.Log.Information("Copy published Console for NSwagStudio");
Expand Down
3 changes: 2 additions & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>

<ItemGroup>
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.1.23463.5",
"rollForward": "latestMinor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Condition="'$(TargetFramework)' == 'net6.0'">dotnet --roll-forward-on-no-candidate-fx 2 "$(NSwagDir_Net60)/dotnet-nswag.dll"</_NSwagCommand>
<_NSwagCommand
Condition="'$(TargetFramework)' == 'net7.0'">dotnet --roll-forward-on-no-candidate-fx 2 "$(NSwagDir_Net70)/dotnet-nswag.dll"</_NSwagCommand>
<_NSwagCommand
Condition="'$(TargetFramework)' == 'net8.0'">dotnet --roll-forward-on-no-candidate-fx 2 "$(NSwagDir_Net80)/dotnet-nswag.dll"</_NSwagCommand>
</PropertyGroup>

<!-- OpenApiReference support for C# -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task Invoke(HttpContext context)

var suffix = !string.IsNullOrWhiteSpace(_swaggerRoute) ? "?url=" + _transformToExternal(_swaggerRoute, context.Request) : "";
var path = _transformToExternal(_swaggerUiRoute, context.Request);
context.Response.Headers.Add("Location", (path != "/" ? path : "") + "/index.html" + suffix);
context.Response.Headers.Append("Location", (path != "/" ? path : "") + "/index.html" + suffix);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you have a problem with the Add()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
else
{
Expand Down
11 changes: 9 additions & 2 deletions src/NSwag.AspNetCore/NSwag.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<PackageTags>Swagger Documentation AspNetCore NetCore TypeScript CodeGen</PackageTags>
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
<SymbolPackageFormat>symbols.nupkg</SymbolPackageFormat>
Expand All @@ -17,6 +17,7 @@
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet5>[5, 6.0)</MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet5>
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet6>[6.0.0, 7.0)</MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet6>
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet7>[7.0.0, 8.0)</MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet7>
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet8>8.0.0-rc.1.23421.29</MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet8>
<NETStandardLibraryPackageVersion>1.6.1</NETStandardLibraryPackageVersion>
<SystemIOFileSystemPackageVersion>4.3.0</SystemIOFileSystemPackageVersion>
<SystemXmlXPathXDocumentPackageVersion>4.0.1</SystemXmlXPathXDocumentPackageVersion>
Expand Down Expand Up @@ -54,7 +55,12 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet7)" />
</ItemGroup>


<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet8)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NSwag.Annotations\NSwag.Annotations.csproj" />
<ProjectReference Include="..\NSwag.Core\NSwag.Core.csproj" />
Expand All @@ -81,6 +87,7 @@
microsoftExtensionsFileProvidersEmbeddedPackageVersionNet5=$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet5);
microsoftExtensionsFileProvidersEmbeddedPackageVersionNet6=$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet6);
microsoftExtensionsFileProvidersEmbeddedPackageVersionNet7=$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet7);
microsoftExtensionsFileProvidersEmbeddedPackageVersionNet8=$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet8);
netStandardLibraryPackageVersion=$(NETStandardLibraryPackageVersion);
systemIOFileSystemPackageVersion=$(SystemIOFileSystemPackageVersion);
systemXmlXPathXDocumentPackageVersion=$(SystemXmlXPathXDocumentPackageVersion);
Expand Down
11 changes: 11 additions & 0 deletions src/NSwag.AspNetCore/NSwag.AspNetCore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
<dependency id="Microsoft.Extensions.ApiDescription.Server" version="$microsoftExtensionsApiDescriptionServerPackageVersion$" />
<dependency id="Microsoft.Extensions.FileProviders.Embedded" version="$MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet7$" exclude="Build,Analyzers" />
</group>
<group targetFramework="net8.0">
<dependency id="NSwag.Annotations" version="$version$" exclude="Build,Analyzers" />
<dependency id="NSwag.Core" version="$version$" exclude="Build,Analyzers" />
<dependency id="NSwag.Core.Yaml" version="$version$" exclude="Build,Analyzers" />
<dependency id="NSwag.Generation.AspNetCore" version="$version$" exclude="Build,Analyzers" />
<dependency id="NSwag.Generation" version="$version$" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.ApiDescription.Server" version="$microsoftExtensionsApiDescriptionServerPackageVersion$" />
<dependency id="Microsoft.Extensions.FileProviders.Embedded" version="$MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet8$" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
Expand All @@ -69,5 +78,7 @@
<file src="bin\$configuration$\net6.0\NSwag.AspNetCore.xml" target="lib\net6.0\" />
<file src="bin\$configuration$\net7.0\NSwag.AspNetCore.dll" target="lib\net7.0\" />
<file src="bin\$configuration$\net7.0\NSwag.AspNetCore.xml" target="lib\net7.0\" />
<file src="bin\$configuration$\net8.0\NSwag.AspNetCore.dll" target="lib\net8.0\" />
<file src="bin\$configuration$\net8.0\NSwag.AspNetCore.xml" target="lib\net8.0\" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,43 @@ public override async Task<object> RunAsync(CommandLineProcessor processor, ICon
toolDirectory = Path.GetDirectoryName(typeof(AspNetCoreToOpenApiCommand).GetTypeInfo().Assembly.Location);
}

if (projectMetadata.TargetFrameworkIdentifier == ".NETFramework")
string binaryName;
var is32BitProject = string.Equals(projectMetadata.PlatformTarget, "x86", StringComparison.OrdinalIgnoreCase);
if (is32BitProject)
{
string binaryName;
var is32BitProject = string.Equals(projectMetadata.PlatformTarget, "x86", StringComparison.OrdinalIgnoreCase);
if (is32BitProject)
if (Environment.Is64BitProcess)
{
if (Environment.Is64BitProcess)
{
throw new InvalidOperationException($"The ouput of {projectFile} is a 32-bit application and requires NSwag.Console.x86 to be processed.");
}

binaryName = LauncherBinaryName + ".x86.exe";
}
else
{
if (!Environment.Is64BitProcess)
{
throw new InvalidOperationException($"The ouput of {projectFile} is a 64-bit application and requires NSwag.Console to be processed.");
}

binaryName = LauncherBinaryName + ".exe";
throw new InvalidOperationException($"The ouput of {projectFile} is a 32-bit application and requires NSwag.Console.x86 to be processed.");
}

var executableSource = Path.Combine(toolDirectory, binaryName);
if (!File.Exists(executableSource))
binaryName = LauncherBinaryName + ".x86.exe";
}
else
{
if (!Environment.Is64BitProcess)
{
throw new InvalidOperationException($"Unable to locate {binaryName} in {toolDirectory}.");
throw new InvalidOperationException($"The ouput of {projectFile} is a 64-bit application and requires NSwag.Console to be processed.");
}

executable = Path.Combine(projectMetadata.OutputPath, binaryName);
File.Copy(executableSource, executable, overwrite: true);
cleanupFiles.Add(executable);
binaryName = LauncherBinaryName + ".exe";
}

var appConfig = Path.Combine(projectMetadata.OutputPath, projectMetadata.TargetFileName + ".config");
if (File.Exists(appConfig))
{
var copiedAppConfig = Path.ChangeExtension(executable, ".exe.config");
File.Copy(appConfig, copiedAppConfig, overwrite: true);
cleanupFiles.Add(copiedAppConfig);
}
var executableSource = Path.Combine(toolDirectory, binaryName);
if (!File.Exists(executableSource))
{
throw new InvalidOperationException($"Unable to locate {binaryName} in {toolDirectory}.");
}

executable = Path.Combine(projectMetadata.OutputPath, binaryName);
File.Copy(executableSource, executable, overwrite: true);
cleanupFiles.Add(executable);

var appConfig = Path.Combine(projectMetadata.OutputPath, projectMetadata.TargetFileName + ".config");
if (File.Exists(appConfig))
{
var copiedAppConfig = Path.ChangeExtension(executable, ".exe.config");
File.Copy(appConfig, copiedAppConfig, overwrite: true);
cleanupFiles.Add(copiedAppConfig);
}
#else
var toolDirectory = AppContext.BaseDirectory;
Expand All @@ -143,40 +140,30 @@ public override async Task<object> RunAsync(CommandLineProcessor processor, ICon
toolDirectory = Path.GetDirectoryName(typeof(AspNetCoreToOpenApiCommand).GetTypeInfo().Assembly.Location);
}

if (projectMetadata.TargetFrameworkIdentifier == ".NETCoreApp" ||
projectMetadata.TargetFrameworkIdentifier == "net6.0" ||
projectMetadata.TargetFrameworkIdentifier == "net7.0")
{
executable = "dotnet";
args.Add("exec");
args.Add("--depsfile");
args.Add(projectMetadata.ProjectDepsFilePath);
executable = "dotnet";
args.Add("exec");
args.Add("--depsfile");
args.Add(projectMetadata.ProjectDepsFilePath);

args.Add("--runtimeconfig");
args.Add(projectMetadata.ProjectRuntimeConfigFilePath);
args.Add("--runtimeconfig");
args.Add(projectMetadata.ProjectRuntimeConfigFilePath);

var binaryName = LauncherBinaryName + ".dll";
var executorBinary = Path.Combine(toolDirectory, binaryName);
var binaryName = LauncherBinaryName + ".dll";
var executorBinary = Path.Combine(toolDirectory, binaryName);

if (!File.Exists(executorBinary))
{
binaryName = LauncherBinaryName + ".exe";
executorBinary = Path.Combine(toolDirectory, binaryName);
}

if (!File.Exists(executorBinary))
{
throw new InvalidOperationException($"Unable to locate {binaryName} in {toolDirectory}.");
}

args.Add(executorBinary);
if (!File.Exists(executorBinary))
{
binaryName = LauncherBinaryName + ".exe";
executorBinary = Path.Combine(toolDirectory, binaryName);
}
#endif
else

if (!File.Exists(executorBinary))
{
throw new InvalidOperationException($"Unsupported target framework '{projectMetadata.TargetFrameworkIdentifier}'.");
throw new InvalidOperationException($"Unable to locate {binaryName} in {toolDirectory}.");
}

args.Add(executorBinary);
#endif
var commandFile = Path.GetTempFileName();
var outputFile = Path.GetTempFileName();
File.WriteAllText(commandFile, JsonConvert.SerializeObject(this));
Expand Down
6 changes: 6 additions & 0 deletions src/NSwag.Commands/NSwag.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0-rc.1.23421.29" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.7" />
Expand Down
4 changes: 4 additions & 0 deletions src/NSwag.Commands/NSwagDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ private string GetArgumentsPrefix()
{
return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "Net70/dotnet-nswag.dll") + "\" ";
}
else if (runtime == Runtime.Net80)
{
return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "Net80/dotnet-nswag.dll") + "\" ";
}
else
#endif
return "";
Expand Down
3 changes: 3 additions & 0 deletions src/NSwag.Commands/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public enum Runtime

/// <summary>.NET 7 app.</summary>
Net70,

/// <summary>.NET 8 app.</summary>
Net80,

/// <summary>Execute in the same process.</summary>
Debug
Expand Down
5 changes: 5 additions & 0 deletions src/NSwag.Commands/RuntimeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static Runtime CurrentRuntime
var framework = PlatformServices.Default.Application.RuntimeFramework;
if (framework.Identifier == ".NETCoreApp")
{
if (framework.Version.Major >= 8)
{
return Runtime.Net80;
}

if (framework.Version.Major >= 7)
{
return Runtime.Net70;
Expand Down
7 changes: 6 additions & 1 deletion src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<AssemblyName>dotnet-nswag</AssemblyName>
<PackageId>NSwag.ConsoleCore</PackageId>
Expand All @@ -22,6 +22,11 @@
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0-rc.1.23421.29" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NConsole" Version="3.12.6605.26941" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn),618,1591</NoWarn>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn),618,1591</NoWarn>
</PropertyGroup>
<ItemGroup>
Expand All @@ -19,6 +19,10 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0-rc.1.23421.29" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NSwag.Annotations\NSwag.Annotations.csproj" />
<ProjectReference Include="..\NSwag.Generation.AspNetCore.Tests.Web\NSwag.Generation.AspNetCore.Tests.Web.csproj" />
Expand Down
Loading
Loading