Created
November 4, 2015 04:00
-
-
Save emgarten/9681ea4edb90982e7db2 to your computer and use it in GitHub Desktop.
NuGet.Core example of reading nuget.config restore settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using NuGet; | |
namespace ConsoleApplication25 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Create a new file system using the root directory of the solution or project. | |
// All nuget.config files from that directory and up will be checked. | |
var fileSystem = new PhysicalFileSystem(@"D:\tmp\test\ConsoleApplication1"); | |
var settings = new Settings(fileSystem); | |
// Restore settings reader | |
var restoreSettings = new PackageRestoreConsent(settings); | |
// Check if automatic restore is enabled AND consent is granted | |
// Both of these default to true if they are not set. | |
var canRestore = restoreSettings.IsAutomatic && restoreSettings.IsGranted; | |
Console.WriteLine($"Automatic restore allowed: {canRestore.ToString()}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment