Merge branch 'release/2.1.4xx' into release/2.1.401
* release/2.1.4xx: Add XSLT Transform for apphost (#9609) Update date test according to MicrosoftNETSdkPackageVersion update Update MicrosoftNETCoreAppPackageVersion Update SDK to 2.1.400-preview-63110-09 Revert implementation of the --mode option for the publish command. Updating the WebSdk from aspnet/websdk/2.1.4xx Removing 'Locked-file' test; CLI:release/2.1.3xx (#9604) Log a verbose message when DOTNET_CLI_HOME is being used.
This commit is contained in:
commit
789423b469
40 changed files with 308 additions and 628 deletions
|
@ -1,49 +0,0 @@
|
|||
// 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.Diagnostics;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Cli;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using NuGet.Frameworks;
|
||||
using NuGet.ProjectModel;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||
{
|
||||
public class GivenThatWeWantToReadLockFilesQuickly : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ItFailsInLessThanOneSecondWhenTheProjectAssetsJsonDoesNotExist()
|
||||
{
|
||||
var testInstance = TestAssets.Get("TestAppWithProjDepTool")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
var assetsFile = testInstance.Root.GetDirectory("obj").GetFile("project.assets.json").FullName;
|
||||
var expectedMessage = string.Join(
|
||||
Environment.NewLine,
|
||||
string.Format(LocalizableStrings.FileNotFound, assetsFile),
|
||||
LocalizableStrings.ProjectNotRestoredOrRestoreFailed);
|
||||
|
||||
Action action = () =>
|
||||
{
|
||||
var lockFile = new LockFileFormat()
|
||||
.ReadWithLock(assetsFile)
|
||||
.Result;
|
||||
};
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
|
||||
action.ShouldThrow<GracefulException>().WithMessage(expectedMessage);
|
||||
|
||||
stopWatch.Stop();
|
||||
stopWatch.ElapsedMilliseconds.Should().BeLessThan(1000);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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}" : "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,5 +49,23 @@ namespace Microsoft.DotNet.Tests
|
|||
.And
|
||||
.HaveStdErrContaining(CliFolderPathCalculator.DotnetHomeVariableName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GivenASpecifiedDotnetCliHomeVariableItPrintsUsageMessage()
|
||||
{
|
||||
var home = Path.Combine(TempRoot.Root, Path.GetRandomFileName());
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName, home)
|
||||
.ExecuteWithCapturedOutput("-d help")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
string.Format(
|
||||
LocalizableStrings.DotnetCliHomeUsed,
|
||||
home,
|
||||
CliFolderPathCalculator.DotnetHomeVariableName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue