Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Adding dotnet add package sub command #5122

Merged
merged 6 commits into from
Dec 27, 2016

Conversation

mishra14
Copy link

Adding the dotnet add package sub command to add package references.

NuGet part of the work : NuGet/NuGet.Client#1063

Fixes add package part of https://github.com/dotnet/cli/issues/4521 and NuGet/Home#3751

//cc: @livarcocc @piotrpMSFT @blackdwarf @krwq @rrelyea @emgarten

@dnfclas
Copy link

dnfclas commented Dec 21, 2016

Hi @mishra14, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@mishra14
Copy link
Author

@dotnet-bot test Debian8.2 x64 Debug Build

@mishra14
Copy link
Author

@dotnet-bot test Windows_NT x64 Release Build

@mishra14
Copy link
Author

@dotnet-bot test Ubuntu x64 Release Build


namespace Microsoft.DotNet.Tools.Add.PackageReference
{
internal class LocalizableStrings

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


public static DotNetSubCommandBase Create()
{
var command = new AddPackageReferenceCommand()

This comment was marked as spam.

public override int Run(string fileOrDirectory)
{
var projects = new ProjectCollection();
var msbuildProj = MsbuildProject.FromFileOrDirectory(projects, fileOrDirectory);

This comment was marked as spam.

return result;
}

private void GetProjectDependencyGraph(string projectFilePath,

This comment was marked as spam.

args.Add("/t:GenerateRestoreGraphFile");

// Pass Dependency Graph file output path
args.Add(string.Format("/p:RestoreGraphOutputPath={0}{1}{2}", '"', dgFilePath, '"'));

This comment was marked as spam.


if (result != 0)
{
throw new GracefulException(string.Format(LocalizableStrings.CmdDGFileException, projectFilePath));

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

}
}

private string CreateTemporaryFile(string extension)

This comment was marked as spam.

public override int Run(string fileOrDirectory)
{
var projects = new ProjectCollection();
var msbuildProj = MsbuildProject.FromFileOrDirectory(projects, fileOrDirectory);

This comment was marked as spam.

"package",
"add",
"--package",
"Newtonsoft.Json",

This comment was marked as spam.

"Newtonsoft.Json",
"--project",
projectFilePath
};

This comment was marked as spam.

@mishra14
Copy link
Author

🔔 @livarcocc

@mishra14
Copy link
Author

@dotnet-bot test CentOS7.1 x64 Debug Build

@@ -62,6 +62,19 @@ public static MsbuildProject FromFile(ProjectCollection projects, string project

public static MsbuildProject FromDirectory(ProjectCollection projects, string projectDirectory)
{
FileInfo projectFile = GetProjectFileFromDirectory(projectDirectory);

var project = TryOpenProject(projects, projectFile.FullName);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

}

return new MsbuildProject(projects, project);
return files.First();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

GetProjectDependencyGraph(projectFilePath, tempDgFilePath);
}

var result = NuGetCommand.Run(TransformArgs(RemainingArguments.First(), tempDgFilePath, projectFilePath));

This comment was marked as spam.

}
else
{
projectFilePath = fileOrDirectory;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"package",
"add",
"--package",
packageId,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@livarcocc
Copy link

@srivatsn

@srivatsn srivatsn requested review from agocke and removed request for agocke December 27, 2016 18:07
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

This comment was marked as spam.

This comment was marked as spam.

@@ -270,4 +268,4 @@ private static ProjectRootElement TryOpenProject(ProjectCollection projects, str
}
}
}
}
}

This comment was marked as spam.

@@ -26,4 +28,4 @@ public static int Run(string[] args)
return command.RunCommand(args);
}
}
}
}

This comment was marked as spam.

@livarcocc livarcocc merged commit 47fb245 into dotnet:rel/1.0.0 Dec 27, 2016
@mishra14 mishra14 deleted the dev-anmishr-dotnetaddpackage branch December 28, 2016 18:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants