Add support for accepting directories to add and remove reference commands.
This commit adds support for specifying directories containing a single project to both the `add reference` and `remove reference` commands. Fixes issue #7343.
This commit is contained in:
parent
bcf13b93cc
commit
1ddf5c87c7
19 changed files with 125 additions and 76 deletions
TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Empty
src/dotnet
CommonLocalizableStrings.resx
commands
xlf
CommonLocalizableStrings.cs.xlfCommonLocalizableStrings.de.xlfCommonLocalizableStrings.es.xlfCommonLocalizableStrings.fr.xlfCommonLocalizableStrings.it.xlfCommonLocalizableStrings.ja.xlfCommonLocalizableStrings.ko.xlfCommonLocalizableStrings.pl.xlfCommonLocalizableStrings.pt-BR.xlfCommonLocalizableStrings.ru.xlfCommonLocalizableStrings.tr.xlfCommonLocalizableStrings.zh-Hans.xlfCommonLocalizableStrings.zh-Hant.xlf
test
dotnet-add-reference.Tests
dotnet-remove-reference.Tests
|
@ -0,0 +1,2 @@
|
||||||
|
This directory is intentionally empty.
|
||||||
|
|
|
@ -345,9 +345,6 @@
|
||||||
<data name="SolutionDoesNotExist" xml:space="preserve">
|
<data name="SolutionDoesNotExist" xml:space="preserve">
|
||||||
<value>Specified solution file {0} does not exist, or there is no solution file in the directory.</value>
|
<value>Specified solution file {0} does not exist, or there is no solution file in the directory.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ReferenceDoesNotExist" xml:space="preserve">
|
|
||||||
<value>Reference {0} does not exist.</value>
|
|
||||||
</data>
|
|
||||||
<data name="ReferenceIsInvalid" xml:space="preserve">
|
<data name="ReferenceIsInvalid" xml:space="preserve">
|
||||||
<value>Reference `{0}` is invalid.</value>
|
<value>Reference `{0}` is invalid.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -45,9 +45,9 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
|
|
||||||
var frameworkString = _appliedCommand.ValueOrDefault<string>("framework");
|
var frameworkString = _appliedCommand.ValueOrDefault<string>("framework");
|
||||||
|
|
||||||
PathUtility.EnsureAllPathsExist(_appliedCommand.Arguments, CommonLocalizableStrings.ReferenceDoesNotExist);
|
PathUtility.EnsureAllPathsExist(_appliedCommand.Arguments, CommonLocalizableStrings.CouldNotFindProjectOrDirectory, true);
|
||||||
List<MsbuildProject> refs = _appliedCommand.Arguments
|
List<MsbuildProject> refs = _appliedCommand.Arguments
|
||||||
.Select((r) => MsbuildProject.FromFile(projects, r))
|
.Select((r) => MsbuildProject.FromFileOrDirectory(projects, r))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (frameworkString == null)
|
if (frameworkString == null)
|
||||||
|
@ -90,9 +90,10 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToProjectReference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var relativePathReferences = _appliedCommand.Arguments.Select((r) =>
|
var relativePathReferences = refs.Select((r) =>
|
||||||
Path.GetRelativePath(msbuildProj.ProjectDirectory, Path.GetFullPath(r)))
|
Path.GetRelativePath(
|
||||||
.ToList();
|
msbuildProj.ProjectDirectory,
|
||||||
|
r.ProjectRootElement.FullPath)).ToList();
|
||||||
|
|
||||||
int numberOfAddedReferences = msbuildProj.AddProjectToProjectReferences(
|
int numberOfAddedReferences = msbuildProj.AddProjectToProjectReferences(
|
||||||
frameworkString,
|
frameworkString,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Build.Evaluation;
|
using Microsoft.Build.Evaluation;
|
||||||
using Microsoft.DotNet.Cli;
|
using Microsoft.DotNet.Cli;
|
||||||
|
@ -42,10 +43,22 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectToProjectReference
|
||||||
public override int Execute()
|
public override int Execute()
|
||||||
{
|
{
|
||||||
var msbuildProj = MsbuildProject.FromFileOrDirectory(new ProjectCollection(), _fileOrDirectory);
|
var msbuildProj = MsbuildProject.FromFileOrDirectory(new ProjectCollection(), _fileOrDirectory);
|
||||||
|
var references = _appliedCommand.Arguments.Select(p => {
|
||||||
|
var fullPath = Path.GetFullPath(p);
|
||||||
|
if (!Directory.Exists(fullPath))
|
||||||
|
{
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Path.GetRelativePath(
|
||||||
|
msbuildProj.ProjectRootElement.FullPath,
|
||||||
|
MsbuildProject.GetProjectFileFromDirectory(fullPath).FullName
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
int numberOfRemovedReferences = msbuildProj.RemoveProjectToProjectReferences(
|
int numberOfRemovedReferences = msbuildProj.RemoveProjectToProjectReferences(
|
||||||
_appliedCommand.ValueOrDefault<string>("framework"),
|
_appliedCommand.ValueOrDefault<string>("framework"),
|
||||||
_appliedCommand.Arguments);
|
references);
|
||||||
|
|
||||||
if (numberOfRemovedReferences != 0)
|
if (numberOfRemovedReferences != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Aplikace</target>
|
<target state="translated">Aplikace</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">Odkaz na {0} neexistuje.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Odkaz na {0} byl přidán do projektu.</target>
|
<target state="translated">Odkaz na {0} byl přidán do projektu.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Anwendung</target>
|
<target state="translated">Anwendung</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">Der Verweis "{0}" ist nicht vorhanden.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Der Verweis "{0}" wurde dem Projekt hinzugefügt.</target>
|
<target state="translated">Der Verweis "{0}" wurde dem Projekt hinzugefügt.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Aplicación</target>
|
<target state="translated">Aplicación</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">La referencia {0} no existe.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Se ha agregado la referencia "{0}" al proyecto.</target>
|
<target state="translated">Se ha agregado la referencia "{0}" al proyecto.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Application</target>
|
<target state="translated">Application</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">La référence {0} n'existe pas.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Référence '{0}' ajoutée au projet.</target>
|
<target state="translated">Référence '{0}' ajoutée au projet.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Applicazione</target>
|
<target state="translated">Applicazione</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">Il riferimento {0} non esiste.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Il riferimento `{0}` è stato aggiunto al progetto.</target>
|
<target state="translated">Il riferimento `{0}` è stato aggiunto al progetto.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">アプリケーション</target>
|
<target state="translated">アプリケーション</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">参照 {0} は存在しません。</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">参照 `{0}` がプロジェクトに追加されました。</target>
|
<target state="translated">参照 `{0}` がプロジェクトに追加されました。</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">응용 프로그램</target>
|
<target state="translated">응용 프로그램</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">{0} 참조가 없습니다.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">프로젝트에 '{0}' 참조가 추가되었습니다.</target>
|
<target state="translated">프로젝트에 '{0}' 참조가 추가되었습니다.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Aplikacja</target>
|
<target state="translated">Aplikacja</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">Odwołanie {0} nie istnieje.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Do projektu zostało dodane odwołanie „{0}”.</target>
|
<target state="translated">Do projektu zostało dodane odwołanie „{0}”.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Aplicativo</target>
|
<target state="translated">Aplicativo</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">A referência {0} não existe.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">A referência ‘{0}’ foi adicionada ao projeto.</target>
|
<target state="translated">A referência ‘{0}’ foi adicionada ao projeto.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Приложение</target>
|
<target state="translated">Приложение</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">Ссылка {0} не существует.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">Ссылка "{0}" добавлена в проект.</target>
|
<target state="translated">Ссылка "{0}" добавлена в проект.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">Uygulama</target>
|
<target state="translated">Uygulama</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">{0} başvurusu yok.</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">`{0}` başvurusu projeye eklendi.</target>
|
<target state="translated">`{0}` başvurusu projeye eklendi.</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">应用程序</target>
|
<target state="translated">应用程序</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">引用 {0} 不存在。</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">已将引用“{0}”添加到项目。</target>
|
<target state="translated">已将引用“{0}”添加到项目。</target>
|
||||||
|
|
|
@ -97,11 +97,6 @@
|
||||||
<target state="translated">應用程式</target>
|
<target state="translated">應用程式</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="ReferenceDoesNotExist">
|
|
||||||
<source>Reference {0} does not exist.</source>
|
|
||||||
<target state="translated">參考 {0} 不存在。</target>
|
|
||||||
<note />
|
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="ReferenceAddedToTheProject">
|
<trans-unit id="ReferenceAddedToTheProject">
|
||||||
<source>Reference `{0}` added to the project.</source>
|
<source>Reference `{0}` added to the project.</source>
|
||||||
<target state="translated">參考 `{0}` 已新增至專案。</target>
|
<target state="translated">參考 `{0}` 已新增至專案。</target>
|
||||||
|
|
|
@ -559,7 +559,7 @@ Commands:
|
||||||
.WithProject(lib.CsProjName)
|
.WithProject(lib.CsProjName)
|
||||||
.Execute("\"IDoNotExist.csproj\"");
|
.Execute("\"IDoNotExist.csproj\"");
|
||||||
cmd.Should().Fail();
|
cmd.Should().Fail();
|
||||||
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ReferenceDoesNotExist, "IDoNotExist.csproj"));
|
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, "IDoNotExist.csproj"));
|
||||||
lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
|
lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ Commands:
|
||||||
.WithProject(lib.CsProjPath)
|
.WithProject(lib.CsProjPath)
|
||||||
.Execute($"\"{setup.ValidRefCsprojPath}\" \"IDoNotExist.csproj\"");
|
.Execute($"\"{setup.ValidRefCsprojPath}\" \"IDoNotExist.csproj\"");
|
||||||
cmd.Should().Fail();
|
cmd.Should().Fail();
|
||||||
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ReferenceDoesNotExist, "IDoNotExist.csproj"));
|
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, "IDoNotExist.csproj"));
|
||||||
lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
|
lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,5 +693,55 @@ Commands:
|
||||||
cmd.StdErr.Should().MatchRegex(" - net45");
|
cmd.StdErr.Should().MatchRegex(" - net45");
|
||||||
net45lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
|
net45lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryContainingProjectIsGivenReferenceIsAdded()
|
||||||
|
{
|
||||||
|
var setup = Setup();
|
||||||
|
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||||
|
|
||||||
|
var result = new AddReferenceCommand()
|
||||||
|
.WithWorkingDirectory(setup.TestRoot)
|
||||||
|
.WithProject(lib.CsProjPath)
|
||||||
|
.Execute($"\"{Path.GetDirectoryName(setup.ValidRefCsprojPath)}\"");
|
||||||
|
|
||||||
|
result.Should().Pass();
|
||||||
|
result.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"ValidRef\ValidRef.csproj"));
|
||||||
|
result.StdErr.Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryContainsNoProjectsItCancelsWholeOperation()
|
||||||
|
{
|
||||||
|
var setup = Setup();
|
||||||
|
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||||
|
|
||||||
|
var reference = "Empty";
|
||||||
|
var result = new AddReferenceCommand()
|
||||||
|
.WithWorkingDirectory(setup.TestRoot)
|
||||||
|
.WithProject(lib.CsProjPath)
|
||||||
|
.Execute(reference);
|
||||||
|
|
||||||
|
result.Should().Fail();
|
||||||
|
result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
|
||||||
|
result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, reference));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryContainsMultipleProjectsItCancelsWholeOperation()
|
||||||
|
{
|
||||||
|
var setup = Setup();
|
||||||
|
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||||
|
|
||||||
|
var reference = "MoreThanOne";
|
||||||
|
var result = new AddReferenceCommand()
|
||||||
|
.WithWorkingDirectory(setup.TestRoot)
|
||||||
|
.WithProject(lib.CsProjPath)
|
||||||
|
.Execute(reference);
|
||||||
|
|
||||||
|
result.Should().Fail();
|
||||||
|
result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
|
||||||
|
result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, reference));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -506,5 +506,56 @@ Commands:
|
||||||
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
|
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
|
||||||
csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0);
|
csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryContainingProjectIsGivenReferenceIsRemoved()
|
||||||
|
{
|
||||||
|
var setup = Setup();
|
||||||
|
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||||
|
var libref = AddLibRef(setup, lib);
|
||||||
|
|
||||||
|
var result = new RemoveReferenceCommand()
|
||||||
|
.WithWorkingDirectory(setup.TestRoot)
|
||||||
|
.WithProject(lib.CsProjPath)
|
||||||
|
.Execute($"\"{libref.CsProjPath}\"");
|
||||||
|
|
||||||
|
result.Should().Pass();
|
||||||
|
result.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
|
||||||
|
result.StdErr.Should().BeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryContainsNoProjectsItCancelsWholeOperation()
|
||||||
|
{
|
||||||
|
var setup = Setup();
|
||||||
|
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||||
|
|
||||||
|
var reference = "Empty";
|
||||||
|
var result = new RemoveReferenceCommand()
|
||||||
|
.WithWorkingDirectory(setup.TestRoot)
|
||||||
|
.WithProject(lib.CsProjPath)
|
||||||
|
.Execute(reference);
|
||||||
|
|
||||||
|
result.Should().Fail();
|
||||||
|
result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
|
||||||
|
result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, Path.Combine(setup.TestRoot, reference)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryContainsMultipleProjectsItCancelsWholeOperation()
|
||||||
|
{
|
||||||
|
var setup = Setup();
|
||||||
|
var lib = NewLibWithFrameworks(dir: setup.TestRoot);
|
||||||
|
|
||||||
|
var reference = "MoreThanOne";
|
||||||
|
var result = new RemoveReferenceCommand()
|
||||||
|
.WithWorkingDirectory(setup.TestRoot)
|
||||||
|
.WithProject(lib.CsProjPath)
|
||||||
|
.Execute(reference);
|
||||||
|
|
||||||
|
result.Should().Fail();
|
||||||
|
result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
|
||||||
|
result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, Path.Combine(setup.TestRoot, reference)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue