Search code examples
c#.netlinqpad

How can I restore NuGet packages from a custom package source when using LINQPAD's lprun.exe?


We use the lprun feature of LINQPAD to run our build scripts; However as we are in a corporate environment we block access to the NuGet.org package source:

<add key="nuget.org" value="https://www.nuget.org/api/v2/" />

And instead use a corporate proxy e.g. a custom package source:

<add key="MyProxy" value="https://proxy.server/custom-nuget-repo" />

When developing locally these sources are specified in:

C:\Users\Me\AppData\Roaming\Nuget.config

However LINQPAD is ignoring this file, how can I provide custom package sources when using the lprun to restore NuGet packages referenced?


Solution

  • lprun and LINQPad both use the file %AppData%\LINQPad\NuGetSources.xml for NuGet Package sources, so this is the file you need to edit.

    In case this file doesn't exist, here is an example:

    <?xml version="1.0" encoding="utf-8"?>
    <NuGetSources>
      <Source Name="(default)" />
      <Source Name="My Packages" URI="https://www.myget.org/F/your-username-here/" UserName="Example" Password="base64encodedstring" Enabled="false" />
    </NuGetSources>