Fix adding tools directory to PATH for native installers.
This commit fixes adding the tools directory to the user's PATH for the native installers. The issue was a regression caused by #8886. The change used a "no-op" sentinel file that reported it existed. This "no-op" sentinel was used for the native installers. Unlike the other "no-op" sentinels used by the native installer, we do want PATH to be modified by the native installer. The fix is to change the "no-op" sentinel to report the file doesn't exist, but also to not to attempt to create the file. This fixes #9208.
This commit is contained in:
parent
e7ebf48578
commit
0f0f70ce48
3 changed files with 53 additions and 2 deletions
|
@ -7,9 +7,16 @@ namespace Microsoft.DotNet.Configurer
|
||||||
{
|
{
|
||||||
public class NoOpFileSentinel : IFileSentinel
|
public class NoOpFileSentinel : IFileSentinel
|
||||||
{
|
{
|
||||||
|
private bool _exists;
|
||||||
|
|
||||||
|
public NoOpFileSentinel(bool exists)
|
||||||
|
{
|
||||||
|
_exists = exists;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Exists()
|
public bool Exists()
|
||||||
{
|
{
|
||||||
return true;
|
return _exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create()
|
public void Create()
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
aspNetCertificateSentinel = new NoOpAspNetCertificateSentinel();
|
aspNetCertificateSentinel = new NoOpAspNetCertificateSentinel();
|
||||||
firstTimeUseNoticeSentinel = new NoOpFirstTimeUseNoticeSentinel();
|
firstTimeUseNoticeSentinel = new NoOpFirstTimeUseNoticeSentinel();
|
||||||
toolPathSentinel = new NoOpFileSentinel();
|
toolPathSentinel = new NoOpFileSentinel(exists: false);
|
||||||
hasSuperUserAccess = true;
|
hasSuperUserAccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.Cli;
|
using Microsoft.DotNet.Cli;
|
||||||
|
using Microsoft.DotNet.Configurer;
|
||||||
using Microsoft.DotNet.TestFramework;
|
using Microsoft.DotNet.TestFramework;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -193,6 +194,49 @@ namespace Microsoft.DotNet.Tests
|
||||||
.ContainVisuallySameFragment(Configurer.LocalizableStrings.AspNetCertificateInstalled);
|
.ContainVisuallySameFragment(Configurer.LocalizableStrings.AspNetCertificateInstalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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(
|
||||||
|
$"export PATH=\"$PATH:{new CliFolderPathCalculator().ToolsShimPathInUnix.PathWithDollar}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
[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();
|
||||||
|
File.ReadAllText(pathsd).Should().Be(new CliFolderPathCalculator().ToolsShimPathInUnix.PathWithTilde);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ItRestoresTheNuGetPackagesToTheNuGetCacheFolder()
|
public void ItRestoresTheNuGetPackagesToTheNuGetCacheFolder()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue