Home

Copying referenced files to a subfolder within Output folder

Currently referencing any file (in the References tab) would copy it over to the output folder, as a flat structure.

e.g. OutputDir/referenced_file.json

Is there any possibility to copy the referenced file to a subfolder within the outdir ?

e.g. OutputDir/assets/referenced_file.json

Or may be reference a whole folder ?

Comments

  • If you reference a NuGet package with content files, LINQPad will recursively copy the following folders automatically:

    contentFiles\any
    contentFiles\cs

    Otherwise, you could use LINQPad's OnInit hook method and write a query like this:

    void Main()
    {
        // Test it:
        Util.Cmd (@"dir");
        Util.Cmd (@"dir foo");
    }
    
    void OnInit()    // Executes when the query process first loads
    {
        if (!Directory.Exists ("foo"))
        {
            Directory.CreateDirectory ("foo");
            File.WriteAllText (@"foo\\test.txt", "test");
        }
    }
    

    To re-use this from another query, save it to a query such as "foo.linq", then #load it as follows:

    #load "foo"
    
    void Main()
    {
        // Test it:
        Util.Cmd (@"dir");
        Util.Cmd (@"dir foo");
    }
    
Sign In or Register to comment.