Home

How to #load files from output folder

Is there a way to #load files from the output folder?

#load "<output>\Utilities\*.cs"

Background is I have a number of nuget packages which contain source code utilities as contentFiles.

<contentFiles>
  <files include="cs\any\Utilities\DefaultDictionary.cs" buildAction="Compile" />
</contentFiles>

When I add such a nuget package to LinqPad the source file is copied to the output folder but it is not included in the compile.

I can include them manually with an absolute path like
#load "c:\Users\<MyUser>\AppData\Local\Temp\LINQPad8\_aljymzdy\shadow-1\Utilities\*.cs
but since the output folder is temporary and for this query only it is not a good solution.

Best thing would be it LinqPad automatically loaded content files with buildAction="Compile" but an easier way to load from output folder would work as well.

Comments

  • edited November 26

    You can compile all those files to the assembly and reference it in the script by pressing F4.

    Or you can reference files from the NuGet package cache. Usually it is under %USERPROFILE%\.nuget, e.g. for IsExternalInit source only package path is %USERPROFILE%\.nuget\packages\isexternalinit\1.0.3\content\net20\IsExternalInit\IsExternalInit.cs

  • Thank you for your reply.

    Referencing the package cache works for maybe one or two packages but quickly becomes a mess when there are more.

    Compiling them into an assembly defeats the purpose of having the utilities as source files
    (private dependencies, framework independence)

  • You can compile as netstandard2.0 and/or create NuGet package with all .NET versions you want and reference it. Or copy source files to your script folder and reference it, e.g., #load "./MyLib/MyFile.cs"

    Besides, MS supports as of now only .NET 8 and .NET 9; others are out of support.

  • It sounds like you need the ability to reference a pseudo-folder of the form nuget:package

    #load "nuget:package\content\MyFile.cs"

    or

    #load "nuget:package\content\*.cs"

  • @JoeAlbahari said:
    It sounds like you need the ability to reference a pseudo-folder of the form nuget:package

    #load "nuget:package\content\MyFile.cs"

    or

    #load "nuget:package\content\*.cs"

    Yes, something like that would be nice.

    Maybe nuget:content or nuget:contentFiles would be a clearer name but it is not important.
    I assume it would point to the location where the tree under "/cs/<tfm>" ends up.
    i.e. "/cs/net8/folder/file.cs" would be referenced as nuget:content\folder\file.cs

    Thank you for looking into it.

Sign In or Register to comment.