2023-04-14 14:30:08.581 +08:00 [ERR] Unhandled exception
Mono.TextTemplating.TemplatingEngineException: Not a valid .NET Core host
at Mono.TextTemplating.TemplatingEngine.GetOrCreateCompiler() in /_/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs:line 67
at Mono.TextTemplating.TemplatingEngine.CompileCode(IEnumerable`1 references, TemplateSettings settings, CodeCompileUnit ccu, CancellationToken token) in /_/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs:line 303
at Mono.TextTemplating.TemplatingEngine.CompileTemplateInternal(ParsedTemplate pt, String content, ITextTemplatingEngineHost host, TemplateSettings settings, CancellationToken token) in /_/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs:line 277
at Mono.TextTemplating.TemplatingEngine.ProcessTemplateAsync(ParsedTemplate pt, String content, TemplateSettings settings, ITextTemplatingEngineHost host, CancellationToken token) in /_/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs:line 88
at Mono.TextTemplating.TemplateGenerator.ProcessTemplateAsync(ParsedTemplate pt, String inputFileName, String inputContent, String outputFileName, TemplateSettings settings, CancellationToken token) in /_/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs:line 269
at TableCraft.Core.ConfigManager.GenerateCodeForUsage(String usage, ConfigInfo configInfo, String outputDirectory) in D:\Desktop\Workshop\Others\TableCraft\TableCraft.Core\ConfigManager.cs:line 128
at TableCraft.Editor.ViewModels.MainWindowViewModel.GenerateCodeWithCurrentUsage() in D:\Desktop\Workshop\Others\TableCraft\TableCraft.Editor\ViewModels\MainWindowViewModel.cs:line 326
looking into Mono.TextTemplating.CodeCompilation.RuntimeInfo.GetDotNetCoreSdk(),
static bool DotnetRootIsValid (string root) => !string.IsNullOrEmpty (root) && (File.Exists (Path.Combine (root, "dotnet")) || File.Exists (Path.Combine (root, "dotnet.exe")));
// this should get us something like /usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.0
var runtimeDir = Path.GetDirectoryName (typeof (object).Assembly.Location);
var dotnetRoot = Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (runtimeDir)));
if (!DotnetRootIsValid (dotnetRoot)) {
// this may happen on single file deployments
return FromError (RuntimeKind.NetCore, "Not a valid .NET Core host");
}
It's clear that runtimeDir is the same as the executable file path on the self-contained version, resulting in dotnetRoot being invalid. This is the debugging output from a self-contained version of TableCraft:
log-20230414.txt
looking into
Mono.TextTemplating.CodeCompilation.RuntimeInfo.GetDotNetCoreSdk()
,It's clear that
runtimeDir
is the same as the executable file path on the self-contained version, resulting indotnetRoot
being invalid. This is the debugging output from a self-contained version of TableCraft: