Update to .NET 8

This commit is contained in:
Wojtek Figat
2023-11-26 15:09:46 +01:00
parent 76f5712c79
commit 06ad316f94
27 changed files with 94 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>annotations</Nullable>

View File

@@ -130,7 +130,7 @@ namespace Flax.Build
/// <summary>
/// The minimum SDK version.
/// </summary>
public static Version MinimumVersion => new Version(7, 0);
public static Version MinimumVersion => new Version(8, 0);
/// <summary>
/// The maximum SDK version.

View File

@@ -164,6 +164,30 @@ namespace Flax.Build
}
}
public string Serialize()
{
// Null any empty fields to exclude them from serialization
if (HotReloadPostfix?.Length == 0)
HotReloadPostfix = null;
foreach (var binaryModule in BinaryModules)
{
if (binaryModule.NativePathProcessed?.Length == 0)
binaryModule.NativePathProcessed = null;
if (binaryModule.ManagedPathProcessed?.Length == 0)
binaryModule.ManagedPathProcessed = null;
}
// Convert to Json
var options = new JsonSerializerOptions
{
WriteIndented = true,
IncludeFields = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
TypeInfoResolver = BuildTargetInfoSourceGenerationContext.Default,
};
return JsonSerializer.Serialize<BuildTargetInfo>(this, options);
}
public static string ProcessPath(string path, string projectPath)
{
if (string.IsNullOrEmpty(path))
@@ -1017,7 +1041,7 @@ namespace Flax.Build
buildData.BuildInfo.AddReferencedBuilds(ref i, project.ProjectFolderPath, buildData.ReferenceBuilds);
if (!buildData.Target.IsPreBuilt)
Utilities.WriteFileIfChanged(Path.Combine(outputPath, target.Name + ".Build.json"), JsonSerializer.Serialize<BuildTargetInfo>(buildData.BuildInfo, new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true, TypeInfoResolver = BuildTargetInfoSourceGenerationContext.Default }));
Utilities.WriteFileIfChanged(Path.Combine(outputPath, target.Name + ".Build.json"), buildData.BuildInfo.Serialize());
}
// Deploy files
@@ -1216,7 +1240,7 @@ namespace Flax.Build
buildData.BuildInfo.AddReferencedBuilds(ref i, project.ProjectFolderPath, buildData.ReferenceBuilds);
if (!buildData.Target.IsPreBuilt)
Utilities.WriteFileIfChanged(Path.Combine(outputPath, target.Name + ".Build.json"), JsonSerializer.Serialize<BuildTargetInfo>(buildData.BuildInfo, new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true, TypeInfoResolver = BuildTargetInfoSourceGenerationContext.Default }));
Utilities.WriteFileIfChanged(Path.Combine(outputPath, target.Name + ".Build.json"), buildData.BuildInfo.Serialize());
}
// Deploy files

View File

@@ -50,7 +50,7 @@ namespace Flax.Deps.Dependencies
{
// Build configuration (see build.cmd -help)
string configuration = "Release";
string framework = "net7.0";
string framework = "net8.0";
// Clean output directory
var artifacts = Path.Combine(root, "artifacts");
@@ -224,7 +224,7 @@ namespace Flax.Deps.Dependencies
}
var privateCorelib = "System.Private.CoreLib.dll";
Utilities.FileCopy(Path.Combine(unpackTemp, "runtimes", hostRuntimeName, "native", privateCorelib), Path.Combine(dstClassLibrary, privateCorelib));
Utilities.DirectoryCopy(Path.Combine(unpackTemp, "runtimes", hostRuntimeName, "lib", "net7.0"), dstClassLibrary, false, true);
Utilities.DirectoryCopy(Path.Combine(unpackTemp, "runtimes", hostRuntimeName, "lib", "net8.0"), dstClassLibrary, false, true);
// TODO: host/fxr/<version>/hostfxr.dll
// TODO: shared/Microsoft.NETCore.App/<version>/hostpolicy.dl
// TODO: shared/Microsoft.NETCore.App/<version>/System.IO.Compression.Native.dll

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>annotations</Nullable>

View File

@@ -96,7 +96,7 @@ namespace Flax.Build.Projects.VisualStudio
var cacheProjectsPath = Utilities.MakePathRelativeTo(Path.Combine(Globals.Root, "Cache", "Projects"), projectDirectory);
var flaxBuildTargetsPath = !string.IsNullOrEmpty(cacheProjectsPath) ? Path.Combine(cacheProjectsPath, flaxBuildTargetsFilename) : flaxBuildTargetsFilename;
csProjectFileContent.AppendLine(" <TargetFramework>net7.0</TargetFramework>");
csProjectFileContent.AppendLine(" <TargetFramework>net8.0</TargetFramework>");
csProjectFileContent.AppendLine(" <ImplicitUsings>disable</ImplicitUsings>");
csProjectFileContent.AppendLine(string.Format(" <Nullable>{0}</Nullable>", baseConfiguration.TargetBuildOptions.ScriptingAPI.CSharpNullableReferences.ToString().ToLowerInvariant()));
csProjectFileContent.AppendLine(" <IsPackable>false</IsPackable>");

View File

@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.0",
"version": "8.0.0",
"rollForward": "latestMajor"
}
}