Scripts written in PowerShell to generate a msbuild project file from a Linqpad Query, then you can build with msbuild. Supports Nuget packages by creating project.json, which you can restore using Nuget 3 and build with Build Tools 2015(included in Visual Studio 2015).
Currently only supports C# and F# program type queries, and only generates Library or Exe type projects.
-
Ensure latest nuget.exe is in your PATH.
-
Install Build Tools 2015 if you haven't installed Visual Studio 2015.
-
Either copy the folders in
src\Modules
to your PowerShell Modules path or executesrc\Use-Lpmake.ps1
to load the modules for you. -
If you want to publish nuget packages using
lpmake -Publish
switch, then you need to define an environment variable namedmynuget
to point to a location when you want to publish the packages, such asc:\nuget
. You need to ensure it is configured in nuget:nuget sources add -Name MyPackages -Source c:\nuget
-
For LinqPad queries using
Dump
extension method, you will need to have a custom Nuget package namedObjectDumperLib
which contains extension methodDump
for any object. You can change this bylpmake -ObjectDumper <nuget_package_name>
. I have included a LinqPad querysrc\Extra\ObjectDumperLib.linq
which can be built withlpmake
and publish as a Nuget package:lpmake .\src\Extra\ObjectDumperLib.linq -Publish
- Ensure your Linqpad query has a special comment line that will be used by
this script to differentiate between "program" code and "library" code: the
Main
method and any other methods not in a class are considered as "program" code and should occur before the special comment line. This script will use either the default comment line when you create a new C# Program type query:// Define other methods and classes here
, or use//////////
to separate the program and library code. - Run
Import-Module linqpad
if you have added the modules in your PowerShell module paths, or runsrc\Use-Lpmake.ps1
. - Run
lpmake <full_path_to_your_linqpad_query_file>
to generate a msbuild project file in a temporary folder and build it by calling msbuild. By default it generates a Library type project, which means only code after the special comment line will be used; to generate an Exe type project (and include the "program" code before the special comment line), use-OutputType Exe
. - You can use
-Load
to immediately load the compiled assemby into PowerShell.