diff --git a/Directory.Packages.props b/Directory.Packages.props index b5d10cac53d6..831213a37869 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -62,6 +62,7 @@ + diff --git a/NuGet.config b/NuGet.config index 09870da28882..9298463ec7d8 100644 --- a/NuGet.config +++ b/NuGet.config @@ -32,6 +32,7 @@ + diff --git a/documentation/general/dotnet-run-file.md b/documentation/general/dotnet-run-file.md index ea907c0aa7cb..7964ee389ee0 100644 --- a/documentation/general/dotnet-run-file.md +++ b/documentation/general/dotnet-run-file.md @@ -190,7 +190,7 @@ have the shared `.cs` files source-included via ` + diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/PathUtility.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/PathUtility.cs index 9527cee0282b..af364e5eb956 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/PathUtility.cs +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/PathUtility.cs @@ -89,6 +89,28 @@ public static void EnsureDirectoryExists(string? directoryPath) } } + public static string GetUserRestrictedTempDirectory() + { + // We want a location where permissions are expected to be restricted to the current user. + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? Path.GetTempPath() + : Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + } + +#if NET + public static void CreateUserRestrictedDirectory(string path) + { + if (OperatingSystem.IsWindows()) + { + Directory.CreateDirectory(path); + } + else + { + Directory.CreateDirectory(path, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); + } + } +#endif + public static bool TryDeleteDirectory(string directoryPath) { try diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/Sha256Hasher.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/Sha256Hasher.cs index 33fe02237329..28415445f031 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/Sha256Hasher.cs +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/Sha256Hasher.cs @@ -3,6 +3,8 @@ #if NET +using System.Diagnostics; +using System.IO.Hashing; using System.Security.Cryptography; namespace Microsoft.DotNet.Cli.Utils; @@ -29,4 +31,17 @@ public static string HashWithNormalizedCasing(string text) } } +public static class XxHash128Hasher +{ + public static string HashWithNormalizedCasing(string text) + { + text = text.ToUpperInvariant(); + var bytes = Encoding.UTF8.GetBytes(text); + Span hash = stackalloc byte[sizeof(ulong) * 2]; + int bytesWritten = XxHash128.Hash(bytes.AsSpan(), hash); + Debug.Assert(bytesWritten == hash.Length); + return Convert.ToHexStringLower(hash); + } +} + #endif diff --git a/src/Cli/dotnet/BuildServer/BuildServerProvider.cs b/src/Cli/dotnet/BuildServer/BuildServerProvider.cs index 3252dcaf0df5..f51afe1939e1 100644 --- a/src/Cli/dotnet/BuildServer/BuildServerProvider.cs +++ b/src/Cli/dotnet/BuildServer/BuildServerProvider.cs @@ -22,6 +22,11 @@ internal class BuildServerProvider( public IEnumerable EnumerateBuildServers(ServerEnumerationFlags flags = ServerEnumerationFlags.All) { + if ((flags & ServerEnumerationFlags.Unified) == ServerEnumerationFlags.Unified) + { + yield return new UnifiedBuildServer(); + } + if ((flags & ServerEnumerationFlags.MSBuild) == ServerEnumerationFlags.MSBuild) { // Yield a single MSBuild server (handles server discovery itself) diff --git a/src/Cli/dotnet/BuildServer/IBuildServer.cs b/src/Cli/dotnet/BuildServer/IBuildServer.cs index a46c2090d8d1..67bddeaf6026 100644 --- a/src/Cli/dotnet/BuildServer/IBuildServer.cs +++ b/src/Cli/dotnet/BuildServer/IBuildServer.cs @@ -11,5 +11,5 @@ internal interface IBuildServer string Name { get; } - void Shutdown(); + Task ShutdownAsync(); } diff --git a/src/Cli/dotnet/BuildServer/IBuildServerProvider.cs b/src/Cli/dotnet/BuildServer/IBuildServerProvider.cs index b6edfef28404..6994b47a805f 100644 --- a/src/Cli/dotnet/BuildServer/IBuildServerProvider.cs +++ b/src/Cli/dotnet/BuildServer/IBuildServerProvider.cs @@ -9,10 +9,11 @@ namespace Microsoft.DotNet.Cli.BuildServer; internal enum ServerEnumerationFlags { None = 0, - MSBuild = 1, - VBCSCompiler = 2, - Razor = 4, - All = MSBuild | VBCSCompiler | Razor + MSBuild = 1 << 0, + VBCSCompiler = 1 << 1, + Razor = 1 << 2, + Unified = 1 << 3, + All = MSBuild | VBCSCompiler | Razor | Unified } internal interface IBuildServerProvider diff --git a/src/Cli/dotnet/BuildServer/MSBuildServer.cs b/src/Cli/dotnet/BuildServer/MSBuildServer.cs index 2a837623b015..eaab4dcbc089 100644 --- a/src/Cli/dotnet/BuildServer/MSBuildServer.cs +++ b/src/Cli/dotnet/BuildServer/MSBuildServer.cs @@ -13,8 +13,9 @@ internal class MSBuildServer : IBuildServer public string Name => CliStrings.MSBuildServer; - public void Shutdown() + public Task ShutdownAsync() { BuildManager.DefaultBuildManager.ShutdownAllNodes(); + return Task.CompletedTask; } } diff --git a/src/Cli/dotnet/BuildServer/RazorServer.cs b/src/Cli/dotnet/BuildServer/RazorServer.cs index 3773d1f1c115..30275f0467df 100644 --- a/src/Cli/dotnet/BuildServer/RazorServer.cs +++ b/src/Cli/dotnet/BuildServer/RazorServer.cs @@ -22,14 +22,15 @@ internal class RazorServer( public RazorPidFile PidFile { get; } = pidFile ?? throw new ArgumentNullException(nameof(pidFile)); - public void Shutdown() + public Task ShutdownAsync() { if (!_fileSystem.File.Exists(PidFile.ServerPath.Value)) { // The razor server path doesn't exist anymore so trying to shut it down would fail // Ensure the pid file is cleaned up so we don't try to shut it down again DeletePidFile(); - return; + + return Task.CompletedTask; } var command = _commandFactory @@ -57,6 +58,8 @@ public void Shutdown() // After a successful shutdown, ensure the pid file is deleted // If the pid file was left behind due to a rude exit, this ensures we don't try to shut it down again DeletePidFile(); + + return Task.CompletedTask; } void DeletePidFile() diff --git a/src/Cli/dotnet/BuildServer/UnifiedBuildServer.cs b/src/Cli/dotnet/BuildServer/UnifiedBuildServer.cs new file mode 100644 index 000000000000..1285e25bcec6 --- /dev/null +++ b/src/Cli/dotnet/BuildServer/UnifiedBuildServer.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using Microsoft.DotNet.Cli.Commands; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.Net.BuildServerUtils; + +namespace Microsoft.DotNet.Cli.BuildServer; + +internal sealed class UnifiedBuildServer : IBuildServer +{ + public int ProcessId => 0; // Not used + + public string Name => CliCommandStrings.UnifiedBuildServer; + + public Task ShutdownAsync() + { + var hostServerPath = MSBuildForwardingAppWithoutLogging.GetHostServerPath(createDirectory: false); + var pipeFolder = BuildServerUtility.GetPipeFolder(hostServerPath); + Debug.Assert(pipeFolder != null); + Reporter.Output.WriteLine(CliCommandStrings.ShuttingDownUnifiedBuildServers, AppContext.BaseDirectory, pipeFolder); + + return Task.WhenAll(EnumeratePipes(pipeFolder).Select(async file => + { + try + { + if (!BuildServerUtility.TryParsePipePath(file, out int pid, out ReadOnlySpan label)) + { + throw new GracefulException(CliCommandStrings.NamedPipeFileBadFormat, file); + } + + Reporter.Output.WriteLine(CliCommandStrings.ShuttingDownServerWithPid, label.ToString(), pid); + + // Connect to each pipe. + var client = BuildServerUtility.CreateClient(file); + await using var _ = client.ConfigureAwait(false); + await client.ConnectAsync().ConfigureAwait(false); + + // Send any data to request shutdown. + byte[] data = [1]; + await client.WriteAsync(data).ConfigureAwait(false); + + // Wait for the process to exit. + using var process = Process.GetProcessById(pid); + var timeout = new CancellationTokenSource(TimeSpan.FromMinutes(1)).Token; + await process.WaitForExitAsync(timeout).ConfigureAwait(false); + } + catch (Exception ex) when (ex is not GracefulException) + { + throw new GracefulException(string.Format(CliCommandStrings.NamedPipeShutdownError, file, ex.Message), ex); + } + })); + + static IEnumerable EnumeratePipes(string pipeFolder) + { + // On Windows, we need to enumerate all pipes and then filter them. + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Debug.Assert(pipeFolder.EndsWith('\\')); + return Directory.EnumerateFiles(BuildServerUtility.WindowsPipePrefix) + .Where(path => path.StartsWith(pipeFolder, StringComparison.OrdinalIgnoreCase) && + !path.AsSpan(pipeFolder.Length).ContainsAny('/', '\\')); + } + + // On Unix, we can directly enumerate the files in the pipe folder. + try + { + return Directory.EnumerateFiles(pipeFolder); + } + catch (DirectoryNotFoundException) + { + Reporter.Output.WriteLine(CliCommandStrings.NamedPipeFolderNotFound, pipeFolder); + return []; + } + } + } +} diff --git a/src/Cli/dotnet/BuildServer/VBCSCompilerServer.cs b/src/Cli/dotnet/BuildServer/VBCSCompilerServer.cs index 5be90f5ea202..97db4f1da4c5 100644 --- a/src/Cli/dotnet/BuildServer/VBCSCompilerServer.cs +++ b/src/Cli/dotnet/BuildServer/VBCSCompilerServer.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Cli.BuildServer; -internal class VBCSCompilerServer(ICommandFactory commandFactory = null) : IBuildServer +internal class VBCSCompilerServer : IBuildServer { private static readonly string s_toolsetPackageName = "microsoft.net.sdk.compilers.toolset"; private static readonly string s_vbcsCompilerExeFileName = "VBCSCompiler.exe"; @@ -22,19 +22,14 @@ internal class VBCSCompilerServer(ICommandFactory commandFactory = null) : IBuil "bincore", "VBCSCompiler.dll"); - private readonly ICommandFactory _commandFactory = commandFactory ?? new DotNetCommandFactory(alwaysRunOutOfProc: true); - public int ProcessId => 0; // Not yet used public string Name => CliStrings.VBCSCompilerServer; - public void Shutdown() + public Task ShutdownAsync() { List errors = null; - // Shutdown the compiler from the SDK. - execute(_commandFactory.Create("exec", [VBCSCompilerPath, s_shutdownArg]), ref errors); - // Shutdown toolset compilers. Reporter.Verbose.WriteLine($"Shutting down '{s_toolsetPackageName}' compilers."); var nuGetPackageRoot = SettingsUtility.GetGlobalPackagesFolder(Settings.LoadDefaultSettings(root: null)); @@ -61,6 +56,8 @@ public void Shutdown() string.Join(Environment.NewLine, errors))); } + return Task.CompletedTask; + static void execute(ICommand command, ref List errors) { command = command diff --git a/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommand.cs b/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommand.cs index 244660651751..e570c837810d 100644 --- a/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommand.cs +++ b/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommand.cs @@ -28,7 +28,8 @@ public BuildServerShutdownCommand( bool msbuild = result.GetValue(BuildServerShutdownCommandParser.MSBuildOption); bool vbcscompiler = result.GetValue(BuildServerShutdownCommandParser.VbcsOption); bool razor = result.GetValue(BuildServerShutdownCommandParser.RazorOption); - bool all = !msbuild && !vbcscompiler && !razor; + bool unified = result.GetValue(BuildServerShutdownCommandParser.UnifiedOption); + bool all = !msbuild && !vbcscompiler && !razor && !unified; _enumerationFlags = ServerEnumerationFlags.None; if (msbuild || all) @@ -46,6 +47,11 @@ public BuildServerShutdownCommand( _enumerationFlags |= ServerEnumerationFlags.Razor; } + if (unified || all) + { + _enumerationFlags |= ServerEnumerationFlags.Unified; + } + _serverProvider = serverProvider ?? new BuildServerProvider(); _useOrderedWait = useOrderedWait; _reporter = reporter ?? Reporter.Output; @@ -71,7 +77,10 @@ public override int Execute() if (task.IsFaulted) { success = false; - WriteFailureMessage(server, task.Exception); + foreach (var inner in task.Exception.InnerExceptions) + { + WriteFailureMessage(server, inner); + } } else { @@ -90,7 +99,7 @@ public override int Execute() foreach (var server in _serverProvider.EnumerateBuildServers(_enumerationFlags)) { WriteShutdownMessage(server); - tasks.Add((server, Task.Run(() => server.Shutdown()))); + tasks.Add((server, Task.Run(() => server.ShutdownAsync()))); } return tasks; @@ -124,24 +133,24 @@ private void WriteShutdownMessage(IBuildServer server) } } - private void WriteFailureMessage(IBuildServer server, AggregateException exception) + private void WriteFailureMessage(IBuildServer server, Exception exception) { if (server.ProcessId != 0) { - _reporter.WriteLine( + _errorReporter.WriteLine( string.Format( CliCommandStrings.ShutDownFailedWithPid, server.Name, server.ProcessId, - exception.InnerException.Message).Red()); + exception.Message).Red()); } else { - _reporter.WriteLine( + _errorReporter.WriteLine( string.Format( CliCommandStrings.ShutDownFailed, server.Name, - exception.InnerException.Message).Red()); + exception.Message).Red()); } if (CommandLoggingContext.IsVerbose) diff --git a/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommandParser.cs b/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommandParser.cs index a34ea767f28f..95c82980ef16 100644 --- a/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommandParser.cs +++ b/src/Cli/dotnet/Commands/BuildServer/Shutdown/BuildServerShutdownCommandParser.cs @@ -27,6 +27,12 @@ internal static class BuildServerShutdownCommandParser Arity = ArgumentArity.Zero }; + public static readonly Option UnifiedOption = new("--unified") + { + Description = CliCommandStrings.UnifiedOptionDescription, + Arity = ArgumentArity.Zero + }; + private static readonly Command Command = ConstructCommand(); public static Command GetCommand() @@ -41,6 +47,7 @@ private static Command ConstructCommand() command.Options.Add(MSBuildOption); command.Options.Add(VbcsOption); command.Options.Add(RazorOption); + command.Options.Add(UnifiedOption); command.SetAction((parseResult) => new BuildServerShutdownCommand(parseResult).Execute()); diff --git a/src/Cli/dotnet/Commands/CliCommandStrings.resx b/src/Cli/dotnet/Commands/CliCommandStrings.resx index 47e67b2f714e..742058f10f93 100644 --- a/src/Cli/dotnet/Commands/CliCommandStrings.resx +++ b/src/Cli/dotnet/Commands/CliCommandStrings.resx @@ -1887,6 +1887,25 @@ Your project targets multiple frameworks. Specify which framework to run using ' Shutting down {0} (process {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + + + Named pipe folder not found: {0} + + + Cannot parse pipe file name: {0} + + + Error while shutting down server for pipe '{0}': {1} + + + Unified build server + + + Shut down unified build servers via named pipes. + Skip updating the workload manifests. diff --git a/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs b/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs index fa2104c5ce4d..209513324e3a 100644 --- a/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs +++ b/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs @@ -779,11 +779,7 @@ public static string GetArtifactsPath(string entryPointFileFullPath) /// public static string GetTempSubdirectory() { - // We want a location where permissions are expected to be restricted to the current user. - string directory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? Path.GetTempPath() - : Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - + string directory = PathUtility.GetUserRestrictedTempDirectory(); return Path.Join(directory, "dotnet", "runfile"); } @@ -801,17 +797,10 @@ public static string GetTempSubpath(string name) /// public static void CreateTempSubdirectory(string path) { - if (OperatingSystem.IsWindows()) - { - Directory.CreateDirectory(path); - } - else - { - // Ensure only the current user has access to the directory to avoid leaking the program to other users. - // We don't mind that permissions might be different if the directory already exists, - // since it's under user's local directory and its path should be unique. - Directory.CreateDirectory(path, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); - } + // Ensure only the current user has access to the directory to avoid leaking the program to other users. + // We don't mind that permissions might be different if the directory already exists, + // since it's under user's local directory and its path should be unique. + PathUtility.CreateUserRestrictedDirectory(path); } public static void WriteProjectFile( diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf index f575ca805ef6..32fa55463f8e 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf @@ -1709,6 +1709,21 @@ Nástroj {1} (verze {2}) se úspěšně nainstaloval. Do souboru manifestu {3} s Název + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Cílem projektu je více architektur. Pomocí parametru {0} určete, která arch Vypíná se {0} (proces {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Přeskočit aktualizaci manifestů úlohy @@ -3488,6 +3508,16 @@ příkazu „dotnet tool list“. {0} pokus number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. Nástroj {0} se úspěšně odinstaloval a odebral ze souboru manifestu {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf index 39b2b8bfce27..fc46e308cde7 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf @@ -1709,6 +1709,21 @@ Das Tool "{1}" (Version {2}) wurde erfolgreich installiert. Der Eintrag wird der Name + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Ihr Projekt verwendet mehrere Zielframeworks. Geben Sie über "{0}" an, welches "{0}" (Prozess "{1}") wird heruntergefahren... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Überspringen Sie die Aktualisierung der Workload-Manifeste. @@ -3488,6 +3508,16 @@ und die zugehörigen Paket-IDs für installierte Tools über den Befehl {0} testen number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. Das Tool "{0}" wurde erfolgreich deinstalliert und aus der Manifestdatei "{1}" entfernt. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf index 9391f32360dd..991a1d116070 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf @@ -1709,6 +1709,21 @@ La herramienta "{1}" (versión "{2}") se instaló correctamente. Se ha agregado Nombre + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Su proyecto tiene como destino varias plataformas. Especifique la que quiere usa Apagando {0} (proceso {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Omitir la actualización de los manifiestos de carga de trabajo. @@ -3488,6 +3508,16 @@ y los identificadores de los paquetes correspondientes a las herramientas instal intento {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. La herramienta "{0}" se desinstaló y quitó correctamente del archivo de manifiesto {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf index 59b012cd4727..9fbb66cd3f4d 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf @@ -1709,6 +1709,21 @@ L'outil '{1}' (version '{2}') a été correctement installé. L'entrée est ajou Nom + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Votre projet cible plusieurs frameworks. Spécifiez le framework à exécuter à Arrêt de {0} (processus {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Ignorer la mise à jour des manifestes de charge de travail. @@ -3488,6 +3508,16 @@ et les ID de package correspondants aux outils installés, utilisez la commande essayer {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. L'outil '{0}' a été désinstallé et supprimé correctement du fichier manifeste {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf index b84ca44cde8a..4359c4813ec2 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf @@ -1709,6 +1709,21 @@ Lo strumento '{1}' versione '{2}' è stato installato. La voce è stata aggiunta Nome + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Il progetto è destinato a più framework. Specificare il framework da eseguire Arresto di {0} (processo {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Salta l'aggiornamento dei manifesti del carico di lavoro. @@ -3488,6 +3508,16 @@ e gli ID pacchetto corrispondenti per gli strumenti installati usando il comando prova {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. Lo strumento '{0}' è stato disinstallato e rimosso dal file manifesto {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf index 64c150a82bb2..a02f66bf7cd2 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf @@ -1709,6 +1709,21 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man 名前 + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Your project targets multiple frameworks. Specify which framework to run using ' {0} をシャットダウンしています (プロセス {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. ワークロード マニフェストの更新をスキップします。 @@ -3488,6 +3508,16 @@ and the corresponding package Ids for installed tools using the command {0} を試す number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. ツール '{0}' が正常にアンインストールされ、マニフェスト ファイル {1} から削除されました。 diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf index ebb73defdb26..e2d00f0c1ca9 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf @@ -1709,6 +1709,21 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man 이름 + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Your project targets multiple frameworks. Specify which framework to run using ' {0}(프로세스 {1})을(를) 종료하는 중... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. 워크로드 매니페스트 업데이트 건너뛰기 @@ -3488,6 +3508,16 @@ and the corresponding package Ids for installed tools using the command {0} 시도 number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. '{0}' 도구가 제거되었으며 매니페스트 파일 {1}에서 제거되었습니다. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf index 30b841b9736d..265fb4976745 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf @@ -1709,6 +1709,21 @@ Narzędzie „{1}” (wersja „{2}”) zostało pomyślnie zainstalowane. Wpis Nazwa + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Projekt ma wiele platform docelowych. Określ platformę do uruchomienia przy u Trwa zamykanie serwera {0} (proces {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Pomiń aktualizowanie manifestów pakietu roboczego. @@ -3488,6 +3508,16 @@ i odpowiednie identyfikatory pakietów zainstalowanych narzędzi można znaleź wypróbuj {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. Narzędzie „{0}” zostało pomyślnie odinstalowane i usunięte z pliku manifestu {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf index 02597933a68e..a95948014879 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf @@ -1709,6 +1709,21 @@ A ferramenta '{1}' (versão '{2}') foi instalada com êxito. A entrada foi adici Nome + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Ele tem diversas estruturas como destino. Especifique que estrutura executar usa Desligando o {0} (processo {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Ignorar a atualização dos manifestos de carga de trabalho. @@ -3488,6 +3508,16 @@ e as Ids de pacote correspondentes para as ferramentas instaladas usando o coman experimente {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. A ferramenta '{0}' foi desinstalada com êxito e removida do arquivo de manifesto {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf index 58ab84e02f1c..06c02f4f7aee 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf @@ -1709,6 +1709,21 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man Имя + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Your project targets multiple frameworks. Specify which framework to run using ' Завершается работа {0} (процесс {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. Пропустить обновление манифестов рабочей нагрузки. @@ -3489,6 +3509,16 @@ and the corresponding package Ids for installed tools using the command попробуйте {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. Средство "{0}" успешно удалено и исключено из файла манифеста {1}. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf index f1e3621090b0..2f51e432b317 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf @@ -1709,6 +1709,21 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man Ad + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Projeniz birden fazla Framework'ü hedefliyor. '{0}' kullanarak hangi Framework' {0} kapatılıyor (işlem {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. İş yükü bildirimlerinin güncelleştirilmesini atlayın. @@ -3488,6 +3508,16 @@ karşılık gelen paket kimliklerini bulmak için Şunu deneyin: {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. '{0}' aracı başarıyla kaldırıldı ve {1} bildirim dosyasından çıkarıldı. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf index b2a5d0d02422..4cc4ddc12ee8 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf @@ -1709,6 +1709,21 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man 名称 + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Your project targets multiple frameworks. Specify which framework to run using ' 正在关闭 {0} (进程 {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. 跳过更新工作负载清单。 @@ -3488,6 +3508,16 @@ and the corresponding package Ids for installed tools using the command 尝试 {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. 工具“{0}”已成功卸载并从清单文件 {1} 中移除。 diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf index c27ba06b1e75..908aeb7f9a9d 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf @@ -1709,6 +1709,21 @@ Tool '{1}' (version '{2}') was successfully installed. Entry is added to the man 名稱 + + Cannot parse pipe file name: {0} + Cannot parse pipe file name: {0} + + + + Named pipe folder not found: {0} + Named pipe folder not found: {0} + + + + Error while shutting down server for pipe '{0}': {1} + Error while shutting down server for pipe '{0}': {1} + + The 'dotnet tool search' command unconditionally accesses nuget.org to find tools, but it is not present in your nuget.config. Add it to run this command. This can be done with this command: @@ -2862,6 +2877,11 @@ Your project targets multiple frameworks. Specify which framework to run using ' 正在關閉 {0} (處理序 {1})... + + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + Shutting down unified build servers for SDK '{0}' via named pipe '{1}'... + {0} is full path to SDK directory. {1} is pipe name. + Skip updating the workload manifests. 跳過更新工作負載資訊清單。 @@ -3488,6 +3508,16 @@ and the corresponding package Ids for installed tools using the command 嘗試 {0} number or tries of the current test assembly when test assembly is being retried. {0} is number that starts at 1 + + Unified build server + Unified build server + + + + Shut down unified build servers via named pipes. + Shut down unified build servers via named pipes. + + Tool '{0}' was successfully uninstalled and removed from manifest file {1}. 已成功解除安裝工具 '{0}',且已將其從資訊清單檔 {1} 中移除。 diff --git a/test/dotnet.Tests/BuildServerTests/RazorServerTests.cs b/test/dotnet.Tests/BuildServerTests/RazorServerTests.cs index f5f6082cbdf1..6e675b717345 100644 --- a/test/dotnet.Tests/BuildServerTests/RazorServerTests.cs +++ b/test/dotnet.Tests/BuildServerTests/RazorServerTests.cs @@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Tests.BuildServerTests public class RazorServerTests { [Fact] - public void GivenAFailedShutdownCommandItThrows() + public async Task GivenAFailedShutdownCommandItThrows() { const int ProcessId = 1234; const string PipeName = "some-pipe-name"; @@ -46,9 +46,9 @@ public void GivenAFailedShutdownCommandItThrows() commandFactory: CreateCommandFactoryMock(serverPath, PipeName, exitCode: 1, stdErr: ErrorMessage).Object, fileSystem: fileSystemMock); - Action a = () => server.Shutdown(); + Func a = () => server.ShutdownAsync(); - a.Should().Throw().WithMessage( + await a.Should().ThrowAsync().WithMessage( string.Format( CliStrings.ShutdownCommandFailed, ErrorMessage)); @@ -57,7 +57,7 @@ public void GivenAFailedShutdownCommandItThrows() } [Fact] - public void GivenASuccessfulShutdownItDoesNotThrow() + public async Task GivenASuccessfulShutdownItDoesNotThrow() { const int ProcessId = 1234; const string PipeName = "some-pipe-name"; @@ -85,13 +85,13 @@ public void GivenASuccessfulShutdownItDoesNotThrow() commandFactory: CreateCommandFactoryMock(serverPath, PipeName).Object, fileSystem: fileSystemMock); - server.Shutdown(); + await server.ShutdownAsync(); fileSystemMock.File.Exists(pidFilePath).Should().BeFalse(); } [Fact] - public void GivenANonExistingRazorServerPathItDeletesPidFileAndDoesNotThrow() + public async Task GivenANonExistingRazorServerPathItDeletesPidFileAndDoesNotThrow() { const int ProcessId = 1234; const string PipeName = "some-pipe-name"; @@ -119,9 +119,9 @@ public void GivenANonExistingRazorServerPathItDeletesPidFileAndDoesNotThrow() commandFactory: commandFactoryMock.Object, fileSystem: fileSystemMock); - Action a = () => server.Shutdown(); + Func a = () => server.ShutdownAsync(); - a.Should().NotThrow(); + await a.Should().NotThrowAsync(); commandFactoryMock.Verify(c => c.Create(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); fileSystemMock.File.Exists(pidFilePath).Should().BeFalse(); diff --git a/test/dotnet.Tests/BuildServerTests/UnifiedBuildServerTests.cs b/test/dotnet.Tests/BuildServerTests/UnifiedBuildServerTests.cs new file mode 100644 index 000000000000..172f5fb2ab64 --- /dev/null +++ b/test/dotnet.Tests/BuildServerTests/UnifiedBuildServerTests.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.DotNet.Tests.BuildServerTests; + +[CollectionDefinition(nameof(BuildServerTestCollection), DisableParallelization = true)] +public sealed class BuildServerTestCollection : ICollectionFixture; + +[Collection(nameof(BuildServerTestCollection))] +public sealed class UnifiedBuildServerTests(ITestOutputHelper output) : SdkTest(output) +{ + [Fact] + public void Shutdown_Roslyn() + { + var testInstance = _testAssetsManager.CreateTestDirectory(); + File.WriteAllText(Path.Join(testInstance.Path, "app.csproj"), $""" + + + Exe + {ToolsetInfo.CurrentTargetFramework} + enable + + + """); + File.WriteAllText(Path.Join(testInstance.Path, "app.cs"), """ + Console.WriteLine(); + """); + + var roslynLog = Path.Join(testInstance.Path, "roslyn-log.txt"); + + // Ensure there is no build server running from other tests. + new DotnetCommand(Log, "build-server", "shutdown", "--unified") + .WithWorkingDirectory(testInstance.Path) + .Execute() + .Should().Pass() + .And.NotHaveStdErr(); + + // Build. + new DotnetCommand(Log, "build") + .WithWorkingDirectory(testInstance.Path) + .WithEnvironmentVariable("RoslynCommandLineLogFile", roslynLog) + .Execute() + .Should().Pass() + .And.HaveStdOutContaining("app.dll"); + + // Shutdown the build server. + var result = new DotnetCommand(Log, "build-server", "shutdown", "--unified") + .WithWorkingDirectory(testInstance.Path) + .Execute(); + + Log.WriteLine(roslynLog); + string roslynLogText = File.ReadAllText(roslynLog); + Log.WriteLine(roslynLogText); + + result.Should().Pass() + .And.HaveStdOutContaining("VBCSCompiler") + .And.NotHaveStdErr(); + } +} diff --git a/test/dotnet.Tests/BuildServerTests/VBCSCompilerServerTests.cs b/test/dotnet.Tests/BuildServerTests/VBCSCompilerServerTests.cs deleted file mode 100644 index 3b50670c936b..000000000000 --- a/test/dotnet.Tests/BuildServerTests/VBCSCompilerServerTests.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#nullable disable - -using Microsoft.DotNet.Cli; -using Microsoft.DotNet.Cli.BuildServer; -using Microsoft.DotNet.Cli.CommandFactory; -using Microsoft.DotNet.Cli.Utils; -using Moq; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tests.BuildServerTests -{ - public class VBCSCompilerServerTests - { - [Fact] - public void GivenAZeroExitShutdownDoesNotThrow() - { - var server = new VBCSCompilerServer(CreateCommandFactoryMock().Object); - server.Shutdown(); - } - - [Fact] - public void GivenANonZeroExitCodeShutdownThrows() - { - const string ErrorMessage = "failed!"; - - var server = new VBCSCompilerServer(CreateCommandFactoryMock(exitCode: 1, stdErr: ErrorMessage).Object); - - Action a = () => server.Shutdown(); - - a.Should().Throw().WithMessage( - string.Format( - CliStrings.ShutdownCommandFailed, - ErrorMessage)); - } - - private Mock CreateCommandFactoryMock(int exitCode = 0, string stdErr = "") - { - var commandMock = new Mock(MockBehavior.Strict); - commandMock.Setup(c => c.CaptureStdOut()).Returns(commandMock.Object); - commandMock.Setup(c => c.CaptureStdErr()).Returns(commandMock.Object); - commandMock.Setup(c => c.Execute()).Returns(new CommandResult(null, exitCode, "", stdErr)); - - var commandFactoryMock = new Mock(MockBehavior.Strict); - commandFactoryMock - .Setup( - f => f.Create( - "exec", - new string[] { VBCSCompilerServer.VBCSCompilerPath, "-shutdown" }, - It.IsAny(), - Constants.DefaultConfiguration)) - .Returns(commandMock.Object); - - return commandFactoryMock; - } - } -} diff --git a/test/dotnet.Tests/CommandTests/BuildServer/Shutdown/BuildServerShutdownCommandTests.cs b/test/dotnet.Tests/CommandTests/BuildServer/Shutdown/BuildServerShutdownCommandTests.cs index f8b0e85c1a0c..52d1c1d4b6fc 100644 --- a/test/dotnet.Tests/CommandTests/BuildServer/Shutdown/BuildServerShutdownCommandTests.cs +++ b/test/dotnet.Tests/CommandTests/BuildServer/Shutdown/BuildServerShutdownCommandTests.cs @@ -217,11 +217,11 @@ private Mock CreateServerMock(string name, int pid = 0, string exc if (exceptionMessage == null) { - mock.Setup(s => s.Shutdown()); + mock.Setup(s => s.ShutdownAsync()).Returns(Task.CompletedTask); } else { - mock.Setup(s => s.Shutdown()).Throws(new Exception(exceptionMessage)); + mock.Setup(s => s.ShutdownAsync()).Throws(new Exception(exceptionMessage)); } return mock; @@ -231,7 +231,7 @@ private void VerifyShutdownCalls(IEnumerable> mocks) { foreach (var mock in mocks) { - mock.Verify(s => s.Shutdown(), Times.Once); + mock.Verify(s => s.ShutdownAsync(), Times.Once); } } diff --git a/test/dotnet.Tests/CompletionTests/snapshots/bash/DotnetCliSnapshotTests.VerifyCompletions.verified.sh b/test/dotnet.Tests/CompletionTests/snapshots/bash/DotnetCliSnapshotTests.VerifyCompletions.verified.sh index 0e1338dd8889..42f6b3ca026c 100644 --- a/test/dotnet.Tests/CompletionTests/snapshots/bash/DotnetCliSnapshotTests.VerifyCompletions.verified.sh +++ b/test/dotnet.Tests/CompletionTests/snapshots/bash/DotnetCliSnapshotTests.VerifyCompletions.verified.sh @@ -212,7 +212,7 @@ _testhost_build_server_shutdown() { prev="${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=() - opts="--msbuild --vbcscompiler --razor --help" + opts="--msbuild --vbcscompiler --razor --unified --help" if [[ $COMP_CWORD == "$1" ]]; then COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) diff --git a/test/dotnet.Tests/CompletionTests/snapshots/pwsh/DotnetCliSnapshotTests.VerifyCompletions.verified.ps1 b/test/dotnet.Tests/CompletionTests/snapshots/pwsh/DotnetCliSnapshotTests.VerifyCompletions.verified.ps1 index b467b6d256c8..3fa3f9f8a228 100644 --- a/test/dotnet.Tests/CompletionTests/snapshots/pwsh/DotnetCliSnapshotTests.VerifyCompletions.verified.ps1 +++ b/test/dotnet.Tests/CompletionTests/snapshots/pwsh/DotnetCliSnapshotTests.VerifyCompletions.verified.ps1 @@ -112,6 +112,7 @@ Register-ArgumentCompleter -Native -CommandName 'testhost' -ScriptBlock { [CompletionResult]::new('--msbuild', '--msbuild', [CompletionResultType]::ParameterName, "Shut down the MSBuild build server.") [CompletionResult]::new('--vbcscompiler', '--vbcscompiler', [CompletionResultType]::ParameterName, "Shut down the VB/C# compiler build server.") [CompletionResult]::new('--razor', '--razor', [CompletionResultType]::ParameterName, "Shut down the Razor build server.") + [CompletionResult]::new('--unified', '--unified', [CompletionResultType]::ParameterName, "Shut down unified build servers via named pipes.") [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, "Show command line help.") [CompletionResult]::new('--help', '-h', [CompletionResultType]::ParameterName, "Show command line help.") ) diff --git a/test/dotnet.Tests/CompletionTests/snapshots/zsh/DotnetCliSnapshotTests.VerifyCompletions.verified.zsh b/test/dotnet.Tests/CompletionTests/snapshots/zsh/DotnetCliSnapshotTests.VerifyCompletions.verified.zsh index 81e2a63dddc0..44e2b41f1cca 100644 --- a/test/dotnet.Tests/CompletionTests/snapshots/zsh/DotnetCliSnapshotTests.VerifyCompletions.verified.zsh +++ b/test/dotnet.Tests/CompletionTests/snapshots/zsh/DotnetCliSnapshotTests.VerifyCompletions.verified.zsh @@ -99,6 +99,7 @@ _testhost() { '--msbuild[Shut down the MSBuild build server.]' \ '--vbcscompiler[Shut down the VB/C# compiler build server.]' \ '--razor[Shut down the Razor build server.]' \ + '--unified[Shut down unified build servers via named pipes.]' \ '--help[Show command line help.]' \ '-h[Show command line help.]' \ && ret=0