2017-04-05 20:50:12 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
2016-06-10 03:52:49 +00:00
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
using Microsoft.DotNet.Cli;
|
2018-05-07 23:35:29 +00:00
|
|
|
|
using Microsoft.DotNet.Configurer;
|
2016-06-10 03:52:49 +00:00
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
|
2017-02-01 01:31:37 +00:00
|
|
|
|
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
|
|
|
|
|
2016-06-10 03:52:49 +00:00
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
|
{
|
2017-02-01 01:31:37 +00:00
|
|
|
|
public class GivenThatTheUserIsRunningDotNetForTheFirstTime : TestBase
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2016-06-22 22:17:54 +00:00
|
|
|
|
private static CommandResult _firstDotnetNonVerbUseCommandResult;
|
|
|
|
|
private static CommandResult _firstDotnetVerbUseCommandResult;
|
2017-03-30 18:28:01 +00:00
|
|
|
|
private static DirectoryInfo _nugetFallbackFolder;
|
2017-07-26 05:30:36 +00:00
|
|
|
|
private static DirectoryInfo _dotDotnetFolder;
|
|
|
|
|
private static string _testDirectory;
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
static GivenThatTheUserIsRunningDotNetForTheFirstTime()
|
|
|
|
|
{
|
2017-07-26 05:30:36 +00:00
|
|
|
|
_testDirectory = TestAssets.CreateTestDirectory("Dotnet_first_time_experience_tests").FullName;
|
|
|
|
|
var testNuGetHome = Path.Combine(_testDirectory, "nuget_home");
|
2017-05-31 20:44:03 +00:00
|
|
|
|
var cliTestFallbackFolder = Path.Combine(testNuGetHome, ".dotnet", "NuGetFallbackFolder");
|
2017-11-27 18:45:43 +00:00
|
|
|
|
var profiled = Path.Combine(_testDirectory, "profile.d");
|
|
|
|
|
var pathsd = Path.Combine(_testDirectory, "paths.d");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand()
|
2017-07-26 05:30:36 +00:00
|
|
|
|
.WithWorkingDirectory(_testDirectory);
|
2017-03-30 18:28:01 +00:00
|
|
|
|
command.Environment["HOME"] = testNuGetHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = testNuGetHome;
|
2017-04-03 17:45:35 +00:00
|
|
|
|
command.Environment["APPDATA"] = testNuGetHome;
|
2017-05-31 20:44:03 +00:00
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = cliTestFallbackFolder;
|
2017-11-27 18:45:43 +00:00
|
|
|
|
command.Environment["DOTNET_CLI_TEST_LINUX_PROFILED_PATH"] = profiled;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_OSX_PATHSD_PATH"] = pathsd;
|
2016-06-14 09:41:47 +00:00
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
2016-10-14 07:06:35 +00:00
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
2016-06-22 22:17:54 +00:00
|
|
|
|
_firstDotnetNonVerbUseCommandResult = command.ExecuteWithCapturedOutput("--info");
|
2017-02-01 01:31:37 +00:00
|
|
|
|
_firstDotnetVerbUseCommandResult = command.ExecuteWithCapturedOutput("new --debug:ephemeral-hive");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_nugetFallbackFolder = new DirectoryInfo(cliTestFallbackFolder);
|
2017-07-26 05:30:36 +00:00
|
|
|
|
_dotDotnetFolder = new DirectoryInfo(Path.Combine(testNuGetHome, ".dotnet"));
|
2017-03-03 04:35:20 +00:00
|
|
|
|
}
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-13 22:15:35 +00:00
|
|
|
|
public void UsingDotnetForTheFirstTimeSucceeds()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2016-08-18 22:25:16 +00:00
|
|
|
|
_firstDotnetVerbUseCommandResult
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
2016-06-22 22:17:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-13 22:15:35 +00:00
|
|
|
|
public void UsingDotnetForTheFirstTimeWithNonVerbsDoesNotPrintEula()
|
2016-06-22 22:17:54 +00:00
|
|
|
|
{
|
2018-03-07 20:39:46 +00:00
|
|
|
|
string firstTimeNonVerbUseMessage = Cli.Utils.LocalizableStrings.DotNetSdkInfoLabel;
|
2016-06-22 22:17:54 +00:00
|
|
|
|
|
2016-08-18 22:25:16 +00:00
|
|
|
|
_firstDotnetNonVerbUseCommandResult.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.StartWith(firstTimeNonVerbUseMessage);
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-13 22:15:35 +00:00
|
|
|
|
public void ItShowsTheAppropriateMessageToTheUser()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2017-06-19 18:54:42 +00:00
|
|
|
|
_firstDotnetVerbUseCommandResult.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeWelcomeMessage)
|
|
|
|
|
.And.NotContain("Restore completed in");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-10 07:10:59 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItShowsTheAspNetCertificateGenerationMessageToTheUser()
|
|
|
|
|
{
|
|
|
|
|
_firstDotnetVerbUseCommandResult.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.ContainVisuallySameFragment(Configurer.LocalizableStrings.AspNetCertificateInstalled)
|
|
|
|
|
.And.NotContain("Restore completed in");
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 01:31:37 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItCreatesASentinelFileUnderTheNuGetCacheFolder()
|
|
|
|
|
{
|
2017-03-30 18:28:01 +00:00
|
|
|
|
_nugetFallbackFolder
|
2016-08-18 22:25:16 +00:00
|
|
|
|
.Should()
|
2017-01-24 04:21:58 +00:00
|
|
|
|
.HaveFile($"{GetDotnetVersion()}.dotnetSentinel");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-26 05:30:36 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItCreatesAFirstUseSentinelFileUnderTheDotDotNetFolder()
|
|
|
|
|
{
|
|
|
|
|
_dotDotnetFolder
|
|
|
|
|
.Should()
|
|
|
|
|
.HaveFile($"{GetDotnetVersion()}.dotnetFirstUseSentinel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2018-01-10 07:10:59 +00:00
|
|
|
|
public void ItCreatesAnAspNetCertificateSentinelFileUnderTheDotDotNetFolder()
|
|
|
|
|
{
|
|
|
|
|
_dotDotnetFolder
|
|
|
|
|
.Should()
|
|
|
|
|
.HaveFile($"{GetDotnetVersion()}.aspNetCertificateSentinel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItDoesNotCreateAFirstUseSentinelFileNorAnAspNetCertificateSentinelFileUnderTheDotDotNetFolderWhenInternalReportInstallSuccessIsInvoked()
|
2017-07-26 05:30:36 +00:00
|
|
|
|
{
|
2017-07-26 17:29:10 +00:00
|
|
|
|
var emptyHome = Path.Combine(_testDirectory, "empty_home");
|
2017-11-27 18:45:43 +00:00
|
|
|
|
var profiled = Path.Combine(_testDirectory, "profile.d");
|
|
|
|
|
var pathsd = Path.Combine(_testDirectory, "paths.d");
|
2017-07-26 05:30:36 +00:00
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(_testDirectory);
|
2017-07-26 17:29:10 +00:00
|
|
|
|
command.Environment["HOME"] = emptyHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = emptyHome;
|
|
|
|
|
command.Environment["APPDATA"] = emptyHome;
|
2017-07-26 05:30:36 +00:00
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = _nugetFallbackFolder.FullName;
|
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
2017-11-27 18:45:43 +00:00
|
|
|
|
command.Environment["DOTNET_CLI_TEST_LINUX_PROFILED_PATH"] = profiled;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_OSX_PATHSD_PATH"] = pathsd;
|
2017-07-26 17:29:10 +00:00
|
|
|
|
// Disable to prevent the creation of the .dotnet folder by optimizationdata.
|
|
|
|
|
command.Environment["DOTNET_DISABLE_MULTICOREJIT"] = "true";
|
2017-07-26 05:30:36 +00:00
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
|
|
|
|
|
|
|
|
|
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
|
|
|
|
|
2017-06-06 03:51:58 +00:00
|
|
|
|
var homeFolder = new DirectoryInfo(Path.Combine(emptyHome, ".dotnet"));
|
|
|
|
|
string[] fileEntries = Directory.GetFiles(homeFolder.ToString());
|
|
|
|
|
fileEntries.Should().OnlyContain(x => !x.Contains(".dotnetFirstUseSentinel"));
|
2018-01-10 07:10:59 +00:00
|
|
|
|
fileEntries.Should().OnlyContain(x => !x.Contains(".aspNetCertificateSentinel"));
|
2017-07-26 05:30:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItShowsTheTelemetryNoticeWhenInvokingACommandAfterInternalReportInstallSuccessHasBeenInvoked()
|
|
|
|
|
{
|
|
|
|
|
var newHome = Path.Combine(_testDirectory, "new_home");
|
|
|
|
|
var newHomeFolder = new DirectoryInfo(Path.Combine(newHome, ".dotnet"));
|
2017-11-27 18:45:43 +00:00
|
|
|
|
var profiled = Path.Combine(_testDirectory, "profile.d");
|
|
|
|
|
var pathsd = Path.Combine(_testDirectory, "paths.d");
|
2017-07-26 05:30:36 +00:00
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(_testDirectory);
|
|
|
|
|
command.Environment["HOME"] = newHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = newHome;
|
|
|
|
|
command.Environment["APPDATA"] = newHome;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = _nugetFallbackFolder.FullName;
|
2017-11-27 18:45:43 +00:00
|
|
|
|
command.Environment["DOTNET_CLI_TEST_LINUX_PROFILED_PATH"] = profiled;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_OSX_PATHSD_PATH"] = pathsd;
|
2017-07-26 05:30:36 +00:00
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
|
|
|
|
|
|
|
|
|
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
|
|
|
|
|
|
|
|
|
var result = command.ExecuteWithCapturedOutput("new --debug:ephemeral-hive");
|
|
|
|
|
|
|
|
|
|
result.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeWelcomeMessage);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-10 07:10:59 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItShowsTheAspNetCertificateGenerationMessageWhenInvokingACommandAfterInternalReportInstallSuccessHasBeenInvoked()
|
|
|
|
|
{
|
|
|
|
|
var newHome = Path.Combine(_testDirectory, "aspnet_home");
|
|
|
|
|
var newHomeFolder = new DirectoryInfo(Path.Combine(newHome, ".dotnet"));
|
|
|
|
|
var profiled = Path.Combine(_testDirectory, "profile.d");
|
|
|
|
|
var pathsd = Path.Combine(_testDirectory, "paths.d");
|
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(_testDirectory);
|
|
|
|
|
command.Environment["HOME"] = newHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = newHome;
|
|
|
|
|
command.Environment["APPDATA"] = newHome;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = _nugetFallbackFolder.FullName;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_LINUX_PROFILED_PATH"] = profiled;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_OSX_PATHSD_PATH"] = pathsd;
|
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
|
|
|
|
|
|
|
|
|
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
|
|
|
|
|
|
|
|
|
var result = command.ExecuteWithCapturedOutput("new --debug:ephemeral-hive");
|
|
|
|
|
|
|
|
|
|
result.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.ContainVisuallySameFragment(Configurer.LocalizableStrings.AspNetCertificateInstalled);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-07 23:35:29 +00:00
|
|
|
|
[LinuxOnlyFact]
|
|
|
|
|
public void ItCreatesTheProfileFileOnLinuxWhenInvokedFromNativeInstaller()
|
|
|
|
|
{
|
|
|
|
|
var emptyHome = Path.Combine(_testDirectory, "empty_home");
|
|
|
|
|
var profiled = Path.Combine(_testDirectory, "profile.d");
|
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand().WithWorkingDirectory(_testDirectory);
|
|
|
|
|
command.Environment["HOME"] = emptyHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = emptyHome;
|
|
|
|
|
command.Environment["APPDATA"] = emptyHome;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = _nugetFallbackFolder.FullName;
|
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_LINUX_PROFILED_PATH"] = profiled;
|
|
|
|
|
command.Environment["DOTNET_DISABLE_MULTICOREJIT"] = "true";
|
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
|
|
|
|
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
|
|
|
|
|
|
|
|
|
File.Exists(profiled).Should().BeTrue();
|
|
|
|
|
File.ReadAllText(profiled).Should().Be(
|
2018-05-17 19:52:21 +00:00
|
|
|
|
$"export PATH=\"$PATH:{CliFolderPathCalculator.ToolsShimPathInUnix.PathWithDollar}\"");
|
2018-05-07 23:35:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MacOsOnlyFact]
|
|
|
|
|
public void ItCreatesThePathDFileOnMacOSWhenInvokedFromNativeInstaller()
|
|
|
|
|
{
|
|
|
|
|
var emptyHome = Path.Combine(_testDirectory, "empty_home");
|
|
|
|
|
var pathsd = Path.Combine(_testDirectory, "paths.d");
|
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand().WithWorkingDirectory(_testDirectory);
|
|
|
|
|
command.Environment["HOME"] = emptyHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = emptyHome;
|
|
|
|
|
command.Environment["APPDATA"] = emptyHome;
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = _nugetFallbackFolder.FullName;
|
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
|
|
|
|
command.Environment["DOTNET_CLI_TEST_OSX_PATHSD_PATH"] = pathsd;
|
|
|
|
|
command.Environment["DOTNET_DISABLE_MULTICOREJIT"] = "true";
|
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
|
|
|
|
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
|
|
|
|
|
|
|
|
|
|
File.Exists(pathsd).Should().BeTrue();
|
2018-05-17 19:52:21 +00:00
|
|
|
|
File.ReadAllText(pathsd).Should().Be(CliFolderPathCalculator.ToolsShimPathInUnix.PathWithTilde);
|
2018-05-07 23:35:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-10 03:52:49 +00:00
|
|
|
|
[Fact]
|
2016-12-27 21:28:24 +00:00
|
|
|
|
public void ItRestoresTheNuGetPackagesToTheNuGetCacheFolder()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2016-12-27 21:28:24 +00:00
|
|
|
|
List<string> expectedDirectories = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"microsoft.netcore.app",
|
2017-01-27 23:46:55 +00:00
|
|
|
|
"microsoft.netcore.platforms",
|
|
|
|
|
"netstandard.library",
|
2016-12-27 21:28:24 +00:00
|
|
|
|
"microsoft.aspnetcore.diagnostics",
|
|
|
|
|
"microsoft.aspnetcore.mvc",
|
|
|
|
|
"microsoft.aspnetcore.routing",
|
|
|
|
|
"microsoft.aspnetcore.server.iisintegration",
|
|
|
|
|
"microsoft.aspnetcore.server.kestrel",
|
|
|
|
|
"microsoft.aspnetcore.staticfiles",
|
|
|
|
|
"microsoft.extensions.configuration.environmentvariables",
|
|
|
|
|
"microsoft.extensions.configuration.json",
|
|
|
|
|
"microsoft.extensions.logging",
|
|
|
|
|
"microsoft.extensions.logging.console",
|
|
|
|
|
"microsoft.extensions.logging.debug",
|
|
|
|
|
"microsoft.extensions.options.configurationextensions",
|
2017-04-22 18:52:54 +00:00
|
|
|
|
//BrowserLink has been temporarily disabled until https://github.com/dotnet/templating/issues/644 is resolved
|
|
|
|
|
//"microsoft.visualstudio.web.browserlink",
|
2016-12-27 21:28:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-03-30 18:28:01 +00:00
|
|
|
|
_nugetFallbackFolder
|
2016-08-18 22:25:16 +00:00
|
|
|
|
.Should()
|
2016-12-27 21:28:24 +00:00
|
|
|
|
.HaveDirectories(expectedDirectories);
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-07 14:43:28 +00:00
|
|
|
|
private string GetDotnetVersion()
|
2017-02-01 01:31:37 +00:00
|
|
|
|
{
|
|
|
|
|
return new DotnetCommand().ExecuteWithCapturedOutput("--version").StdOut
|
|
|
|
|
.TrimEnd(Environment.NewLine.ToCharArray());
|
|
|
|
|
}
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
2017-03-03 04:35:20 +00:00
|
|
|
|
}
|