Skip to content

Instantly share code, notes, and snippets.

View emgarten's full-sized avatar

Justin Emgarten emgarten

View GitHub Profile
using NuGet.Client;
using NuGet.Client.VisualStudio;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Program
{
using System;
namespace NuGet.Versioning
{
/// <summary>
/// VersionFloatComparer orders versions around a floating range. The range in this
/// case is only the floating part.
/// Ex: [1.0.*, 2.0.0) has a floating range of [1.0.0, 1.1.0)
/// Filtering on the [1.0.0, 2.0.0) range needs to happen outside of this class, it will not be
/// taken into account here.
{
"locked": false,
"version": 1,
"targets": {
".NETFramework,Version=v4.6": {
"packageA/1.0.0": {
"shared": {
"codeLanguage": {
"cs": {
"shared/cs/net45/code/code.cs": {
@emgarten
emgarten / restore.cs
Created November 4, 2015 04:00
NuGet.Core example of reading nuget.config restore settings
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.
@emgarten
emgarten / updates.cs
Created November 18, 2015 23:22
Find package updates available for a packages.config file
// install-package nuget.protocol.visualstudio
using NuGet.Configuration;
using NuGet.Packaging;
using NuGet.Protocol.Core.Types;
using NuGet.Protocol.VisualStudio;
using System;
using System.IO;
using System.Linq;
using System.Threading;
#:C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj
C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj|C:\src\repros\roslyn\src\Test\PdbUtilities\PdbUtilities.csproj
C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj|C:\src\repros\roslyn\src\Test\Utilities\Desktop\TestUtilities.Desktop.csproj
C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj|C:\src\repros\roslyn\src\Compilers\CSharp\Portable\CSharpCodeAnalysis.csproj
C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj|C:\src\repros\roslyn\src\Compilers\Test\Resources\Core\CompilerTestResources.csproj
C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj|C:\src\repros\roslyn\src\Test\Utilities\Portable.FX45\TestUtilities.FX45.csproj
C:\src\repros\roslyn\src\Compilers\Core\CodeAnalysisTest\CodeAnalysisTest.csproj|C:\src\repros\roslyn\src\Compilers\VisualBasic\Portable\BasicCodeAnalysis.
<!--
***********************************************************************************************
Microsoft.NuGet.ImportAfter.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
@emgarten
emgarten / dg-debugging.txt
Created October 12, 2016 22:36
Debugging restore3
Set environment variables
$env:NUGET_PERSIST_DG=true
$env:NUGET_PERSIST_DG_PATH=c:\temp\path.json
Run dotnet.exe restore3
Open the output json file
Restore contains projects that will be directly restored.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Frameworks;
using NuGet.Packaging.Core;
using NuGet.ProjectManagement;
namespace ConsoleApplication5
@emgarten
emgarten / FindParentPackages.cs
Created January 22, 2017 20:34
Find all packages on nuget.org that depend on the target package id.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using NuGet.CatalogReader;
using NuGet.Common;
using NuGet.Packaging.Core;
using NuGet.Protocol;