dotnet sln command (#5233)

* Add dotnet sln command

* Use new names for localizable strings

* Fix up the tests for the verb rename
This commit is contained in:
Justin Goshi 2017-01-06 10:58:23 -10:00 committed by GitHub
parent dbdbde5bcc
commit e109a9be47
26 changed files with 142 additions and 99 deletions

View file

@ -49,6 +49,7 @@ namespace Microsoft.DotNet.Cli.Utils
public static readonly string MSBUILD_EXE_PATH = "MSBUILD_EXE_PATH"; public static readonly string MSBUILD_EXE_PATH = "MSBUILD_EXE_PATH";
public static readonly string ProjectOrSolutionArgumentName = "<PROJECT_OR_SOLUTION>"; public static readonly string ProjectArgumentName = "<PROJECT>";
public static readonly string SolutionArgumentName = "<SLN_FILE>";
} }
} }

View file

@ -16,6 +16,8 @@ namespace Microsoft.DotNet.Cli
{ {
protected abstract string CommandName { get; } protected abstract string CommandName { get; }
protected abstract string FullCommandNameLocalized { get; } protected abstract string FullCommandNameLocalized { get; }
protected abstract string ArgumentName { get; }
protected abstract string ArgumentDescriptionLocalized { get; }
internal abstract List<Func<DotNetSubCommandBase>> SubCommands { get; } internal abstract List<Func<DotNetSubCommandBase>> SubCommands { get; }
public int RunCommand(string[] args) public int RunCommand(string[] args)
@ -30,9 +32,7 @@ namespace Microsoft.DotNet.Cli
command.HelpOption("-h|--help"); command.HelpOption("-h|--help");
command.Argument( command.Argument(ArgumentName, ArgumentDescriptionLocalized);
Constants.ProjectOrSolutionArgumentName,
CommonLocalizableStrings.ArgumentsProjectOrSolutionDescription);
foreach (var subCommandCreator in SubCommands) foreach (var subCommandCreator in SubCommands)
{ {
@ -44,7 +44,7 @@ namespace Microsoft.DotNet.Cli
{ {
if (!command.Arguments.Any()) if (!command.Arguments.Any())
{ {
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, Constants.ProjectOrSolutionArgumentName); throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, ArgumentDescriptionLocalized);
} }
var projectOrDirectory = command.Arguments.First().Value; var projectOrDirectory = command.Arguments.First().Value;

View file

@ -23,6 +23,7 @@ using Microsoft.DotNet.Tools.Remove;
using Microsoft.DotNet.Tools.Restore; using Microsoft.DotNet.Tools.Restore;
using Microsoft.DotNet.Tools.RestoreProjectJson; using Microsoft.DotNet.Tools.RestoreProjectJson;
using Microsoft.DotNet.Tools.Run; using Microsoft.DotNet.Tools.Run;
using Microsoft.DotNet.Tools.Sln;
using Microsoft.DotNet.Tools.Test; using Microsoft.DotNet.Tools.Test;
using Microsoft.DotNet.Tools.VSTest; using Microsoft.DotNet.Tools.VSTest;
using NuGet.Frameworks; using NuGet.Frameworks;
@ -48,6 +49,7 @@ namespace Microsoft.DotNet.Cli
["restore"] = RestoreCommand.Run, ["restore"] = RestoreCommand.Run,
["restore-projectjson"] = RestoreProjectJsonCommand.Run, ["restore-projectjson"] = RestoreProjectJsonCommand.Run,
["run"] = RunCommand.Run, ["run"] = RunCommand.Run,
["sln"] = SlnCommand.Run,
["test"] = TestCommand.Run, ["test"] = TestCommand.Run,
["vstest"] = VSTestCommand.Run, ["vstest"] = VSTestCommand.Run,
}; };

View file

@ -4,9 +4,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Add.PackageReference; using Microsoft.DotNet.Tools.Add.PackageReference;
using Microsoft.DotNet.Tools.Add.ProjectToProjectReference; using Microsoft.DotNet.Tools.Add.ProjectToProjectReference;
using Microsoft.DotNet.Tools.Add.ProjectToSolution;
namespace Microsoft.DotNet.Tools.Add namespace Microsoft.DotNet.Tools.Add
{ {
@ -14,12 +14,13 @@ namespace Microsoft.DotNet.Tools.Add
{ {
protected override string CommandName => "add"; protected override string CommandName => "add";
protected override string FullCommandNameLocalized => LocalizableStrings.NetAddCommand; protected override string FullCommandNameLocalized => LocalizableStrings.NetAddCommand;
protected override string ArgumentName => Constants.ProjectArgumentName;
protected override string ArgumentDescriptionLocalized => CommonLocalizableStrings.ArgumentsProjectDescription;
internal override List<Func<DotNetSubCommandBase>> SubCommands => internal override List<Func<DotNetSubCommandBase>> SubCommands =>
new List<Func<DotNetSubCommandBase>> new List<Func<DotNetSubCommandBase>>
{ {
AddProjectToSolutionCommand.Create,
AddProjectToProjectReferenceCommand.Create, AddProjectToProjectReferenceCommand.Create,
AddPackageReferenceCommand.Create AddPackageReferenceCommand.Create,
}; };
public static int Run(string[] args) public static int Run(string[] args)

View file

@ -4,8 +4,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.List.ProjectToProjectReferences; using Microsoft.DotNet.Tools.List.ProjectToProjectReferences;
using Microsoft.DotNet.Tools.List.ProjectsInSolution;
namespace Microsoft.DotNet.Tools.List namespace Microsoft.DotNet.Tools.List
{ {
@ -13,10 +13,11 @@ namespace Microsoft.DotNet.Tools.List
{ {
protected override string CommandName => "list"; protected override string CommandName => "list";
protected override string FullCommandNameLocalized => LocalizableStrings.NetListCommand; protected override string FullCommandNameLocalized => LocalizableStrings.NetListCommand;
protected override string ArgumentName => Constants.ProjectArgumentName;
protected override string ArgumentDescriptionLocalized => CommonLocalizableStrings.ArgumentsProjectDescription;
internal override List<Func<DotNetSubCommandBase>> SubCommands => internal override List<Func<DotNetSubCommandBase>> SubCommands =>
new List<Func<DotNetSubCommandBase>> new List<Func<DotNetSubCommandBase>>
{ {
ListProjectsInSolutionCommand.Create,
ListProjectToProjectReferencesCommand.Create, ListProjectToProjectReferencesCommand.Create,
}; };

View file

@ -153,9 +153,9 @@ namespace Microsoft.DotNet.Tools.Migrate
{ {
List<string> args = new List<string>() List<string> args = new List<string>()
{ {
"add", "sln",
slnPath, slnPath,
"project", "add",
csprojPath, csprojPath,
}; };

View file

@ -4,8 +4,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Remove.PackageReference; using Microsoft.DotNet.Tools.Remove.PackageReference;
using Microsoft.DotNet.Tools.Remove.ProjectFromSolution;
using Microsoft.DotNet.Tools.Remove.ProjectToProjectReference; using Microsoft.DotNet.Tools.Remove.ProjectToProjectReference;
namespace Microsoft.DotNet.Tools.Remove namespace Microsoft.DotNet.Tools.Remove
@ -14,10 +14,11 @@ namespace Microsoft.DotNet.Tools.Remove
{ {
protected override string CommandName => "remove"; protected override string CommandName => "remove";
protected override string FullCommandNameLocalized => LocalizableStrings.NetRemoveCommand; protected override string FullCommandNameLocalized => LocalizableStrings.NetRemoveCommand;
protected override string ArgumentName => Constants.ProjectArgumentName;
protected override string ArgumentDescriptionLocalized => CommonLocalizableStrings.ArgumentsProjectDescription;
internal override List<Func<DotNetSubCommandBase>> SubCommands => internal override List<Func<DotNetSubCommandBase>> SubCommands =>
new List<Func<DotNetSubCommandBase>> new List<Func<DotNetSubCommandBase>>
{ {
RemoveProjectFromSolutionCommand.Create,
RemoveProjectToProjectReferenceCommand.Create, RemoveProjectToProjectReferenceCommand.Create,
RemovePackageReferenceCommand.Create RemovePackageReferenceCommand.Create
}; };

View file

@ -0,0 +1,34 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Sln.Add;
using Microsoft.DotNet.Tools.Sln.List;
using Microsoft.DotNet.Tools.Sln.Remove;
namespace Microsoft.DotNet.Tools.Sln
{
public class SlnCommand : DotNetTopLevelCommandBase
{
protected override string CommandName => "sln";
protected override string FullCommandNameLocalized => LocalizableStrings.AppFullName;
protected override string ArgumentName => Constants.SolutionArgumentName;
protected override string ArgumentDescriptionLocalized => CommonLocalizableStrings.ArgumentsSolutionDescription;
internal override List<Func<DotNetSubCommandBase>> SubCommands =>
new List<Func<DotNetSubCommandBase>>
{
AddProjectToSolutionCommand.Create,
ListProjectsInSolutionCommand.Create,
RemoveProjectFromSolutionCommand.Create
};
public static int Run(string[] args)
{
var command = new SlnCommand();
return command.RunCommand(args);
}
}
}

View file

@ -8,12 +8,13 @@ using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.Cli.Sln.Internal;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common; using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Tools.Sln;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace Microsoft.DotNet.Tools.Add.ProjectToSolution namespace Microsoft.DotNet.Tools.Sln.Add
{ {
internal class AddProjectToSolutionCommand : DotNetSubCommandBase internal class AddProjectToSolutionCommand : DotNetSubCommandBase
{ {
@ -21,11 +22,11 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToSolution
{ {
var command = new AddProjectToSolutionCommand() var command = new AddProjectToSolutionCommand()
{ {
Name = "project", Name = "add",
FullName = LocalizableStrings.AppFullName, FullName = LocalizableStrings.AddAppFullName,
Description = LocalizableStrings.AppDescription, Description = LocalizableStrings.AddSubcommandHelpText,
HandleRemainingArguments = true, HandleRemainingArguments = true,
ArgumentSeparatorHelpText = LocalizableStrings.AppHelpText, ArgumentSeparatorHelpText = LocalizableStrings.AddSubcommandHelpText,
}; };
command.HelpOption("-h|--help"); command.HelpOption("-h|--help");

View file

@ -5,8 +5,9 @@ using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.Cli.Sln.Internal;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common; using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Tools.Sln;
namespace Microsoft.DotNet.Tools.List.ProjectsInSolution namespace Microsoft.DotNet.Tools.Sln.List
{ {
internal class ListProjectsInSolutionCommand : DotNetSubCommandBase internal class ListProjectsInSolutionCommand : DotNetSubCommandBase
{ {
@ -14,9 +15,9 @@ namespace Microsoft.DotNet.Tools.List.ProjectsInSolution
{ {
var command = new ListProjectsInSolutionCommand() var command = new ListProjectsInSolutionCommand()
{ {
Name = "projects", Name = "list",
FullName = LocalizableStrings.AppFullName, FullName = LocalizableStrings.ListAppFullName,
Description = LocalizableStrings.AppDescription, Description = LocalizableStrings.ListSubcommandHelpText,
}; };
command.HelpOption("-h|--help"); command.HelpOption("-h|--help");

View file

@ -5,12 +5,13 @@ using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.Cli.Sln.Internal;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common; using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Tools.Sln;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace Microsoft.DotNet.Tools.Remove.ProjectFromSolution namespace Microsoft.DotNet.Tools.Sln.Remove
{ {
internal class RemoveProjectFromSolutionCommand : DotNetSubCommandBase internal class RemoveProjectFromSolutionCommand : DotNetSubCommandBase
{ {
@ -18,11 +19,11 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectFromSolution
{ {
var command = new RemoveProjectFromSolutionCommand() var command = new RemoveProjectFromSolutionCommand()
{ {
Name = "project", Name = "remove",
FullName = LocalizableStrings.AppFullName, FullName = LocalizableStrings.RemoveAppFullName,
Description = LocalizableStrings.AppDescription, Description = LocalizableStrings.RemoveSubcommandHelpText,
HandleRemainingArguments = true, HandleRemainingArguments = true,
ArgumentSeparatorHelpText = LocalizableStrings.AppHelpText, ArgumentSeparatorHelpText = LocalizableStrings.RemoveSubcommandHelpText,
}; };
command.HelpOption("-h|--help"); command.HelpOption("-h|--help");

View file

@ -16,10 +16,10 @@ namespace Microsoft.DotNet.Cli.Add.P2P.Tests
{ {
private const string HelpText = @".NET Add Project to Project (p2p) reference Command private const string HelpText = @".NET Add Project to Project (p2p) reference Command
Usage: dotnet add <PROJECT_OR_SOLUTION> p2p [options] [args] Usage: dotnet add <PROJECT> p2p [options] [args]
Arguments: Arguments:
<PROJECT_OR_SOLUTION> The project or solution to operation on. If a file is not specified, the current directory is searched. <PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
Options: Options:
-h|--help Show help information -h|--help Show help information

View file

@ -15,10 +15,10 @@ namespace Microsoft.DotNet.Cli.List.P2P.Tests
{ {
private const string HelpText = @".NET Core Project-to-Project dependency viewer private const string HelpText = @".NET Core Project-to-Project dependency viewer
Usage: dotnet list <PROJECT_OR_SOLUTION> p2ps [options] Usage: dotnet list <PROJECT> p2ps [options]
Arguments: Arguments:
<PROJECT_OR_SOLUTION> The project or solution to operation on. If a file is not specified, the current directory is searched. <PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
Options: Options:
-h|--help Show help information"; -h|--help Show help information";

View file

@ -15,10 +15,10 @@ namespace Microsoft.DotNet.Cli.Remove.P2P.Tests
{ {
private const string HelpText = @".NET Remove Project to Project (p2p) reference Command private const string HelpText = @".NET Remove Project to Project (p2p) reference Command
Usage: dotnet remove <PROJECT_OR_SOLUTION> p2p [options] [args] Usage: dotnet remove <PROJECT> p2p [options] [args]
Arguments: Arguments:
<PROJECT_OR_SOLUTION> The project or solution to operation on. If a file is not specified, the current directory is searched. <PROJECT> The project file to operate on. If a file is not specified, the command will search the current directory for one.
Options: Options:
-h|--help Show help information -h|--help Show help information

View file

@ -10,22 +10,22 @@ using System.IO;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
namespace Microsoft.DotNet.Cli.Add.Proj.Tests namespace Microsoft.DotNet.Cli.Sln.Add.Tests
{ {
public class GivenDotnetAddProj : TestBase public class GivenDotnetSlnAdd : TestBase
{ {
private string HelpText = @".NET Add Project to Solution Command private string HelpText = @".NET Add project(s) to a solution file Command
Usage: dotnet add <PROJECT_OR_SOLUTION> project [options] [args] Usage: dotnet sln <SLN_FILE> add [options] [args]
Arguments: Arguments:
<PROJECT_OR_SOLUTION> The project or solution to operation on. If a file is not specified, the current directory is searched. <SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
Options: Options:
-h|--help Show help information -h|--help Show help information
Additional Arguments: Additional Arguments:
Projects to add to solution Add a specified project(s) to the solution.
"; ";
private const string ExpectedSlnFileAfterAddingLibProj = @" private const string ExpectedSlnFileAfterAddingLibProj = @"
@ -185,7 +185,7 @@ EndGlobal
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"add project {helpArg}"); .ExecuteWithCapturedOutput($"sln add {helpArg}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
} }
@ -196,7 +196,7 @@ EndGlobal
public void WhenNoCommandIsPassedItPrintsError(string commandName) public void WhenNoCommandIsPassedItPrintsError(string commandName)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"add {commandName}"); .ExecuteWithCapturedOutput($"sln {commandName}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Required command was not provided."); cmd.StdErr.Should().Be("Required command was not provided.");
} }
@ -205,7 +205,7 @@ EndGlobal
public void WhenTooManyArgumentsArePassedItPrintsError() public void WhenTooManyArgumentsArePassedItPrintsError()
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput("add one.sln two.sln three.sln project"); .ExecuteWithCapturedOutput("sln one.sln two.sln three.sln add");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Unrecognized command or argument 'two.sln'"); cmd.StdErr.Should().Be("Unrecognized command or argument 'two.sln'");
cmd.StdOut.Should().Be("Specify --help for a list of available options and commands."); cmd.StdOut.Should().Be("Specify --help for a list of available options and commands.");
@ -220,7 +220,7 @@ EndGlobal
public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solutionName) public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solutionName)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"add {solutionName} project p.csproj"); .ExecuteWithCapturedOutput($"sln {solutionName} add p.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`."); cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -239,7 +239,7 @@ EndGlobal
var projectToAdd = Path.Combine("Lib", "Lib.csproj"); var projectToAdd = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add InvalidSolution.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln InvalidSolution.sln add {projectToAdd}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Invalid format in line 1: File header is missing"); cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Invalid format in line 1: File header is missing");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -259,7 +259,7 @@ EndGlobal
var projectToAdd = Path.Combine("Lib", "Lib.csproj"); var projectToAdd = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln add {projectToAdd}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`. Invalid format in line 1: File header is missing"); cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`. Invalid format in line 1: File header is missing");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -277,7 +277,7 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput(@"add App.sln project"); .ExecuteWithCapturedOutput(@"sln App.sln add");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("You must specify at least one project to add."); cmd.StdErr.Should().Be("You must specify at least one project to add.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -296,7 +296,7 @@ EndGlobal
var solutionPath = Path.Combine(projectDirectory, "App"); var solutionPath = Path.Combine(projectDirectory, "App");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(solutionPath) .WithWorkingDirectory(solutionPath)
.ExecuteWithCapturedOutput(@"add project App.csproj"); .ExecuteWithCapturedOutput(@"sln add App.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory."); cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -315,7 +315,7 @@ EndGlobal
var projectToAdd = Path.Combine("Lib", "Lib.csproj"); var projectToAdd = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln add {projectToAdd}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use."); cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -334,7 +334,7 @@ EndGlobal
var projectToAdd = Path.Combine("src", "Lib", "Lib.csproj"); var projectToAdd = Path.Combine("src", "Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Pass(); cmd.Should().Pass();
var slnPath = Path.Combine(projectDirectory, "App.sln"); var slnPath = Path.Combine(projectDirectory, "App.sln");
@ -362,7 +362,7 @@ EndGlobal
var projectToAdd = "Lib/Lib.csproj"; var projectToAdd = "Lib/Lib.csproj";
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Pass(); cmd.Should().Pass();
var slnPath = Path.Combine(projectDirectory, "App.sln"); var slnPath = Path.Combine(projectDirectory, "App.sln");
@ -393,7 +393,7 @@ EndGlobal
var projectPath = Path.Combine("Lib", "Lib.csproj"); var projectPath = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be($"Project `{projectPath}` added to the solution."); cmd.StdOut.Should().Be($"Project `{projectPath}` added to the solution.");
cmd.StdErr.Should().BeEmpty(); cmd.StdErr.Should().BeEmpty();
@ -415,7 +415,7 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput(@"add App.sln project App/App.csproj Lib/Lib.csproj"); .ExecuteWithCapturedOutput(@"sln App.sln add App/App.csproj Lib/Lib.csproj");
cmd.Should().Pass(); cmd.Should().Pass();
var slnPath = Path.Combine(projectDirectory, "App.sln"); var slnPath = Path.Combine(projectDirectory, "App.sln");
@ -463,7 +463,7 @@ EndGlobal
var projectToAdd = Path.Combine("Lib", "Lib.csproj"); var projectToAdd = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be($"Solution {solutionPath} already contains project {projectToAdd}."); cmd.StdOut.Should().Be($"Solution {solutionPath} already contains project {projectToAdd}.");
cmd.StdErr.Should().BeEmpty(); cmd.StdErr.Should().BeEmpty();
@ -485,7 +485,7 @@ EndGlobal
var projectToAdd = Path.Combine("Lib", "Lib.csproj"); var projectToAdd = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd} idonotexist.csproj"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd} idonotexist.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Project `idonotexist.csproj` does not exist."); cmd.StdErr.Should().Be("Project `idonotexist.csproj` does not exist.");
@ -510,7 +510,7 @@ EndGlobal
var projectToAdd = Path.Combine("UnknownProject", "UnknownProject.unknownproj"); var projectToAdd = Path.Combine("UnknownProject", "UnknownProject.unknownproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().BeVisuallyEquivalentTo("Unsupported project type. Please check with your sdk provider."); cmd.StdErr.Should().BeVisuallyEquivalentTo("Unsupported project type. Please check with your sdk provider.");
@ -541,7 +541,7 @@ EndGlobal
var projectToAdd = Path.Combine(projectDir, projectName); var projectToAdd = Path.Combine(projectDir, projectName);
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}"); .ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be($"Project `{projectToAdd}` added to the solution."); cmd.StdOut.Should().Be($"Project `{projectToAdd}` added to the solution.");
cmd.StdErr.Should().BeEmpty(); cmd.StdErr.Should().BeEmpty();

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework> <TargetFramework>netcoreapp1.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-add-proj.Tests</AssemblyName> <AssemblyName>dotnet-sln-add.Tests</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback> <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
</PropertyGroup> </PropertyGroup>

View file

@ -9,16 +9,16 @@ using System.IO;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
namespace Microsoft.DotNet.Cli.List.Proj.Tests namespace Microsoft.DotNet.Cli.Sln.List.Tests
{ {
public class GivenDotnetListProj : TestBase public class GivenDotnetSlnList : TestBase
{ {
private const string HelpText = @".NET Projects in Solution viewer private const string HelpText = @".NET List project(s) in a solution file Command
Usage: dotnet list <PROJECT_OR_SOLUTION> projects [options] Usage: dotnet sln <SLN_FILE> list [options]
Arguments: Arguments:
<PROJECT_OR_SOLUTION> The project or solution to operation on. If a file is not specified, the current directory is searched. <SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
Options: Options:
-h|--help Show help information"; -h|--help Show help information";
@ -29,7 +29,7 @@ Options:
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"list projects {helpArg}"); .ExecuteWithCapturedOutput($"sln list {helpArg}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
} }
@ -40,7 +40,7 @@ Options:
public void WhenNoCommandIsPassedItPrintsError(string commandName) public void WhenNoCommandIsPassedItPrintsError(string commandName)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"list {commandName}"); .ExecuteWithCapturedOutput($"sln {commandName}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Required command was not provided."); cmd.StdErr.Should().Be("Required command was not provided.");
} }
@ -49,7 +49,7 @@ Options:
public void WhenTooManyArgumentsArePassedItPrintsError() public void WhenTooManyArgumentsArePassedItPrintsError()
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput("list one.sln two.sln three.sln projects"); .ExecuteWithCapturedOutput("sln one.sln two.sln three.sln list");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Unrecognized command or argument 'two.sln'"); cmd.StdErr.Should().Be("Unrecognized command or argument 'two.sln'");
} }
@ -63,7 +63,7 @@ Options:
public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solutionName) public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solutionName)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"list {solutionName} projects"); .ExecuteWithCapturedOutput($"sln {solutionName} list");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`."); cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -81,7 +81,7 @@ Options:
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("list InvalidSolution.sln projects"); .ExecuteWithCapturedOutput("sln InvalidSolution.sln list");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Invalid format in line 1: File header is missing"); cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Invalid format in line 1: File header is missing");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -100,7 +100,7 @@ Options:
var solutionFullPath = Path.Combine(projectDirectory, "InvalidSolution.sln"); var solutionFullPath = Path.Combine(projectDirectory, "InvalidSolution.sln");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("list projects"); .ExecuteWithCapturedOutput("sln list");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionFullPath}`. Invalid format in line 1: File header is missing"); cmd.StdErr.Should().Be($"Invalid solution `{solutionFullPath}`. Invalid format in line 1: File header is missing");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -119,7 +119,7 @@ Options:
var solutionDir = Path.Combine(projectDirectory, "App"); var solutionDir = Path.Combine(projectDirectory, "App");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(solutionDir) .WithWorkingDirectory(solutionDir)
.ExecuteWithCapturedOutput("list projects"); .ExecuteWithCapturedOutput("sln list");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionDir + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory."); cmd.StdErr.Should().Be($"Specified solution file {solutionDir + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -137,7 +137,7 @@ Options:
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("list projects"); .ExecuteWithCapturedOutput("sln list");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use."); cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -155,7 +155,7 @@ Options:
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("list projects"); .ExecuteWithCapturedOutput("sln list");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be("No projects found in the solution."); cmd.StdOut.Should().Be("No projects found in the solution.");
} }
@ -177,7 +177,7 @@ Options:
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("list projects"); .ExecuteWithCapturedOutput("sln list");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText); cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
} }

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework> <TargetFramework>netcoreapp1.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-list-proj.Tests</AssemblyName> <AssemblyName>dotnet-sln-list.Tests</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback> <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
</PropertyGroup> </PropertyGroup>

View file

@ -9,22 +9,22 @@ using System.IO;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
namespace Microsoft.DotNet.Cli.Remove.Project.Tests namespace Microsoft.DotNet.Cli.Sln.Remove.Tests
{ {
public class GivenDotnetRemoveProj : TestBase public class GivenDotnetSlnRemove : TestBase
{ {
private const string HelpText = @".NET Remove Project from Solution Command private const string HelpText = @".NET Remove project(s) from a solution file Command
Usage: dotnet remove <PROJECT_OR_SOLUTION> project [options] [args] Usage: dotnet sln <SLN_FILE> remove [options] [args]
Arguments: Arguments:
<PROJECT_OR_SOLUTION> The project or solution to operation on. If a file is not specified, the current directory is searched. <SLN_FILE> Solution file to operate on. If not specified, the command will search the current directory for one.
Options: Options:
-h|--help Show help information -h|--help Show help information
Additional Arguments: Additional Arguments:
Projects to remove from a solution Remove the specified project(s) from the solution. The project is not impacted.
"; ";
private const string ExpectedSlnContentsAfterRemove = @" private const string ExpectedSlnContentsAfterRemove = @"
@ -166,7 +166,7 @@ EndGlobal
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"remove project {helpArg}"); .ExecuteWithCapturedOutput($"sln remove {helpArg}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
} }
@ -175,7 +175,7 @@ EndGlobal
public void WhenTooManyArgumentsArePassedItPrintsError() public void WhenTooManyArgumentsArePassedItPrintsError()
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput("remove one.sln two.sln three.sln project"); .ExecuteWithCapturedOutput("sln one.sln two.sln three.sln remove");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Unrecognized command or argument 'two.sln'"); cmd.StdErr.Should().Be("Unrecognized command or argument 'two.sln'");
cmd.StdOut.Should().Be("Specify --help for a list of available options and commands."); cmd.StdOut.Should().Be("Specify --help for a list of available options and commands.");
@ -187,7 +187,7 @@ EndGlobal
public void WhenNoCommandIsPassedItPrintsError(string commandName) public void WhenNoCommandIsPassedItPrintsError(string commandName)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"remove {commandName}"); .ExecuteWithCapturedOutput($"sln {commandName}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Required command was not provided."); cmd.StdErr.Should().Be("Required command was not provided.");
} }
@ -201,7 +201,7 @@ EndGlobal
public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solutionName) public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solutionName)
{ {
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"remove {solutionName} project p.csproj"); .ExecuteWithCapturedOutput($"sln {solutionName} remove p.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`."); cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -220,7 +220,7 @@ EndGlobal
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove InvalidSolution.sln project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln InvalidSolution.sln remove {projectToRemove}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Invalid format in line 1: File header is missing"); cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Invalid format in line 1: File header is missing");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -240,7 +240,7 @@ EndGlobal
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`. Invalid format in line 1: File header is missing"); cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`. Invalid format in line 1: File header is missing");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -258,7 +258,7 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput(@"remove App.sln project"); .ExecuteWithCapturedOutput(@"sln App.sln remove");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("You must specify at least one project to remove."); cmd.StdErr.Should().Be("You must specify at least one project to remove.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -277,7 +277,7 @@ EndGlobal
var solutionPath = Path.Combine(projectDirectory, "App"); var solutionPath = Path.Combine(projectDirectory, "App");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(solutionPath) .WithWorkingDirectory(solutionPath)
.ExecuteWithCapturedOutput(@"remove project App.csproj"); .ExecuteWithCapturedOutput(@"sln remove App.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory."); cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -296,7 +296,7 @@ EndGlobal
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use."); cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
@ -316,7 +316,7 @@ EndGlobal
var contentBefore = File.ReadAllText(solutionPath); var contentBefore = File.ReadAllText(solutionPath);
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("remove project referenceDoesNotExistInSln.csproj"); .ExecuteWithCapturedOutput("sln remove referenceDoesNotExistInSln.csproj");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be("Project reference `referenceDoesNotExistInSln.csproj` could not be found."); cmd.StdOut.Should().Be("Project reference `referenceDoesNotExistInSln.csproj` could not be found.");
File.ReadAllText(solutionPath) File.ReadAllText(solutionPath)
@ -340,7 +340,7 @@ EndGlobal
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be($"Project reference `{projectToRemove}` removed."); cmd.StdOut.Should().Be($"Project reference `{projectToRemove}` removed.");
@ -366,7 +366,7 @@ EndGlobal
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
string outputText = $@"Project reference `{projectToRemove}` removed. string outputText = $@"Project reference `{projectToRemove}` removed.
@ -395,7 +395,7 @@ Project reference `{projectToRemove}` removed.";
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project idontexist.csproj {projectToRemove} idontexisteither.csproj"); .ExecuteWithCapturedOutput($"sln remove idontexist.csproj {projectToRemove} idontexisteither.csproj");
cmd.Should().Pass(); cmd.Should().Pass();
string outputText = $@"Project reference `idontexist.csproj` could not be found. string outputText = $@"Project reference `idontexist.csproj` could not be found.
@ -425,7 +425,7 @@ Project reference `idontexisteither.csproj` could not be found.";
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
File.ReadAllText(solutionPath) File.ReadAllText(solutionPath)
@ -449,7 +449,7 @@ Project reference `idontexisteither.csproj` could not be found.";
var projectToRemove = Path.Combine("Lib", "Lib.csproj"); var projectToRemove = Path.Combine("Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
new DotnetCommand() new DotnetCommand()
@ -492,7 +492,7 @@ Project reference `idontexisteither.csproj` could not be found.";
var projectsToRemove = $"{libPath} {appPath}"; var projectsToRemove = $"{libPath} {appPath}";
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectsToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectsToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
File.ReadAllText(solutionPath) File.ReadAllText(solutionPath)
@ -514,7 +514,7 @@ Project reference `idontexisteither.csproj` could not be found.";
var projectToRemove = Path.Combine("src", "NotLastProjInSrc", "NotLastProjInSrc.csproj"); var projectToRemove = Path.Combine("src", "NotLastProjInSrc", "NotLastProjInSrc.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
File.ReadAllText(solutionPath) File.ReadAllText(solutionPath)
@ -536,7 +536,7 @@ Project reference `idontexisteither.csproj` could not be found.";
var projectToRemove = Path.Combine("src", "Lib", "Lib.csproj"); var projectToRemove = Path.Combine("src", "Lib", "Lib.csproj");
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"remove project {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
File.ReadAllText(solutionPath) File.ReadAllText(solutionPath)

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework> <TargetFramework>netcoreapp1.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-remove-proj.Tests</AssemblyName> <AssemblyName>dotnet-sln-remove.Tests</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback> <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
</PropertyGroup> </PropertyGroup>