text fixes for dotnet remove
This commit is contained in:
parent
bcfc16000c
commit
8a2be57617
4 changed files with 55 additions and 32 deletions
|
@ -55,13 +55,15 @@ namespace Microsoft.DotNet.Cli
|
||||||
.ForwardAs(o => $"--package-directory {o.Arguments.Single()}"))),
|
.ForwardAs(o => $"--package-directory {o.Arguments.Single()}"))),
|
||||||
Create.Command(
|
Create.Command(
|
||||||
"reference",
|
"reference",
|
||||||
"Command to add project to project reference",
|
Tools.Add.ProjectToProjectReference.LocalizableStrings.AppFullName,
|
||||||
Accept.OneOrMoreArguments(),
|
Accept.OneOrMoreArguments()
|
||||||
|
.With(name: "args",
|
||||||
|
description: Tools.Add.ProjectToProjectReference.LocalizableStrings.AppHelpText),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
Create.Option("-f|--framework",
|
Create.Option("-f|--framework",
|
||||||
"Add reference only when targeting a specific framework",
|
"Add reference only when targeting a specific framework",
|
||||||
Accept.AnyOneOf(Suggest.TargetFrameworksFromProjectFile)
|
Accept.AnyOneOf(Suggest.TargetFrameworksFromProjectFile)
|
||||||
.With(name: "FRAMEWORK"))),
|
.With(name: "FRAMEWORK"))),
|
||||||
CommonOptions.HelpOption());
|
CommonOptions.HelpOption());
|
||||||
|
|
||||||
public static IEnumerable<string> QueryNuGet(string match)
|
public static IEnumerable<string> QueryNuGet(string match)
|
||||||
|
|
|
@ -11,9 +11,16 @@ namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
DebugHelper.HandleDebugSwitch(ref args);
|
DebugHelper.HandleDebugSwitch(ref args);
|
||||||
|
|
||||||
var result =
|
ParseResult result;
|
||||||
Parser.Instance.Parse(
|
try
|
||||||
|
{
|
||||||
|
result = Parser.Instance.Parse(
|
||||||
args.Single());
|
args.Single());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("The parser threw an exception.", e);
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine(result.Diagram());
|
Console.WriteLine(result.Diagram());
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Build.Evaluation;
|
using Microsoft.Build.Evaluation;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.Tools;
|
using Microsoft.DotNet.Tools;
|
||||||
|
using static System.Array;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
|
@ -10,33 +13,46 @@ namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
public static IEnumerable<string> TargetFrameworksFromProjectFile()
|
public static IEnumerable<string> TargetFrameworksFromProjectFile()
|
||||||
{
|
{
|
||||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(
|
var msBuildProject = GetMSBuildProject();
|
||||||
new ProjectCollection(),
|
|
||||||
Directory.GetCurrentDirectory());
|
|
||||||
|
|
||||||
foreach (var tfm in msbuildProj.GetTargetFrameworks())
|
if (msBuildProject == null)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var tfm in msBuildProject.GetTargetFrameworks())
|
||||||
{
|
{
|
||||||
yield return tfm.GetShortFolderName();
|
yield return tfm.GetShortFolderName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> RunTimesFromProjectFile()
|
private static void Report(Exception e) =>
|
||||||
|
Reporter.Verbose.WriteLine($"Exception occurred while getting suggestions: {e}");
|
||||||
|
|
||||||
|
public static IEnumerable<string> RunTimesFromProjectFile() =>
|
||||||
|
GetMSBuildProject()
|
||||||
|
.GetRuntimeIdentifiers() ??
|
||||||
|
Empty<string>();
|
||||||
|
|
||||||
|
public static IEnumerable<string> ProjectReferencesFromProjectFile() =>
|
||||||
|
GetMSBuildProject()
|
||||||
|
?.GetProjectToProjectReferences()
|
||||||
|
.Select(r => r.Include) ??
|
||||||
|
Empty<string>();
|
||||||
|
|
||||||
|
private static MsbuildProject GetMSBuildProject()
|
||||||
{
|
{
|
||||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(
|
try
|
||||||
new ProjectCollection(),
|
{
|
||||||
Directory.GetCurrentDirectory());
|
return MsbuildProject.FromFileOrDirectory(
|
||||||
|
new ProjectCollection(),
|
||||||
return msbuildProj.GetRuntimeIdentifiers();
|
Directory.GetCurrentDirectory());
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
public static IEnumerable<string> ProjectReferencesFromProjectFile()
|
{
|
||||||
{
|
Report(e);
|
||||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(
|
return null;
|
||||||
new ProjectCollection(),
|
}
|
||||||
Directory.GetCurrentDirectory());
|
|
||||||
|
|
||||||
return msbuildProj.GetProjectToProjectReferences()
|
|
||||||
.Select(r => r.Include);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,17 +16,15 @@ namespace Microsoft.DotNet.Cli.Add.Reference.Tests
|
||||||
{
|
{
|
||||||
private const string HelpText = @".NET Add Project to Project reference Command
|
private const string HelpText = @".NET Add Project to Project reference Command
|
||||||
|
|
||||||
Usage: dotnet add <PROJECT> reference [options] [args]
|
Usage: dotnet add <PROJECT> reference [options] <args>
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
<PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
|
||||||
|
<args> Project to project references to add
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h|--help Show help information
|
-h, --help Show help information
|
||||||
-f|--framework <FRAMEWORK> Add reference only when targeting a specific framework
|
-f, --framework <FRAMEWORK> Add reference only when targeting a specific framework
|
||||||
|
|
||||||
Additional Arguments:
|
|
||||||
Project to project references to add
|
|
||||||
";
|
";
|
||||||
|
|
||||||
const string FrameworkNet451Arg = "-f net451";
|
const string FrameworkNet451Arg = "-f net451";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue