Merge branch 'master' into merges/release/2.1.3xx-to-master

This commit is contained in:
Livar 2018-04-06 09:05:57 -07:00 committed by GitHub
commit 7cb7535bae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
193 changed files with 4282 additions and 953 deletions

View file

@ -35,7 +35,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return null;
}
return $"/p:RuntimeIdentifier={_runtime}";
return $"-property:RuntimeIdentifier={_runtime}";
}
}
}

View file

@ -35,7 +35,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return null;
}
return $"/p:RuntimeIdentifier={_runtime}";
return $"-property:RuntimeIdentifier={_runtime}";
}
}
}

View file

@ -50,7 +50,7 @@ Common options:
Run 'dotnet COMMAND --help' for more information on a command.
sdk-options:
--version Display .NET Core SDK version.
--version Display .NET Core SDK version in use.
--info Display .NET Core information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.

View file

@ -9,25 +9,25 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetBuildInvocation
{
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m";
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m";
[Theory]
[InlineData(new string[] { }, "/t:Build")]
[InlineData(new string[] { "-o", "foo" }, "/t:Build /p:OutputPath=foo")]
[InlineData(new string[] { "-p:Verbosity=diag" }, "/t:Build -p:Verbosity=diag")]
[InlineData(new string[] { "--output", "foo" }, "/t:Build /p:OutputPath=foo")]
[InlineData(new string[] { "-o", "foo1 foo2" }, "/t:Build \"/p:OutputPath=foo1 foo2\"")]
[InlineData(new string[] { "--no-incremental" }, "/t:Rebuild")]
[InlineData(new string[] { "-r", "rid" }, "/t:Build /p:RuntimeIdentifier=rid")]
[InlineData(new string[] { "--runtime", "rid" }, "/t:Build /p:RuntimeIdentifier=rid")]
[InlineData(new string[] { "-c", "config" }, "/t:Build /p:Configuration=config")]
[InlineData(new string[] { "--configuration", "config" }, "/t:Build /p:Configuration=config")]
[InlineData(new string[] { "--version-suffix", "mysuffix" }, "/t:Build /p:VersionSuffix=mysuffix")]
[InlineData(new string[] { "--no-dependencies" }, "/t:Build /p:BuildProjectReferences=false")]
[InlineData(new string[] { "-v", "diag" }, "/t:Build /verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "/t:Build /verbosity:diag")]
[InlineData(new string[] { }, "-target:Build")]
[InlineData(new string[] { "-o", "foo" }, "-target:Build -property:OutputPath=foo")]
[InlineData(new string[] { "-property:Verbosity=diag" }, "-target:Build -property:Verbosity=diag")]
[InlineData(new string[] { "--output", "foo" }, "-target:Build -property:OutputPath=foo")]
[InlineData(new string[] { "-o", "foo1 foo2" }, "-target:Build \"-property:OutputPath=foo1 foo2\"")]
[InlineData(new string[] { "--no-incremental" }, "-target:Rebuild")]
[InlineData(new string[] { "-r", "rid" }, "-target:Build -property:RuntimeIdentifier=rid")]
[InlineData(new string[] { "--runtime", "rid" }, "-target:Build -property:RuntimeIdentifier=rid")]
[InlineData(new string[] { "-c", "config" }, "-target:Build -property:Configuration=config")]
[InlineData(new string[] { "--configuration", "config" }, "-target:Build -property:Configuration=config")]
[InlineData(new string[] { "--version-suffix", "mysuffix" }, "-target:Build -property:VersionSuffix=mysuffix")]
[InlineData(new string[] { "--no-dependencies" }, "-target:Build -property:BuildProjectReferences=false")]
[InlineData(new string[] { "-v", "diag" }, "-target:Build -verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "-target:Build -verbosity:diag")]
[InlineData(new string[] { "--no-incremental", "-o", "myoutput", "-r", "myruntime", "-v", "diag", "/ArbitrarySwitchForMSBuild" },
"/t:Rebuild /p:OutputPath=myoutput /p:RuntimeIdentifier=myruntime /verbosity:diag /ArbitrarySwitchForMSBuild")]
"-target:Rebuild -property:OutputPath=myoutput -property:RuntimeIdentifier=myruntime -verbosity:diag /ArbitrarySwitchForMSBuild")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
{
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
@ -39,14 +39,14 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
command.GetProcessStartInfo()
.Arguments.Should()
.Be($"{ExpectedPrefix} /restore /clp:Summary{expectedAdditionalArgs}");
.Be($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary{expectedAdditionalArgs}");
}
[Theory]
[InlineData(new string[] { "-f", "tfm" }, "/t:Restore", "/t:Build /p:TargetFramework=tfm")]
[InlineData(new string[] { "-f", "tfm" }, "-target:Restore", "-target:Build -property:TargetFramework=tfm")]
[InlineData(new string[] { "-o", "myoutput", "-f", "tfm", "-v", "diag", "/ArbitrarySwitchForMSBuild" },
"/t:Restore /p:OutputPath=myoutput /verbosity:diag /ArbitrarySwitchForMSBuild",
"/t:Build /p:OutputPath=myoutput /p:TargetFramework=tfm /verbosity:diag /ArbitrarySwitchForMSBuild")]
"-target:Restore -property:OutputPath=myoutput -verbosity:diag /ArbitrarySwitchForMSBuild",
"-target:Build -property:OutputPath=myoutput -property:TargetFramework=tfm -verbosity:diag /ArbitrarySwitchForMSBuild")]
public void MsbuildInvocationIsCorrectForSeparateRestore(
string[] args,
string expectedAdditionalArgsForRestore,
@ -63,7 +63,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
command.GetProcessStartInfo()
.Arguments.Should()
.Be($"{ExpectedPrefix} /nologo /clp:Summary{expectedAdditionalArgs}");
.Be($"{ExpectedPrefix} -nologo -consoleloggerparameters:Summary{expectedAdditionalArgs}");
}
}

View file

@ -10,26 +10,26 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetCleanInvocation
{
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m /v:normal /t:Clean";
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -verbosity:normal -target:Clean";
[Fact]
public void ItAddsProjectToMsbuildInvocation()
{
var msbuildPath = "<msbuildpath>";
CleanCommand.FromArgs(new string[] { "<project>" }, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be("exec <msbuildpath> /m /v:m /v:normal <project> /t:Clean");
.GetProcessStartInfo().Arguments.Should().Be("exec <msbuildpath> -maxcpucount -verbosity:m -verbosity:normal <project> -target:Clean");
}
[Theory]
[InlineData(new string[] { }, "")]
[InlineData(new string[] { "-o", "<output>" }, "/p:OutputPath=<output>")]
[InlineData(new string[] { "--output", "<output>" }, "/p:OutputPath=<output>")]
[InlineData(new string[] { "-f", "<framework>" }, "/p:TargetFramework=<framework>")]
[InlineData(new string[] { "--framework", "<framework>" }, "/p:TargetFramework=<framework>")]
[InlineData(new string[] { "-c", "<configuration>" }, "/p:Configuration=<configuration>")]
[InlineData(new string[] { "--configuration", "<configuration>" }, "/p:Configuration=<configuration>")]
[InlineData(new string[] { "-v", "diag" }, "/verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "/verbosity:diag")]
[InlineData(new string[] { "-o", "<output>" }, "-property:OutputPath=<output>")]
[InlineData(new string[] { "--output", "<output>" }, "-property:OutputPath=<output>")]
[InlineData(new string[] { "-f", "<framework>" }, "-property:TargetFramework=<framework>")]
[InlineData(new string[] { "--framework", "<framework>" }, "-property:TargetFramework=<framework>")]
[InlineData(new string[] { "-c", "<configuration>" }, "-property:Configuration=<configuration>")]
[InlineData(new string[] { "--configuration", "<configuration>" }, "-property:Configuration=<configuration>")]
[InlineData(new string[] { "-v", "diag" }, "-verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "-verbosity:diag")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
{
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");

View file

@ -86,8 +86,12 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
result.StdOut.Should().Contain(MSBuildHelpText);
}
[Fact]
public void WhenRestoreSourcesStartsWithUnixPathThenHttpsSourceIsParsedCorrectly()
[Theory]
[InlineData("/p")]
[InlineData("/property")]
[InlineData("-p")]
[InlineData("-property")]
public void WhenRestoreSourcesStartsWithUnixPathThenHttpsSourceIsParsedCorrectly(string propertyFormat)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
@ -104,7 +108,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
var result = new DotnetCommand()
.WithWorkingDirectory(root)
.Execute($"msbuild /p:RestoreSources={somePathThatExists};https://api.nuget.org/v3/index.json /t:restore LibraryWithUnresolvablePackageReference.csproj");
.Execute($"msbuild {propertyFormat}:RestoreSources={somePathThatExists};https://api.nuget.org/v3/index.json /t:restore LibraryWithUnresolvablePackageReference.csproj");
_output.WriteLine($"[STDOUT]\n{result.StdOut}\n[STDERR]\n{result.StdErr}");
@ -138,7 +142,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
allArgs.Should().NotBeNull();
allArgs.Should().Contain(
value => value.IndexOf("/distributedlogger", StringComparison.OrdinalIgnoreCase) >= 0,
value => value.IndexOf("-distributedlogger", StringComparison.OrdinalIgnoreCase) >= 0,
"The MSBuild logger argument should be specified when telemetry is enabled.");
}
}
@ -151,7 +155,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
allArgs.Should().NotBeNull();
allArgs.Should().NotContain(
value => value.IndexOf("/Logger", StringComparison.OrdinalIgnoreCase) >= 0,
value => value.IndexOf("-logger", StringComparison.OrdinalIgnoreCase) >= 0,
$"The MSBuild logger argument should not be specified when telemetry is disabled.");
}

View file

@ -11,23 +11,23 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetPackInvocation
{
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m /restore /t:pack";
const string ExpectedNoBuildPrefix = "exec <msbuildpath> /m /v:m /t:pack";
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -restore -target:pack";
const string ExpectedNoBuildPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -target:pack";
[Theory]
[InlineData(new string[] { }, "")]
[InlineData(new string[] { "-o", "<packageoutputpath>" }, "/p:PackageOutputPath=<packageoutputpath>")]
[InlineData(new string[] { "--output", "<packageoutputpath>" }, "/p:PackageOutputPath=<packageoutputpath>")]
[InlineData(new string[] { "--no-build" }, "/p:NoBuild=true")]
[InlineData(new string[] { "--include-symbols" }, "/p:IncludeSymbols=true")]
[InlineData(new string[] { "--include-source" }, "/p:IncludeSource=true")]
[InlineData(new string[] { "-c", "<config>" }, "/p:Configuration=<config>")]
[InlineData(new string[] { "--configuration", "<config>" }, "/p:Configuration=<config>")]
[InlineData(new string[] { "--version-suffix", "<versionsuffix>" }, "/p:VersionSuffix=<versionsuffix>")]
[InlineData(new string[] { "-s" }, "/p:Serviceable=true")]
[InlineData(new string[] { "--serviceable" }, "/p:Serviceable=true")]
[InlineData(new string[] { "-v", "diag" }, "/verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "/verbosity:diag")]
[InlineData(new string[] { "-o", "<packageoutputpath>" }, "-property:PackageOutputPath=<packageoutputpath>")]
[InlineData(new string[] { "--output", "<packageoutputpath>" }, "-property:PackageOutputPath=<packageoutputpath>")]
[InlineData(new string[] { "--no-build" }, "-property:NoBuild=true")]
[InlineData(new string[] { "--include-symbols" }, "-property:IncludeSymbols=true")]
[InlineData(new string[] { "--include-source" }, "-property:IncludeSource=true")]
[InlineData(new string[] { "-c", "<config>" }, "-property:Configuration=<config>")]
[InlineData(new string[] { "--configuration", "<config>" }, "-property:Configuration=<config>")]
[InlineData(new string[] { "--version-suffix", "<versionsuffix>" }, "-property:VersionSuffix=<versionsuffix>")]
[InlineData(new string[] { "-s" }, "-property:Serviceable=true")]
[InlineData(new string[] { "--serviceable" }, "-property:Serviceable=true")]
[InlineData(new string[] { "-v", "diag" }, "-verbosity:diag")]
[InlineData(new string[] { "--verbosity", "diag" }, "-verbosity:diag")]
[InlineData(new string[] { "<project>" }, "<project>")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
{

View file

@ -20,20 +20,20 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
this.output = output;
}
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m";
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m";
[Theory]
[InlineData(new string[] { }, "")]
[InlineData(new string[] { "-r", "<rid>" }, "/p:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, "/p:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "-o", "<publishdir>" }, "/p:PublishDir=<publishdir>")]
[InlineData(new string[] { "--output", "<publishdir>" }, "/p:PublishDir=<publishdir>")]
[InlineData(new string[] { "-c", "<config>" }, "/p:Configuration=<config>")]
[InlineData(new string[] { "--configuration", "<config>" }, "/p:Configuration=<config>")]
[InlineData(new string[] { "--version-suffix", "<versionsuffix>" }, "/p:VersionSuffix=<versionsuffix>")]
[InlineData(new string[] { "--manifest", "<manifestfiles>" }, "/p:TargetManifestFiles=<manifestfiles>")]
[InlineData(new string[] { "-v", "minimal" }, "/verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, "/verbosity:minimal")]
[InlineData(new string[] { "-r", "<rid>" }, "-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, "-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "-o", "<publishdir>" }, "-property:PublishDir=<publishdir>")]
[InlineData(new string[] { "--output", "<publishdir>" }, "-property:PublishDir=<publishdir>")]
[InlineData(new string[] { "-c", "<config>" }, "-property:Configuration=<config>")]
[InlineData(new string[] { "--configuration", "<config>" }, "-property:Configuration=<config>")]
[InlineData(new string[] { "--version-suffix", "<versionsuffix>" }, "-property:VersionSuffix=<versionsuffix>")]
[InlineData(new string[] { "--manifest", "<manifestfiles>" }, "-property:TargetManifestFiles=<manifestfiles>")]
[InlineData(new string[] { "-v", "minimal" }, "-verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, "-verbosity:minimal")]
[InlineData(new string[] { "<project>" }, "<project>")]
[InlineData(new string[] { "<project>", "<extra-args>" }, "<project> <extra-args>")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
@ -49,12 +49,12 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
command.GetProcessStartInfo()
.Arguments.Should()
.Be($"{ExpectedPrefix} /restore /t:Publish{expectedAdditionalArgs}");
.Be($"{ExpectedPrefix} -restore -target:Publish{expectedAdditionalArgs}");
}
[Theory]
[InlineData(new string[] { "-f", "<tfm>" }, "/p:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, "/p:TargetFramework=<tfm>")]
[InlineData(new string[] { "-f", "<tfm>" }, "-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, "-property:TargetFramework=<tfm>")]
public void MsbuildInvocationIsCorrectForSeparateRestore(string[] args, string expectedAdditionalArgs)
{
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");
@ -65,27 +65,45 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
command.SeparateRestoreCommand
.GetProcessStartInfo()
.Arguments.Should()
.Be($"{ExpectedPrefix} /t:Restore");
.Be($"{ExpectedPrefix} -target:Restore");
command.GetProcessStartInfo()
.Arguments.Should()
.Be($"{ExpectedPrefix} /nologo /t:Publish{expectedAdditionalArgs}");
.Be($"{ExpectedPrefix} -nologo -target:Publish{expectedAdditionalArgs}");
}
[Fact]
public void MsbuildInvocationIsCorrectForNoBuild()
{
var msbuildPath = "<msbuildpath>";
var command = PublishCommand.FromArgs(new[] { "--no-build" }, msbuildPath);
command.SeparateRestoreCommand
.Should()
.BeNull();
// NOTE --no-build implies no-restore hence no -restore argument to msbuild below.
command.GetProcessStartInfo()
.Arguments
.Should()
.Be($"{ExpectedPrefix} -target:Publish -property:NoBuild=true");
}
[Theory]
[InlineData(new string[] { }, "")]
[InlineData(new string[] { "-f", "<tfm>" }, "/p:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, "/p:TargetFramework=<tfm>")]
[InlineData(new string[] { "-r", "<rid>" }, "/p:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, "/p:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "-o", "<publishdir>" }, "/p:PublishDir=<publishdir>")]
[InlineData(new string[] { "--output", "<publishdir>" }, "/p:PublishDir=<publishdir>")]
[InlineData(new string[] { "-c", "<config>" }, "/p:Configuration=<config>")]
[InlineData(new string[] { "--configuration", "<config>" }, "/p:Configuration=<config>")]
[InlineData(new string[] { "--version-suffix", "<versionsuffix>" }, "/p:VersionSuffix=<versionsuffix>")]
[InlineData(new string[] { "--manifest", "<manifestfiles>" }, "/p:TargetManifestFiles=<manifestfiles>")]
[InlineData(new string[] { "-v", "minimal" }, "/verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, "/verbosity:minimal")]
[InlineData(new string[] { "-f", "<tfm>" }, "-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, "-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "-r", "<rid>" }, "-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, "-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "-o", "<publishdir>" }, "-property:PublishDir=<publishdir>")]
[InlineData(new string[] { "--output", "<publishdir>" }, "-property:PublishDir=<publishdir>")]
[InlineData(new string[] { "-c", "<config>" }, "-property:Configuration=<config>")]
[InlineData(new string[] { "--configuration", "<config>" }, "-property:Configuration=<config>")]
[InlineData(new string[] { "--version-suffix", "<versionsuffix>" }, "-property:VersionSuffix=<versionsuffix>")]
[InlineData(new string[] { "--manifest", "<manifestfiles>" }, "-property:TargetManifestFiles=<manifestfiles>")]
[InlineData(new string[] { "-v", "minimal" }, "-verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, "-verbosity:minimal")]
[InlineData(new string[] { "--no-build" }, "-property:NoBuild=true")]
public void OptionForwardingIsCorrect(string[] args, string expectedAdditionalArgs)
{
var expectedArgs = expectedAdditionalArgs.Split(' ', StringSplitOptions.RemoveEmptyEntries);
@ -100,4 +118,4 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
.BeEquivalentTo(expectedArgs);
}
}
}
}

View file

@ -11,24 +11,24 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
public class GivenDotnetRestoreInvocation
{
private const string ExpectedPrefix =
"exec <msbuildpath> /m /v:m /nologo /t:Restore";
"exec <msbuildpath> -maxcpucount -verbosity:m -nologo -target:Restore";
[Theory]
[InlineData(new string[] { }, "")]
[InlineData(new string[] { "-s", "<source>" }, "/p:RestoreSources=<source>")]
[InlineData(new string[] { "--source", "<source>" }, "/p:RestoreSources=<source>")]
[InlineData(new string[] { "-s", "<source0>", "-s", "<source1>" }, "/p:RestoreSources=<source0>%3B<source1>")]
[InlineData(new string[] { "-r", "<runtime>" }, "/p:RuntimeIdentifiers=<runtime>")]
[InlineData(new string[] { "--runtime", "<runtime>" }, "/p:RuntimeIdentifiers=<runtime>")]
[InlineData(new string[] { "-r", "<runtime0>", "-r", "<runtime1>" }, "/p:RuntimeIdentifiers=<runtime0>%3B<runtime1>")]
[InlineData(new string[] { "--packages", "<packages>" }, "/p:RestorePackagesPath=<packages>")]
[InlineData(new string[] { "--disable-parallel" }, "/p:RestoreDisableParallel=true")]
[InlineData(new string[] { "--configfile", "<config>" }, "/p:RestoreConfigFile=<config>")]
[InlineData(new string[] { "--no-cache" }, "/p:RestoreNoCache=true")]
[InlineData(new string[] { "--ignore-failed-sources" }, "/p:RestoreIgnoreFailedSources=true")]
[InlineData(new string[] { "--no-dependencies" }, "/p:RestoreRecursive=false")]
[InlineData(new string[] { "-v", "minimal" }, @"/verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, @"/verbosity:minimal")]
[InlineData(new string[] { "-s", "<source>" }, "-property:RestoreSources=<source>")]
[InlineData(new string[] { "--source", "<source>" }, "-property:RestoreSources=<source>")]
[InlineData(new string[] { "-s", "<source0>", "-s", "<source1>" }, "-property:RestoreSources=<source0>%3B<source1>")]
[InlineData(new string[] { "-r", "<runtime>" }, "-property:RuntimeIdentifiers=<runtime>")]
[InlineData(new string[] { "--runtime", "<runtime>" }, "-property:RuntimeIdentifiers=<runtime>")]
[InlineData(new string[] { "-r", "<runtime0>", "-r", "<runtime1>" }, "-property:RuntimeIdentifiers=<runtime0>%3B<runtime1>")]
[InlineData(new string[] { "--packages", "<packages>" }, "-property:RestorePackagesPath=<packages>")]
[InlineData(new string[] { "--disable-parallel" }, "-property:RestoreDisableParallel=true")]
[InlineData(new string[] { "--configfile", "<config>" }, "-property:RestoreConfigFile=<config>")]
[InlineData(new string[] { "--no-cache" }, "-property:RestoreNoCache=true")]
[InlineData(new string[] { "--ignore-failed-sources" }, "-property:RestoreIgnoreFailedSources=true")]
[InlineData(new string[] { "--no-dependencies" }, "-property:RestoreRecursive=false")]
[InlineData(new string[] { "-v", "minimal" }, @"-verbosity:minimal")]
[InlineData(new string[] { "--verbosity", "minimal" }, @"-verbosity:minimal")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
{
expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}");

View file

@ -11,8 +11,8 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
public class GivenDotnetStoreInvocation
{
const string ExpectedPrefix = "exec <msbuildpath> /m /v:m /t:ComposeStore <project>";
static readonly string[] ArgsPrefix = { "-m", "<project>" };
const string ExpectedPrefix = "exec <msbuildpath> -maxcpucount -verbosity:m -target:ComposeStore <project>";
static readonly string[] ArgsPrefix = { "--manifest", "<project>" };
[Theory]
[InlineData("-m")]
@ -26,11 +26,11 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
}
[Theory]
[InlineData(new string[] { "-f", "<tfm>" }, @"/p:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, @"/p:TargetFramework=<tfm>")]
[InlineData(new string[] { "-r", "<rid>" }, @"/p:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, @"/p:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--manifest", "one.xml", "--manifest", "two.xml", "--manifest", "three.xml" }, @"/p:AdditionalProjects=one.xml%3Btwo.xml%3Bthree.xml")]
[InlineData(new string[] { "-f", "<tfm>" }, @"-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "--framework", "<tfm>" }, @"-property:TargetFramework=<tfm>")]
[InlineData(new string[] { "-r", "<rid>" }, @"-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--runtime", "<rid>" }, @"-property:RuntimeIdentifier=<rid>")]
[InlineData(new string[] { "--manifest", "one.xml", "--manifest", "two.xml", "--manifest", "three.xml" }, @"-property:AdditionalProjects=one.xml%3Btwo.xml%3Bthree.xml")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
{
args = ArgsPrefix.Concat(args).ToArray();
@ -51,7 +51,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
var msbuildPath = "<msbuildpath>";
StoreCommand.FromArgs(args, msbuildPath)
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix} /p:ComposeDir={Path.GetFullPath(path)}");
.GetProcessStartInfo().Arguments.Should().Be($"{ExpectedPrefix} -property:ComposeDir={Path.GetFullPath(path)}");
}
}
}

View file

@ -235,5 +235,94 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
.Should().Pass()
.And.HaveStdOutContaining("Hello World");
}
[Fact]
public void ItFailsToPublishWithNoBuildIfNotPreviouslyBuilt()
{
var rootPath = TestAssets.CreateTestDirectory().FullName;
string newArgs = $"console -o \"{rootPath}\"";
new NewCommandShim() // note implicit restore here
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
new PublishCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput("--no-build")
.Should()
.Fail()
.And.HaveStdOutContaining("MSB3030"); // "Could not copy ___ because it was not found."
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void ItPublishesSuccessfullyWithNoBuildIfPreviouslyBuilt(bool selfContained)
{
var rootPath = TestAssets.CreateTestDirectory(identifier: selfContained ? "_sc" : "").FullName;
var rootDir = new DirectoryInfo(rootPath);
string newArgs = $"console -o \"{rootPath}\" --no-restore";
new NewCommandShim()
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
var rid = selfContained ? DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier() : "";
var ridArg = selfContained ? $"-r {rid}" : "";
new BuildCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput(ridArg)
.Should()
.Pass();
new PublishCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput($"{ridArg} --no-build")
.Should()
.Pass();
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
var outputProgram = rootDir
.GetDirectory("bin", configuration, "netcoreapp2.1", rid, "publish", $"{rootDir.Name}.dll")
.FullName;
new TestCommand(outputProgram)
.ExecuteWithCapturedOutput()
.Should()
.Pass()
.And.HaveStdOutContaining("Hello World");
}
[Fact]
public void ItFailsToPublishWithNoBuildIfPreviouslyBuiltWithoutRid()
{
var rootPath = TestAssets.CreateTestDirectory().FullName;
var rootDir = new DirectoryInfo(rootPath);
string newArgs = $"console -o \"{rootPath}\" --no-restore";
new NewCommandShim()
.WithWorkingDirectory(rootPath)
.Execute(newArgs)
.Should()
.Pass();
new BuildCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput()
.Should()
.Pass();
new PublishCommand()
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput("-r win-x64 --no-build")
.Should()
.Fail();
}
}
}

View file

@ -55,7 +55,8 @@ namespace Microsoft.DotNet.Tests.Commands
{
var store = new Mock<IToolPackageStore>(MockBehavior.Strict);
var command = CreateCommand(store.Object, "-g --tool-path /tools", "/tools");
var toolPath = Path.GetTempPath();
var command = CreateCommand(store.Object, $"-g --tool-path {toolPath}", toolPath);
Action a = () => {
command.Execute();
@ -83,6 +84,26 @@ namespace Microsoft.DotNet.Tests.Commands
_reporter.Lines.Should().Equal(EnumerateExpectedTableLines(store.Object));
}
[Fact]
public void GivenAnInvalidToolPathItThrowsException()
{
var store = new Mock<IToolPackageStore>(MockBehavior.Strict);
store
.Setup(s => s.EnumeratePackages())
.Returns(new IToolPackage[0]);
var toolPath = "tool-path-does-not-exist";
var command = CreateCommand(store.Object, $"--tool-path {toolPath}", toolPath);
Action a = () => command.Execute();
a.ShouldThrow<GracefulException>()
.And
.Message
.Should()
.Be(string.Format(LocalizableStrings.InvalidToolPathOption, toolPath));
}
[Fact]
public void GivenAToolPathItPassesToolPathToStoreFactory()
{
@ -91,7 +112,8 @@ namespace Microsoft.DotNet.Tests.Commands
.Setup(s => s.EnumeratePackages())
.Returns(new IToolPackage[0]);
var command = CreateCommand(store.Object, "--tool-path /tools", "/tools");
var toolPath = Path.GetTempPath();
var command = CreateCommand(store.Object, $"--tool-path {toolPath}", toolPath);
command.Execute().Should().Be(0);

View file

@ -51,11 +51,11 @@ namespace Microsoft.DotNet.Tests.Commands
Action a = () => command.Execute();
a.ShouldThrow<GracefulException>().And.Message
.Should().Contain(
string.Format(
LocalizableStrings.ToolNotInstalled,
packageId));
a.ShouldThrow<GracefulException>()
.And
.Message
.Should()
.Be(string.Format(LocalizableStrings.ToolNotInstalled, packageId));
}
[Fact]
@ -131,9 +131,10 @@ namespace Microsoft.DotNet.Tests.Commands
.Execute();
a.ShouldThrow<GracefulException>()
.And.Message
.Should().Contain(
string.Format(
.And
.Message
.Should()
.Be(string.Format(
CommonLocalizableStrings.FailedToUninstallToolPackage,
PackageId,
"simulated error"));
@ -145,12 +146,31 @@ namespace Microsoft.DotNet.Tests.Commands
[Fact]
public void WhenRunWithBothGlobalAndToolPathShowErrorMessage()
{
var uninstallCommand = CreateUninstallCommand($"-g --tool-path /tmp/folder {PackageId}");
var uninstallCommand = CreateUninstallCommand($"-g --tool-path {Path.GetTempPath()} {PackageId}");
Action a = () => uninstallCommand.Execute();
a.ShouldThrow<GracefulException>().And.Message
.Should().Contain(LocalizableStrings.UninstallToolCommandInvalidGlobalAndToolPath);
a.ShouldThrow<GracefulException>()
.And
.Message
.Should()
.Be(LocalizableStrings.UninstallToolCommandInvalidGlobalAndToolPath);
}
[Fact]
public void GivenAnInvalidToolPathItThrowsException()
{
var toolPath = "tool-path-does-not-exist";
var uninstallCommand = CreateUninstallCommand($"--tool-path {toolPath} {PackageId}");
Action a = () => uninstallCommand.Execute();
a.ShouldThrow<GracefulException>()
.And
.Message
.Should()
.Be(string.Format(LocalizableStrings.InvalidToolPathOption, toolPath));
}
[Fact]
@ -160,8 +180,11 @@ namespace Microsoft.DotNet.Tests.Commands
Action a = () => uninstallCommand.Execute();
a.ShouldThrow<GracefulException>().And.Message
.Should().Contain(LocalizableStrings.UninstallToolCommandNeedGlobalOrToolPath);
a.ShouldThrow<GracefulException>()
.And
.Message
.Should()
.Be(LocalizableStrings.UninstallToolCommandNeedGlobalOrToolPath);
}
private ToolInstallCommand CreateInstallCommand(string options)