/// <summary> /// Runs 'dotnet publish' on the specified project. /// </summary> /// <param name="project">The project.</param> /// <param name="framework">The framework.</param> /// <param name="runtime">The runtime.</param> /// <param name="noRestore">Whether to restore the project.</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 DotnetPublishAsync( this Project project, string framework = null, string runtime = null, bool?noRestore = true, TimeSpan?timeout = null, bool showShellWindow = false) { if (project is null) { throw new ArgumentNullException(nameof(project)); } var frameworkArgument = framework is null ? null : $"--framework {framework}"; var runtimeArgument = runtime is null ? null : $"--self-contained --runtime {runtime}"; var noRestoreArgument = noRestore is null ? null : "--no-restore"; DirectoryExtensions.CheckCreate(project.PublishDirectoryPath); using (var cancellationTokenSource = new CancellationTokenSource(timeout ?? TimeSpan.FromMinutes(1))) { await AssertStartAsync( project.DirectoryPath, "dotnet", $"publish {noRestoreArgument} {frameworkArgument} {runtimeArgument} --output {project.PublishDirectoryPath}", showShellWindow, cancellationTokenSource.Token) .ConfigureAwait(false); } }
/// <summary> /// Runs 'dotnet publish' on the specified project. /// </summary> /// <param name="project">The project.</param> /// <param name="framework">The framework.</param> /// <param name="runtime">The runtime.</param> /// <param name="noRestore">Whether to restore the project.</param> /// <param name="timeout">The timeout.</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 Task DotnetPublishAsync( this Project project, string framework = null, string runtime = null, bool?noRestore = true, TimeSpan?timeout = null, bool showShellWindow = false) { if (project is null) { throw new ArgumentNullException(nameof(project)); } var frameworkArgument = framework is null ? null : $"--framework {framework}"; var runtimeArgument = runtime is null ? null : $"--self-contained --runtime {runtime}"; var noRestoreArgument = noRestore is null ? null : "--no-restore"; DirectoryExtensions.CheckCreate(project.PublishDirectoryPath); return(AssertStartAsync( project.DirectoryPath, "dotnet", $"publish {noRestoreArgument} {frameworkArgument} {runtimeArgument} --output {project.PublishDirectoryPath}", showShellWindow, CancellationTokenFactory.GetCancellationToken(timeout))); }
/// <summary> /// Runs 'dotnet publish' on the specified project. /// </summary> /// <param name="project">The project.</param> /// <param name="framework">The framework.</param> /// <param name="runtime">The runtime.</param> /// <param name="noRestore">Whether to restore the project.</param> /// <param name="timeout">The timeout.</param> /// <returns>A task representing the operation.</returns> public static Task DotnetPublish( this Project project, string framework = null, string runtime = null, bool?noRestore = true, TimeSpan?timeout = null) { var frameworkArgument = framework == null ? null : $"--framework {framework}"; var runtimeArgument = runtime == null ? null : $"--self-contained --runtime {runtime}"; var noRestoreArgument = noRestore == null ? null : "--no-restore"; DirectoryExtensions.CheckCreate(project.PublishDirectoryPath); return(AssertStartAsync( project.DirectoryPath, "dotnet", $"publish {noRestoreArgument} {frameworkArgument} {runtimeArgument} --output {project.PublishDirectoryPath}", CancellationTokenFactory.GetCancellationToken(timeout))); }
/// <summary> /// Initializes a new instance of the <see cref="TempDirectory"/> class. /// </summary> /// <param name="directoryPath">The temporary directory path.</param> public TempDirectory(string directoryPath) { this.DirectoryPath = directoryPath; DirectoryExtensions.CheckCreate(this.DirectoryPath); }