Skip to content

Commit

Permalink
Add DotnetNew.ReinitialiseAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Mar 17, 2020
1 parent d080b2f commit 0b5309a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Source/Boxed.DotnetNewTest/Boxed.DotnetNewTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<PropertyGroup Label="Package">
<VersionPrefix>3.3.0</VersionPrefix>
<VersionPrefix>3.4.0</VersionPrefix>
<Authors>Muhammad Rehan Saeed (RehanSaeed.com)</Authors>
<Company>Muhammad Rehan Saeed (RehanSaeed.com)</Company>
<Product>ASP.NET Core Dotnet New Test Boxed</Product>
Expand Down
27 changes: 24 additions & 3 deletions Source/Boxed.DotnetNewTest/DotnetNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class DotnetNew
/// </summary>
/// <typeparam name="T">A type from the assembly used to find the directory path of the project to install.</typeparam>
/// <param name="fileName">Name of the file.</param>
/// <returns>A task representing the operation.</returns>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static Task InstallAsync<T>(string fileName) =>
InstallAsync(typeof(T).GetTypeInfo().Assembly, fileName);

Expand All @@ -26,7 +26,7 @@ public static Task InstallAsync<T>(string fileName) =>
/// </summary>
/// <param name="assembly">The assembly used to find the directory path of the project to install.</param>
/// <param name="fileName">Name of the file.</param>
/// <returns>A task representing the operation.</returns>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
/// <exception cref="FileNotFoundException">A file with the specified file name was not found.</exception>
public static Task InstallAsync(Assembly assembly, string fileName)
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public static Task InstallAsync(Assembly assembly, string fileName)
/// <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>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static async Task InstallAsync(string source, TimeSpan? timeout = null, bool showShellWindow = false)
{
if (source is null)
Expand All @@ -76,6 +76,27 @@ await ProcessExtensions
}
}

/// <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);
}
}

private static string GetFilePath(Assembly assembly, string projectName)
{
string projectFilePath = null;
Expand Down

0 comments on commit 0b5309a

Please sign in to comment.