public void Muxer_ListRuntimes() { DotNet.Exec("--list-runtimes") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0"); }
public void EnvironmentVariable_DotNetInfo_ListEnvironment() { var dotnet = new DotNetCli(sharedTestState.RepoDirectories.BuiltDotnet); var command = dotnet.Exec("--info") .CaptureStdOut(); var envVars = new (string Architecture, string Path)[] {
protected CommandResult RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, Action<CommandResult> resultAction = null, bool? multiLevelLookup = false) { using (DotNetCliExtensions.DotNetCliCustomizer dotnetCustomizer = settings.DotnetCustomizer == null ? null : dotnet.Customize()) { settings.DotnetCustomizer?.Invoke(dotnetCustomizer); if (app is not null) { if (settings.RuntimeConfigCustomizer != null) { settings.RuntimeConfigCustomizer(RuntimeConfig.Path(app.RuntimeConfigJson)).Save(); } settings.WithCommandLine(app.AppDll); } Command command = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()); if (settings.WorkingDirectory != null) { command = command.WorkingDirectory(settings.WorkingDirectory); } CommandResult result = command .EnableTracingAndCaptureOutputs() .MultilevelLookup(multiLevelLookup) .Environment(settings.Environment) .Execute(); resultAction?.Invoke(result); return result; } }
protected CommandResult RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, Action <CommandResult> resultAction = null, bool multiLevelLookup = false) { using (DotNetCliExtensions.DotNetCliCustomizer dotnetCustomizer = settings.DotnetCustomizer == null ? null : dotnet.Customize()) { settings.DotnetCustomizer?.Invoke(dotnetCustomizer); if (settings.RuntimeConfigCustomizer != null) { settings.RuntimeConfigCustomizer(RuntimeConfig.Path(app.RuntimeConfigJson)).Save(); } settings.WithCommandLine(app.AppDll); Command command = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()); if (settings.WorkingDirectory != null) { command = command.WorkingDirectory(settings.WorkingDirectory); } CommandResult result = command .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", multiLevelLookup ? "1" : "0") .Environment(settings.Environment) .CaptureStdOut() .CaptureStdErr() .Execute(); resultAction?.Invoke(result); return(result); } }
protected void RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, Action <CommandResult> resultAction, bool multiLevelLookup = false) { if (settings.RuntimeConfigCustomizer != null) { settings.RuntimeConfigCustomizer(RuntimeConfig.Path(app.RuntimeConfigJson)).Save(); } settings.WithCommandLine(app.AppDll); CommandResult result = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", multiLevelLookup ? "1" : "0") .Environment(settings.Environment) .CaptureStdOut() .CaptureStdErr() .Execute(); resultAction(result); }
[PlatformSpecific(TestPlatforms.Windows)] // Multi-level lookup is only supported on Windows. public void SdkMultilevelLookup_Global_Json_Single_Digit_Patch_Rollup() { // Set specified SDK version = 9999.3.4-global-dummy SetGlobalJsonVersion("SingleDigit-global.json"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: empty // Reg: empty // Expected: no compatible version and a specific error messages DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should().Fail() .And.HaveStdErrContaining("A compatible installed .NET SDK for global.json version"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.4.1", "9999.3.4-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: 9999.4.1, 9999.3.4-dummy // Reg: empty // Expected: no compatible version and a specific error message DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should().Fail() .And.HaveStdErrContaining("A compatible installed .NET SDK for global.json version"); // Add SDK versions AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.3"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: 9999.4.1, 9999.3.4-dummy // Reg: 9999.3.3 // Expected: no compatible version and a specific error message DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should().Fail() .And.HaveStdErrContaining("A compatible installed .NET SDK for global.json version"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4 // Reg: 9999.3.3 // Expected: 9999.3.4 from exe dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_regSdkBaseDir, "9999.3.5-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4 // Reg: 9999.3.3, 9999.3.5-dummy // Expected: 9999.3.5-dummy from reg dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.600"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4, 9999.3.600 // Reg: 9999.3.3, 9999.3.5-dummy // Expected: 9999.3.5-dummy from reg dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_regSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4-global-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Cwd: empty // User: empty // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.4, 9999.3.600, 9999.3.4-global-dummy // Reg: 9999.3.3, 9999.3.5-dummy // Expected: 9999.3.4-global-dummy from exe dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4-global-dummy", _dotnetSdkDllMessageTerminator)); // Verify we have the expected SDK versions DotNet.Exec("--list-sdks") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1") .EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir) .CaptureStdOut() .Execute() .Should().Pass() .And.HaveStdOutContaining("9999.3.4-dummy") .And.HaveStdOutContaining("9999.3.4-global-dummy") .And.HaveStdOutContaining("9999.4.1") .And.HaveStdOutContaining("9999.3.3") .And.HaveStdOutContaining("9999.3.4") .And.HaveStdOutContaining("9999.3.600") .And.HaveStdOutContaining("9999.3.5-dummy"); }
public void SdkLookup_Global_Json_Single_Digit_Patch_Rollup() { // Set specified SDK version = 9999.3.4-global-dummy SetGlobalJsonVersion("SingleDigit-global.json"); // Specified SDK version: 9999.3.4-global-dummy // Exe: empty // Expected: no compatible version and a specific error messages DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should().Fail() .And.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version") .And.HaveStdErrContaining("It was not possible to find any installed dotnet SDKs") .And.HaveStdErrContaining("aka.ms/dotnet-download") .And.NotHaveStdErrContaining("Checking if resolved SDK dir"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.4.1", "9999.3.4-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Exe: 9999.4.1, 9999.3.4-dummy // Expected: no compatible version and a specific error message DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should().Fail() .And.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version") .And.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.3"); // Specified SDK version: 9999.3.4-global-dummy // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3 // Expected: no compatible version and a specific error message DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute(fExpectedToFail: true) .Should().Fail() .And.HaveStdErrContaining("A compatible installed dotnet SDK for global.json version") .And.NotHaveStdErrContaining("It was not possible to find any installed dotnet SDKs"); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4"); // Specified SDK version: 9999.3.4-global-dummy // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4 // Expected: 9999.3.4 from exe dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.5-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy // Expected: 9999.3.5-dummy from exe dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.600"); // Specified SDK version: 9999.3.4-global-dummy // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy, 9999.3.600 // Expected: 9999.3.5-dummy from exe dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.5-dummy", _dotnetSdkDllMessageTerminator)); // Add SDK versions AddAvailableSdkVersions(_exeSdkBaseDir, "9999.3.4-global-dummy"); // Specified SDK version: 9999.3.4-global-dummy // Exe: 9999.4.1, 9999.3.4-dummy, 9999.3.3, 9999.3.4, 9999.3.5-dummy, 9999.3.600, 9999.3.4-global-dummy // Expected: 9999.3.4-global-dummy from exe dir DotNet.Exec("help") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .CaptureStdErr() .Execute() .Should().Pass() .And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.3.4-global-dummy", _dotnetSdkDllMessageTerminator)); // Verify we have the expected SDK versions DotNet.Exec("--list-sdks") .WorkingDirectory(_currentWorkingDir) .WithUserProfile(_userDir) .Environment(s_DefaultEnvironment) .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .CaptureStdOut() .Execute() .Should().Pass() .And.HaveStdOutContaining("9999.3.4-dummy") .And.HaveStdOutContaining("9999.3.4-global-dummy") .And.HaveStdOutContaining("9999.4.1") .And.HaveStdOutContaining("9999.3.3") .And.HaveStdOutContaining("9999.3.4") .And.HaveStdOutContaining("9999.3.600") .And.HaveStdOutContaining("9999.3.5-dummy"); }