Skip to content

Commit

Permalink
Dotnet uninstall command changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Sep 23, 2024
1 parent 49914d4 commit 6f0ef1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/app/Fake.DotNet.Cli/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2047,13 +2047,13 @@ module DotNet =
__.MarkSuccess()

/// <summary>
/// Execute dotnet new <c>--uninstall &lt;PATH|NUGET_ID&gt;</c> command to uninstall a new template
/// Execute dotnet new <c>uninstall &lt;PATH|NUGET_ID&gt;</c> command to uninstall a new template
/// </summary>
///
/// <param name="templateName">template short name to uninstall</param>
/// <param name="setParams">set version command parameters</param>
let uninstallTemplate templateName =
use __ = Trace.traceTask "DotNet:new" "dotnet new --uninstall command"
use __ = Trace.traceTask "DotNet:new" "dotnet new uninstall command"
let param = TemplateUninstallOptions.Create(templateName)
let args = buildTemplateUninstallArgs param
let result = execArgsList (fun _ -> param.Common) "new" args
Expand All @@ -2070,6 +2070,6 @@ module DotNet =

match success with
| true -> ()
| false -> failwithf $"dotnet new --uninstall failed with code %i{result.ExitCode}"
| false -> failwithf $"dotnet new uninstall failed with code %i{result.ExitCode}"

__.MarkSuccess()
6 changes: 3 additions & 3 deletions src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ let tests =

Expect.equal cli expected "New --install args generated correctly."

testCase "Test that the dotnet new --uninstall command works as expected"
testCase "Test that the dotnet new uninstall command works as expected"
<| fun _ ->
let param = DotNet.TemplateUninstallOptions.Create("my-awesome-template")
let cli = param |> DotNet.buildTemplateUninstallArgs |> Args.toWindowsCommandLine

let expected = "--uninstall my-awesome-template"
let expected = "uninstall my-awesome-template"

Expect.equal cli expected "New --uninstall args generated correctly."
Expect.equal cli expected "New uninstall args generated correctly."

testCase "Test buildAfterArgs with no after args"
<| fun _ ->
Expand Down
20 changes: 10 additions & 10 deletions src/test/Fake.DotNet.Cli.IntegrationTests/TemplateTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,6 @@ let fileExists dir fileName =
let setupTemplate () =
Process.setEnableProcessTracing true

try
DotNet.uninstallTemplate templatePackageName
with exn ->
$"should clear out preexisting templates\nDebugging Info: {getDebuggingInfo ()}"
|> Expect.isTrue false

printfn $"{Environment.CurrentDirectory}"

DotNet.setupEnv dotnetSdk.Value

let templateNupkg =
GlobbingPattern.create "../../../release/dotnetcore/fake-template.*.nupkg"
|> GlobbingPattern.setBaseDir __SOURCE_DIRECTORY__
Expand All @@ -154,6 +144,16 @@ let setupTemplate () =
| Some t -> t
| Option.None -> templatePackageName

try // Specs have changed: needs full package name: https://github.com/dotnet/docs/pull/3054
DotNet.uninstallTemplate fakeTemplateName
with exn ->
$"should clear out preexisting templates\nDebugging Info: {getDebuggingInfo ()}"
|> Expect.isTrue false

printfn $"{Environment.CurrentDirectory}"

DotNet.setupEnv dotnetSdk.Value

try
DotNet.installTemplate fakeTemplateName id
with exn ->
Expand Down

0 comments on commit 6f0ef1b

Please sign in to comment.