Fix C# building to properly use reference assemblies for .NET 7
This commit is contained in:
@@ -37,7 +37,8 @@ public class Editor : EditorModule
|
||||
{
|
||||
base.Setup(options);
|
||||
|
||||
options.ScriptingAPI.SystemReferences.Add("System.Private.Xml");
|
||||
options.ScriptingAPI.SystemReferences.Add("System.Xml");
|
||||
options.ScriptingAPI.SystemReferences.Add("System.Xml.ReaderWriter");
|
||||
options.ScriptingAPI.SystemReferences.Add("System.Text.RegularExpressions");
|
||||
options.ScriptingAPI.SystemReferences.Add("System.ComponentModel.TypeConverter");
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@ namespace Flax.Build
|
||||
if (!dotnetSdk.IsValid)
|
||||
throw new Exception("Cannot compile C# without .NET SDK");
|
||||
string dotnetPath = "dotnet", referenceAnalyzers;
|
||||
string[] runtimeVersionNameParts = dotnetSdk.RuntimeVersionName.Split('.');
|
||||
string runtimeVersionShort = runtimeVersionNameParts[0] + '.' + runtimeVersionNameParts[1];
|
||||
#else
|
||||
string monoRoot, monoPath;
|
||||
#endif
|
||||
@@ -174,7 +176,7 @@ namespace Flax.Build
|
||||
#if USE_NETCORE
|
||||
dotnetPath = Path.Combine(dotnetSdk.RootPath, "dotnet.exe");
|
||||
cscPath = Path.Combine(dotnetSdk.RootPath, @$"sdk\{dotnetSdk.VersionName}\Roslyn\bincore\csc.dll");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, @$"shared\Microsoft.NETCore.App\{dotnetSdk.RuntimeVersionName}\");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, @$"packs\Microsoft.NETCore.App.Ref\{dotnetSdk.RuntimeVersionName}\ref\net{runtimeVersionShort}\");
|
||||
referenceAnalyzers = Path.Combine(dotnetSdk.RootPath, @$"packs\Microsoft.NETCore.App.Ref\{dotnetSdk.RuntimeVersionName}\analyzers\dotnet\cs\");
|
||||
#else
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Windows", "Mono");
|
||||
@@ -190,7 +192,7 @@ namespace Flax.Build
|
||||
{
|
||||
#if USE_NETCORE
|
||||
cscPath = Path.Combine(dotnetSdk.RootPath, $"sdk/{dotnetSdk.VersionName}/Roslyn/bincore/csc.dll");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, $"shared/Microsoft.NETCore.App/{dotnetSdk.RuntimeVersionName}/");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, $"packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/ref/net{runtimeVersionShort}/");
|
||||
referenceAnalyzers = Path.Combine(dotnetSdk.RootPath, $"packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/analyzers/dotnet/cs/");
|
||||
#else
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Linux", "Mono");
|
||||
@@ -204,7 +206,7 @@ namespace Flax.Build
|
||||
{
|
||||
#if USE_NETCORE
|
||||
cscPath = Path.Combine(dotnetSdk.RootPath, $"sdk/{dotnetSdk.VersionName}/Roslyn/bincore/csc.dll");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, $"shared/Microsoft.NETCore.App/{dotnetSdk.RuntimeVersionName}/");
|
||||
referenceAssemblies = Path.Combine(dotnetSdk.RootPath, $"packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/ref/net{runtimeVersionShort}/");
|
||||
referenceAnalyzers = Path.Combine(dotnetSdk.RootPath, $"packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/analyzers/dotnet/cs/");
|
||||
#else
|
||||
monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Mac", "Mono");
|
||||
@@ -256,6 +258,7 @@ namespace Flax.Build
|
||||
args.Add(buildData.Configuration == TargetConfiguration.Release ? "/optimize+" : "/optimize-");
|
||||
#else
|
||||
args.Add(buildData.Configuration == TargetConfiguration.Debug ? "/optimize-" : "/optimize+");
|
||||
args.Add(string.Format("/reference:\"{0}mscorlib.dll\"", referenceAssemblies));
|
||||
#endif
|
||||
args.Add(string.Format("/out:\"{0}\"", outputFile));
|
||||
args.Add(string.Format("/doc:\"{0}\"", outputDocFile));
|
||||
@@ -263,7 +266,6 @@ namespace Flax.Build
|
||||
args.Add("/define:" + string.Join(";", buildOptions.ScriptingAPI.Defines));
|
||||
if (buildData.Configuration == TargetConfiguration.Debug)
|
||||
args.Add("/define:DEBUG");
|
||||
args.Add(string.Format("/reference:\"{0}mscorlib.dll\"", referenceAssemblies));
|
||||
foreach (var reference in buildOptions.ScriptingAPI.SystemReferences)
|
||||
args.Add(string.Format("/reference:\"{0}{1}.dll\"", referenceAssemblies, reference));
|
||||
foreach (var reference in fileReferences)
|
||||
|
||||
@@ -244,6 +244,8 @@ namespace Flax.Build.NativeCpp
|
||||
Defines = new HashSet<string>(),
|
||||
SystemReferences = new HashSet<string>
|
||||
{
|
||||
"mscorlib",
|
||||
"netstandard",
|
||||
"Microsoft.CSharp",
|
||||
"System",
|
||||
|
||||
@@ -258,25 +260,32 @@ namespace Flax.Build.NativeCpp
|
||||
//"System.ComponentModel.TypeConverter",
|
||||
"System.Console",
|
||||
"System.Core",
|
||||
"System.Diagnostics.StackTrace",
|
||||
"System.Globalization",
|
||||
"System.IO",
|
||||
"System.IO.Compression",
|
||||
"System.IO.FileSystem.Watcher",
|
||||
"System.Linq",
|
||||
"System.Linq.Expressions",
|
||||
"System.Memory",
|
||||
"System.Net",
|
||||
"System.Net.Http",
|
||||
"System.Net.Primitives",
|
||||
"System.ObjectModel",
|
||||
"System.Private.CoreLib",
|
||||
"System.Private.Uri",
|
||||
//"System.Private.Xml",
|
||||
"System.ValueTuple",
|
||||
|
||||
"System.Reflection",
|
||||
"System.Runtime",
|
||||
"System.Runtime.Extensions",
|
||||
"System.Runtime.Handles",
|
||||
"System.Runtime.Intrinsics",
|
||||
"System.Runtime.Numerics",
|
||||
"System.Runtime.Loader",
|
||||
"System.Runtime.CompilerServices.Unsafe",
|
||||
"System.Runtime.InteropServices",
|
||||
"System.Runtime.InteropServices.RuntimeInformation",
|
||||
"System.Runtime.Serialization.Formatters", // BinaryFormatter
|
||||
"System.Runtime.Serialization",
|
||||
"System.Runtime.Serialization.Formatters",
|
||||
|
||||
"System.Security.Cryptography",
|
||||
"System.Security.Cryptography.Algorithms",
|
||||
"System.Security.Cryptography.Primitives",
|
||||
@@ -284,8 +293,11 @@ namespace Flax.Build.NativeCpp
|
||||
"System.Threading.Tasks.Parallel",
|
||||
//"System.Xml",
|
||||
|
||||
"System.Threading",
|
||||
"System.Threading.Thread",
|
||||
|
||||
"System.Reflection",
|
||||
//"System.Reflection.Metadata",
|
||||
"netstandard",
|
||||
},
|
||||
SystemAnalyzers = new HashSet<string>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user