Revert implementation of the --mode option for the publish command.

This commit reverts the implementation of the `--mode` option for the `dotnet
publish` command.  A bug in the apphost prevents this feature from working
properly in some cases and there currently is not a mechanism to service it
with this feature.

The team has decided to move this feature to 2.2.1xx for the .NET Core SDK.

Fixes dotnet/sdk#2380.
This commit is contained in:
Peter Huene 2018-07-09 11:47:59 -07:00
parent 5aa6fe1ca7
commit d9e8947ff4
No known key found for this signature in database
GPG key ID: E1D265D820213D6A
19 changed files with 156 additions and 574 deletions

View file

@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string _output;
private string _runtime;
private List<string> _targetManifests = new List<string>();
private string _mode;
private bool? _selfContained;
public PublishCommand WithFramework(string framework)
{
@ -44,9 +44,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return this;
}
public PublishCommand WithMode(string value)
public PublishCommand WithSelfContained(bool value)
{
_mode = value;
_selfContained = value;
return this;
}
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
OutputOption,
TargetOption,
RuntimeOption,
ModeOption);
SelfContainedOption);
}
private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}";
@ -80,6 +80,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string TargetOption => string.Join(" ", _targetManifests);
private string ModeOption => string.IsNullOrEmpty(_mode) ? "" : $"--mode {_mode}";
private string SelfContainedOption => _selfContained.HasValue ? $"--self-contained:{_selfContained.Value}" : "";
}
}

View file

@ -97,15 +97,14 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
}
[Theory]
[InlineData("self-contained", null)]
[InlineData(null, null)]
[InlineData(null, "--self-contained")]
[InlineData(null, "--self-contained=true")]
public void ItPublishesSelfContainedWithRid(string mode, string args)
[InlineData(null)]
[InlineData("--self-contained")]
[InlineData("--self-contained=true")]
public void ItPublishesSelfContainedWithRid(string args)
{
var testAppName = "MSBuildTestApp";
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var outputDirectory = PublishApp(testAppName, rid, mode, args);
var outputDirectory = PublishApp(testAppName, rid, args);
var outputProgram = Path.Combine(outputDirectory.FullName, $"{testAppName}{Constants.ExeSuffix}");
@ -116,16 +115,14 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
}
[Theory]
[InlineData("fx-dependent", null)]
[InlineData(null, "--self-contained=false")]
public void ItPublishesFrameworkDependentWithRid(string mode, string args)
[InlineData("--self-contained=false")]
public void ItPublishesFrameworkDependentWithRid(string args)
{
var testAppName = "MSBuildTestApp";
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var outputDirectory = PublishApp(testAppName, rid, mode, args);
var outputDirectory = PublishApp(testAppName, rid, args);
outputDirectory.Should().OnlyHaveFiles(new[] {
$"{testAppName}{Constants.ExeSuffix}",
$"{testAppName}.dll",
$"{testAppName}.pdb",
$"{testAppName}.deps.json",
@ -134,31 +131,6 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
var outputProgram = Path.Combine(outputDirectory.FullName, $"{testAppName}{Constants.ExeSuffix}");
var command = new TestCommand(outputProgram);
command.Environment[Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)"] =
new RepoDirectoriesProvider().DotnetRoot;
command.ExecuteWithCapturedOutput()
.Should()
.Pass()
.And
.HaveStdOutContaining("Hello World");
}
[Fact]
public void ItPublishesFrameworkDependentNoExeWithRid()
{
var testAppName = "MSBuildTestApp";
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var outputDirectory = PublishApp(testAppName, rid, mode: "fx-dependent-no-exe");
outputDirectory.Should().OnlyHaveFiles(new[] {
$"{testAppName}.dll",
$"{testAppName}.pdb",
$"{testAppName}.deps.json",
$"{testAppName}.runtimeconfig.json",
});
new DotnetCommand()
.ExecuteWithCapturedOutput(Path.Combine(outputDirectory.FullName, $"{testAppName}.dll"))
.Should().Pass()
@ -166,14 +138,12 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
}
[Theory]
[InlineData("fx-dependent-no-exe", null)]
[InlineData("fx-dependent", null)]
[InlineData(null, "--self-contained=false")]
[InlineData(null, null)]
public void ItPublishesFrameworkDependentWithoutRid(string mode, string args)
[InlineData("--self-contained=false")]
[InlineData(null)]
public void ItPublishesFrameworkDependentWithoutRid(string args)
{
var testAppName = "MSBuildTestApp";
var outputDirectory = PublishApp(testAppName, rid: null, mode: mode, args: args);
var outputDirectory = PublishApp(testAppName, rid: null, args: args);
outputDirectory.Should().OnlyHaveFiles(new[] {
$"{testAppName}.dll",
@ -188,10 +158,10 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
.And.HaveStdOutContaining("Hello World");
}
private DirectoryInfo PublishApp(string testAppName, string rid, string mode, string args = null)
private DirectoryInfo PublishApp(string testAppName, string rid, string args = null)
{
var testInstance = TestAssets.Get(testAppName)
.CreateInstance($"PublishApp_{rid ?? "none"}_{mode ?? "none"}_{args ?? "none"}")
.CreateInstance($"PublishApp_{rid ?? "none"}_{args ?? "none"}")
.WithSourceFiles()
.WithRestoreFiles();
@ -199,7 +169,6 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
new PublishCommand()
.WithRuntime(rid)
.WithMode(mode)
.WithWorkingDirectory(testProjectDirectory)
.Execute(args ?? "")
.Should().Pass();
@ -336,24 +305,5 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
.Should()
.Fail();
}
[Fact]
public void ItFailsToPublishIfBothModeAndSelfContainedAreSpecified()
{
var testInstance = TestAssets.Get("MSBuildTestApp")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
var testProjectDirectory = testInstance.Root;
new PublishCommand()
.WithWorkingDirectory(testProjectDirectory)
.Execute("--self-contained --mode fx-dependent")
.Should()
.Fail()
.And
.HaveStdErrContaining(LocalizableStrings.PublishModeAndSelfContainedOptionsConflict);
}
}
}