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

Mono.TextTemplating.CodeCompilation RuntimeInfo class do not handle right under Linux and .net6 #168

Closed
kleve-ops opened this issue Oct 17, 2023 · 3 comments
Assignees

Comments

@kleve-ops
Copy link

inside
static 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);

Path.GetDirectoryName (typeof (object).Assembly.Location) don't give the the path to the .net installation. It's pointing into my App bin folder. So we need a way to set the path to the dotnet installation folder or we should have the option to override static RuntimeInfo GetDotNetCoreSdk (). I am happy if one of you can tell me how I come around this execption:Mono.TextTemplating.TemplatingEngineException: Not a valid .NET Core host
at Mono.TextTemplating.TemplatingEngine.GetOrCreateCompiler() in /_/Mono.TextTemplating/Mono.TextTemplating/TemplatingEngine.cs:line 67

@kleve-ops
Copy link
Author

OK, if I build the stuff under Windows for Linux then this problem is gone. Looks like that's a problem with the none standard .net6 installation on my Linux machine.
Now the only problem is that PublishSingleFile is not working. Here the Assemblyname is null. Need to adapt the detection of assenbly refs in SIngleFile context.

@mhutch mhutch self-assigned this Dec 4, 2023
@kleve-ops
Copy link
Author

OK, the problem with GetDotNetCoreSdk () still exists. To solve this please add:
static 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);
if (!runtimeDir.Contains ("Microsoft.NETCore.App") && Environment.GetEnvironmentVariable ("DOTNET_HOST_PATH") != null) {
	runtimeDir = Environment.GetEnvironmentVariable ("DOTNET_HOST_PATH");
}
var dotnetRoot = Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (runtimeDir)));

With that solution we have a workaround via "DOTNET_HOST_PATH".

@mhutch
Copy link
Member

mhutch commented Jan 23, 2024

@kleve-ops would DOTNET_ROOT be acceptable? It seems like the more appropriate environment variable for our use.

@mhutch mhutch closed this as completed in 121ec3d Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants