Skip to content

Commit dd59e60

Browse files
Small improvements to the solution explorer init
1 parent 752f4ca commit dd59e60

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Components/SolutionExplorer.fs

+19-2
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,26 @@ module SolutionExplorer =
551551
let! name = window.showInputBox(opts)
552552
if JS.isDefined dir && JS.isDefined name then
553553
let output = if String.IsNullOrWhiteSpace dir then None else Some dir
554-
let name = if String.IsNullOrWhiteSpace name then None else Some name
554+
let projName = if String.IsNullOrWhiteSpace name then None else Some name
555+
556+
let! _ = LanguageService.dotnetNewRun template.description projName output
557+
let model = getSolution()
558+
//If it's the solution workspace we want to add project to the solution
559+
match model with
560+
| Some (Workspace [Solution (_,_, slnName, _)]) ->
561+
let pname =
562+
if projName.IsSome then projName.Value + ".fsproj" else
563+
if output.IsSome then output.Value + ".fsproj" else
564+
(path.dirname workspace.rootPath) + ".fsproj"
565+
566+
let proj =
567+
path.join(workspace.rootPath, dir, name, pname)
568+
Project.execWithDotnet MSBuild.outputChannel (sprintf "sln %s add %s" slnName proj) |> ignore
569+
| _ ->
570+
//If it's the first project in the workspace we need to init the workspace
571+
if Project.getInWorkspace().IsEmpty then
572+
do! Project.initWorkspace()
555573

556-
let! _ = LanguageService.dotnetNewRun template.description name output
557574
()
558575
else
559576
window.showErrorMessage "No open folder." |> ignore

src/Core/Project.fs

+2-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ module Project =
602602
|> Array.map fst
603603

604604
match x with
605-
| WorkspacePeekFound.Solution _
605+
| WorkspacePeekFound.Solution _ ->
606+
setAnyProjectContext true
606607
| WorkspacePeekFound.Directory _ when not(projs |> Array.isEmpty) ->
607608
setAnyProjectContext true
608609
| _ -> ()

0 commit comments

Comments
 (0)