I try to make a unity, it can input .linq file path then output exe like Linqpadless project.
and the logic is using linqpad's cli lprun then adding the generated LINQPadQuery.dll to my exe,so i have to get the lprun output path.
You could use the following script to compile the dll and get a reference to the most recent generated file in the temporary folder within the same application lifetime.
Util.Compile(@"C:\Drive\Projects\LINQPad\Queries\Sample.linq");
var path = Path.Combine(Path.GetTempPath(), "LINQPad5", $"_{AppDomain.CurrentDomain.GetData("LINQPad.InstanceID")}");
var file =
new DirectoryInfo(path)
.EnumerateFiles("*.dll") // Or query_*.dll
.OrderBy(x => x.LastWriteTime)
.Last();
file.FullName.Dump();
Comments
Try
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
@nescafe thanks,yes it could get path on running linq file.
but if i use cli
lprun
it can not return output path.e.g
if i use
ipconfig
, windows system can returnip infoformation
The output folder is dynamic, so a separate lprun cli command would refer to another directory.
You could copy the dll to a known location as part of the script, e.g.
File.Copy(Assembly.GetExecutingAssembly().Location, @"C:\Temp\LINQPadQuery.dll");
Somewhere in your main function, or echo the location at the end of your script:
Console.WriteLine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
What are you trying to achieve?
Thanks!
I try to make a unity, it can input .linq file path then output exe like
Linqpadless
project.and the logic is using linqpad's cli
lprun
then adding the generatedLINQPadQuery.dll
to my exe,so i have to get the lprun output path.You could use the following script to compile the dll and get a reference to the most recent generated file in the temporary folder within the same application lifetime.
wow,it's a solution,thanks!