Beispiel #1
0
        /// <summary>
        /// Installs a template from the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="timeout">The timeout.</param>
        /// <returns>A task representing the operation.</returns>
        public static Task InstallAsync(string source, TimeSpan?timeout = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            return(ProcessExtensions.StartAsync(
                       DirectoryExtensions.GetCurrentDirectory(),
                       "dotnet",
                       $"new --install \"{source}\"",
                       CancellationTokenFactory.GetCancellationToken(timeout)));
        }
Beispiel #2
0
 /// <summary>
 /// Reinitialises the dotnet new command.
 /// </summary>
 /// <param name="timeout">The timeout. Defaults to one minute.</param>
 /// <param name="showShellWindow">if set to <c>true</c> show the shell window instead of logging to output.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 public static async Task ReinitialiseAsync(TimeSpan?timeout = null, bool showShellWindow = false)
 {
     using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
     {
         await ProcessExtensions
         .StartAsync(
             DirectoryExtensions.GetCurrentDirectory(),
             "dotnet",
             $"new --debug:reinit",
             showShellWindow,
             cancellationTokenSource.Token)
         .ConfigureAwait(false);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Installs a template from the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="timeout">The timeout. Defaults to one minute.</param>
        /// <param name="showShellWindow">if set to <c>true</c> show the shell window instead of logging to output.</param>
        /// <returns>A task representing the operation.</returns>
        public static async Task InstallAsync(string source, TimeSpan?timeout = null, bool showShellWindow = false)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1)))
            {
                await ProcessExtensions
                .StartAsync(
                    DirectoryExtensions.GetCurrentDirectory(),
                    "dotnet",
                    $"new --install \"{source}\"",
                    showShellWindow,
                    cancellationTokenSource.Token)
                .ConfigureAwait(false);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Installs a template from the specified source.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="timeout">The timeout.</param>
 /// <returns>A task representing the operation.</returns>
 public static Task Install(string source, TimeSpan?timeout = null) =>
 ProcessExtensions.StartAsync(
     DirectoryExtensions.GetCurrentDirectory(),
     "dotnet",
     $"new --install \"{source}\"",
     CancellationTokenFactory.GetCancellationToken(timeout));