Skip to content

Commit 368defd

Browse files
all together now
1 parent 9f9d1ea commit 368defd

File tree

3 files changed

+30
-45
lines changed

3 files changed

+30
-45
lines changed

src/Graph.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ type Builder<'node> = {
3131
}
3232
let rec private buildNode (builder) (depth) (id) =
3333
if Debug then
34-
printfn "Building (%d) %A" depth id
34+
cprintf Color.Yellow "Building (%d) %A" depth id
3535

3636
let nodeBuilder = buildNode builder (depth + 1)
3737
{ Id = id; Edges = List.map (nodeBuilder) (builder.GetEdges id) }
3838

3939
let rec private visitNode (visitor : VisitorState<'node, 'state>) (node : Node<'node>) =
4040
if Debug then
41-
printfn "Visiting (%d) %A" visitor.Traveled id
41+
cprintf Color.Yellow "Visiting (%d) %A" visitor.Traveled node.Id
4242

4343
match Set.contains node.Id visitor.Visited with
4444
| true -> visitor

src/Program.fs

+28-29
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,43 @@ open BulkAdd.Projects
77
open System
88
open System.IO
99
open BulkAdd.Graph
10+
open BulkAdd.Paths
1011

1112

1213
type StartInfo = System.Diagnostics.ProcessStartInfo
1314
type Process = System.Diagnostics.Process
1415

15-
let addProject slnPath (projects: #seq<string>) =
16-
for projPath in projects do
1716

18-
printfn"-----------------------"
19-
printfn"Adding %s to %s" projPath slnPath
17+
let addProjectToSln slnPath (ProjectRef projectLocation) =
2018

21-
let command = sprintf "sln \"%s\" add \"%s\"" slnPath projPath
22-
if Debug then
23-
printfn "dotnet %s" command
24-
if Global.WhatIfMode then
25-
printfn "Not Executing in WhatIf mode"
26-
else
27-
try
19+
let projectPath =
20+
match projectLocation with
21+
| Abs (AbsPath abs) -> abs
22+
| Rel (RelPath rel) -> rel
2823

29-
let startInfo = StartInfo()
30-
startInfo.FileName <- "dotnet"
31-
startInfo.Arguments <- command
24+
printfn"-----------------------"
25+
printfn"Adding %A to %s" projectPath slnPath
3226

33-
let proc = Process.Start(startInfo)
34-
proc.WaitForExit()
27+
let command = sprintf "sln \"%s\" add \"%s\"" slnPath projectPath
28+
if Debug then
29+
printfn "dotnet %s" command
30+
if Global.WhatIfMode then
31+
printfn "WhatIf mode, No Action Taken"
32+
else
33+
try
34+
let startInfo = StartInfo()
35+
startInfo.FileName <- "dotnet"
36+
startInfo.Arguments <- command
3537

36-
match proc.ExitCode with
37-
| 0 -> cprintf Color.Green "OK"
38-
| code -> cprintf Color.Yellow "Unusual Return :("
39-
with
40-
| _ -> ()
41-
printfn"-----------------------"
38+
let proc = Process.Start(startInfo)
39+
proc.WaitForExit()
40+
41+
match proc.ExitCode with
42+
| 0 -> cprintf Color.Green "OK"
43+
| code -> cprintf Color.Yellow "Unusual Return :("
44+
with
45+
| _ -> ()
46+
//printfn"-----------------------"
4247

4348

4449
[<EntryPoint>]
@@ -61,15 +66,9 @@ let main argv =
6166

6267
let inspector = {
6368
State = ()
64-
Inspector = fun (proj, ()) -> printfn"%A" proj
69+
Inspector = fun (projectRef, ()) -> addProjectToSln argData.SolutionFile projectRef
6570
}
6671

6772
Graph.Visit(originNode, inspector)
6873

69-
// |> Path.GetFullPath
70-
// |> AbsPath
71-
// |> ProjectRef
72-
// |> Graph.
73-
// |> addProject argData.SolutionFile
74-
7574
0

src/Projects.fs

-14
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,3 @@ let GetProjectDependencies(ProjectRef location) =
3030
| Rel relPath -> relPath |> Paths.toAbs pwd |> getProjectDependencies
3131
| Abs absPath -> absPath |> getProjectDependencies
3232

33-
// let getPro(ProjectRef project) =
34-
// //try
35-
36-
// let projectXml = getXml project
37-
38-
// let getAttrib name (node:XElement) = name |> XName.Get |> node.Attribute |> Option.ofObj
39-
40-
// projectXml.Descendants (XName.Get "ProjectReference")
41-
// |> Seq.choose (getAttrib "Include")
42-
// |> Seq.map (fun attr -> attr.Value |> Paths.toAbs projectFile |> ProjectRef)
43-
// //|> Seq.map (fun attr -> attr.Value |> ProjectRef)
44-
// |> Seq.toList
45-
// // with
46-
// // | ex -> Error ex.Message

0 commit comments

Comments
 (0)