Home

How to get lprun output folder?

edited June 2020

I hope to get path of command lprun output folder.

e.g
every time cmd lprun LINQPad will create dll in \AppData\Local\Temp\LINQPad5\ like below photo.
image

thanks!

Comments

  • Try Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

  • edited June 2020

    @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 return ip 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?

  • edited June 2020

    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 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();
    

  • wow,it's a solution,thanks!

Sign In or Register to comment.