@@ -45,10 +45,14 @@ module SdkDiscovery =
4545 |> Seq.toArray
4646
4747 p.WaitForExit()
48+
4849 if p.ExitCode = 0 then
4950 output
5051 elif failOnError then
51- let output = output |> String.concat " \n "
52+ let output =
53+ output
54+ |> String.concat " \n "
55+
5256 failwith $" `{binaryFullPath.FullName} {args}` failed with exit code %i {p.ExitCode}. Output: %s {output}"
5357 else
5458 // for the legacy VS flow, whose behaviour is harder to test, we maintain compatibility with how proj-info
@@ -340,6 +344,20 @@ module ProjectLoader =
340344 internal
341345 | StandardProject of ProjectInstance
342346 | TraversalProject of ProjectInstance
347+ /// This could be things like shproj files, or other things that aren't standard projects
348+ | Other of ProjectInstance
349+
350+ let (| IsTraversal | _ |) ( p : ProjectInstance ) =
351+ match p.GetProperty " IsTraversal" with
352+ | null -> None
353+ | p when Boolean.TryParse( p.EvaluatedValue) = ( true , false ) -> None
354+ | _ -> Some()
355+
356+ let (| DesignTimeCapable | _ |) ( targets : string seq ) ( p : ProjectInstance ) =
357+ if Seq.forall p.Targets.ContainsKey targets then
358+ Some()
359+ else
360+ None
343361
344362 let internal projectLoaderLogger = lazy ( LogProvider.getLoggerByName " ProjectLoader" )
345363
@@ -411,11 +429,12 @@ module ProjectLoader =
411429 match _ message with
412430 | null ->
413431 // if the project is already loaded throw a nicer message
414- let message = System.Text.StringBuilder()
432+ let message = Text.StringBuilder()
433+ let appendLine ( t : string ) ( sb : Text.StringBuilder ) = sb.AppendLine t
415434
416435 message
417- .AppendLine ( $" The project '{projectPath}' already exists in the project collection with the same global properties." )
418- .AppendLine ( " The global properties requested were:" )
436+ |> appendLine $" The project '{projectPath}' already exists in the project collection with the same global properties."
437+ |> appendLine " The global properties requested were:"
419438 |> ignore
420439
421440 for ( KeyValue( k, v)) in properties do
@@ -617,7 +636,7 @@ module ProjectLoader =
617636 let lines : seq < string > = File.ReadLines path
618637
619638 ( Seq.tryFind ( fun ( line : string ) -> line.Contains legacyProjFormatXmlns) lines)
620- .IsSome
639+ |> Option.isSome
621640 else
622641 false
623642
@@ -639,22 +658,20 @@ module ProjectLoader =
639658 let loggers = createLoggers [ path ] binaryLogs sw
640659
641660 let pi = project.CreateProjectInstance()
661+ let designTimeTargets = designTimeBuildTargets isLegacyFrameworkProjFile
642662
643663 let doDesignTimeBuild () =
644- let build = pi.Build( designTimeBuildTargets isLegacyFrameworkProjFile , loggers)
664+ let build = pi.Build( designTimeTargets , loggers)
645665
646666 if build then
647667 Ok( StandardProject pi)
648668 else
649669 Error( sw.ToString())
650670
651- let yieldTraversalProject () = Ok( TraversalProject pi)
652-
653- // do traversal project detection here
654- match pi.GetProperty " IsTraversal" with
655- | null -> doDesignTimeBuild ()
656- | p when Boolean.Parse( p.EvaluatedValue) = false -> doDesignTimeBuild ()
657- | _ -> yieldTraversalProject ()
671+ match pi with
672+ | IsTraversal -> Ok( TraversalProject pi)
673+ | DesignTimeCapable designTimeTargets -> doDesignTimeBuild ()
674+ | _ -> Ok( Other pi)
658675
659676 with exc ->
660677 projectLoaderLogger.Value.error (
@@ -723,6 +740,7 @@ module ProjectLoader =
723740 }
724741 )
725742 |> Seq.toList
743+ | Other(_) -> List.empty
726744
727745 let getCompileItems ( p : ProjectInstance ) =
728746 p.Items
@@ -945,6 +963,7 @@ module ProjectLoader =
945963 type LoadedProjectInfo =
946964 | StandardProjectInfo of ProjectOptions
947965 | TraversalProjectInfo of ProjectReference list
966+ | OtherProjectInfo of ProjectInstance
948967
949968 let getLoadedProjectInfo ( path : string ) customProperties project : Result < LoadedProjectInfo , string > =
950969 // let (LoadedProject p) = project
@@ -1001,6 +1020,7 @@ module ProjectLoader =
10011020 else
10021021 let proj = mapToProject path commandLineArgs p2pRefs compileItems nuGetRefs sdkInfo props customProps
10031022 Ok( LoadedProjectInfo.StandardProjectInfo proj)
1023+ | LoadedProject.Other p -> Ok( LoadedProjectInfo.OtherProjectInfo p)
10041024
10051025/// A type that turns project files or solution files into deconstructed options.
10061026/// Use this in conjunction with the other ProjInfo libraries to turn these options into
@@ -1105,42 +1125,32 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
11051125 paths
11061126 |> Seq.iter ( fun p -> loadingNotification.Trigger( WorkspaceProjectState.Loading p))
11071127
1128+ let designTimeTargets = ProjectLoader.designTimeBuildTargets false
1129+
11081130 let graph =
1109- match
1131+ let entryPoints =
11101132 paths
1133+ |> Seq.map ProjectGraphEntryPoint
11111134 |> List.ofSeq
1112- with
1113- | [ x ] ->
1114- let g : ProjectGraph =
1115- ProjectGraph( x, projectCollection = per_ request_ collection, projectInstanceFactory = projectInstanceFactory)
1116- // When giving ProjectGraph a singular project, g.EntryPointNodes only contains that project.
1117- // To get it to build the Graph with all the dependencies we need to look at all the ProjectNodes
1118- // and tell the graph to use all as potentially an entrypoint
1119- let nodes =
1120- g.ProjectNodes
1121- |> Seq.choose ( fun pn ->
1122- match pn.ProjectInstance.GetProperty( " IsTraversal" ) with
1123- | null ->
1124- ProjectGraphEntryPoint pn.ProjectInstance.FullPath
1125- |> Some
1126- | p ->
1127- match bool.TryParse( p.EvaluatedValue) with
1128- | true , true -> None
1129- | true , false ->
1130- ProjectGraphEntryPoint pn.ProjectInstance.FullPath
1131- |> Some
1132- | false , _ -> None
1133- )
1134-
1135- ProjectGraph( nodes, projectCollection = per_ request_ collection, projectInstanceFactory = projectInstanceFactory)
1136-
1137- | xs ->
1138- let entryPoints =
1139- paths
1140- |> Seq.map ProjectGraphEntryPoint
1141- |> List.ofSeq
11421135
1136+ let g : ProjectGraph =
11431137 ProjectGraph( entryPoints, projectCollection = per_ request_ collection, projectInstanceFactory = projectInstanceFactory)
1138+ // When giving ProjectGraph a singular project, g.EntryPointNodes only contains that project.
1139+ // To get it to build the Graph with all the dependencies we need to look at all the ProjectNodes
1140+ // and tell the graph to use all as potentially an entrypoint
1141+ // Additionally, we need to filter out any projects that are not design time capable
1142+ let nodes =
1143+ g.ProjectNodes
1144+ |> Seq.choose ( fun pn ->
1145+ match pn.ProjectInstance with
1146+ | ProjectLoader.DesignTimeCapable designTimeTargets ->
1147+
1148+ ProjectGraphEntryPoint pn.ProjectInstance.FullPath
1149+ |> Some
1150+ | _ -> None
1151+ )
1152+
1153+ ProjectGraph( nodes, projectCollection = per_ request_ collection, projectInstanceFactory = projectInstanceFactory)
11441154
11451155 graph
11461156
@@ -1205,9 +1215,11 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
12051215 let gbr =
12061216 GraphBuildRequestData(
12071217 projectGraph = projects,
1208- targetsToBuild= ProjectLoader.designTimeBuildTargets false ,
1209- hostServices= null ,
1210- flags= ( BuildRequestDataFlags.ReplaceExistingProjectInstance ||| BuildRequestDataFlags.ClearCachesAfterBuild)
1218+ targetsToBuild = ProjectLoader.designTimeBuildTargets false ,
1219+ hostServices = null ,
1220+ flags =
1221+ ( BuildRequestDataFlags.ReplaceExistingProjectInstance
1222+ ||| BuildRequestDataFlags.ClearCachesAfterBuild)
12111223 )
12121224
12131225 let bm = BuildManager.DefaultBuildManager
@@ -1260,7 +1272,6 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
12601272 let projects =
12611273 builtProjects
12621274 |> Seq.map ( fun p -> p.FullPath, ProjectLoader.getLoadedProjectInfo p.FullPath customProperties ( ProjectLoader.StandardProject p))
1263-
12641275 |> Seq.choose ( fun ( projectPath , projectOptionResult ) ->
12651276 match projectOptionResult with
12661277 | Ok projectOptions ->
@@ -1303,6 +1314,12 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
13031314 )
13041315
13051316 loadingNotification.Trigger( WorkspaceProjectState.Loaded( po, allStandardProjects, false ))
1317+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p ->
1318+ logger.info (
1319+ Log.setMessage " Other project loaded {project}"
1320+ >> Log.addContextDestructured " project" p.FullPath
1321+ )
1322+
13061323 )
13071324
13081325 allStandardProjects :> seq<_>
@@ -1417,6 +1434,7 @@ type WorkspaceLoader private (toolsPath: ToolsPath, ?globalProperties: (string *
14171434 match project with
14181435 | ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> p.ReferencedProjects
14191436 | ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> p
1437+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> []
14201438
14211439 let lst =
14221440 referencedProjects
@@ -1432,6 +1450,7 @@ type WorkspaceLoader private (toolsPath: ToolsPath, ?globalProperties: (string *
14321450 match project with
14331451 | ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> Some p
14341452 | ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> None
1453+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> None
14351454
14361455 lst, info
14371456 | Error msg ->
@@ -1446,13 +1465,14 @@ type WorkspaceLoader private (toolsPath: ToolsPath, ?globalProperties: (string *
14461465
14471466 match project with
14481467 | ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> loadingNotification.Trigger( WorkspaceProjectState.Loaded( p, getAllKnown (), true ))
1449-
14501468 | ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> ()
1469+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> ()
14511470
14521471 let referencedProjects =
14531472 match project with
14541473 | ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> p.ReferencedProjects
14551474 | ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> p
1475+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> []
14561476
14571477 let lst =
14581478 referencedProjects
0 commit comments