@@ -45,10 +45,14 @@ module SdkDiscovery =
45
45
|> Seq.toArray
46
46
47
47
p.WaitForExit()
48
+
48
49
if p.ExitCode = 0 then
49
50
output
50
51
elif failOnError then
51
- let output = output |> String.concat " \n "
52
+ let output =
53
+ output
54
+ |> String.concat " \n "
55
+
52
56
failwith $" `{binaryFullPath.FullName} {args}` failed with exit code %i {p.ExitCode}. Output: %s {output}"
53
57
else
54
58
// for the legacy VS flow, whose behaviour is harder to test, we maintain compatibility with how proj-info
@@ -340,6 +344,20 @@ module ProjectLoader =
340
344
internal
341
345
| StandardProject of ProjectInstance
342
346
| 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
343
361
344
362
let internal projectLoaderLogger = lazy ( LogProvider.getLoggerByName " ProjectLoader" )
345
363
@@ -411,11 +429,12 @@ module ProjectLoader =
411
429
match _ message with
412
430
| null ->
413
431
// 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
415
434
416
435
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:"
419
438
|> ignore
420
439
421
440
for ( KeyValue( k, v)) in properties do
@@ -617,7 +636,7 @@ module ProjectLoader =
617
636
let lines : seq < string > = File.ReadLines path
618
637
619
638
( Seq.tryFind ( fun ( line : string ) -> line.Contains legacyProjFormatXmlns) lines)
620
- .IsSome
639
+ |> Option.isSome
621
640
else
622
641
false
623
642
@@ -639,22 +658,20 @@ module ProjectLoader =
639
658
let loggers = createLoggers [ path ] binaryLogs sw
640
659
641
660
let pi = project.CreateProjectInstance()
661
+ let designTimeTargets = designTimeBuildTargets isLegacyFrameworkProjFile
642
662
643
663
let doDesignTimeBuild () =
644
- let build = pi.Build( designTimeBuildTargets isLegacyFrameworkProjFile , loggers)
664
+ let build = pi.Build( designTimeTargets , loggers)
645
665
646
666
if build then
647
667
Ok( StandardProject pi)
648
668
else
649
669
Error( sw.ToString())
650
670
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)
658
675
659
676
with exc ->
660
677
projectLoaderLogger.Value.error (
@@ -723,6 +740,7 @@ module ProjectLoader =
723
740
}
724
741
)
725
742
|> Seq.toList
743
+ | Other(_) -> List.empty
726
744
727
745
let getCompileItems ( p : ProjectInstance ) =
728
746
p.Items
@@ -945,6 +963,7 @@ module ProjectLoader =
945
963
type LoadedProjectInfo =
946
964
| StandardProjectInfo of ProjectOptions
947
965
| TraversalProjectInfo of ProjectReference list
966
+ | OtherProjectInfo of ProjectInstance
948
967
949
968
let getLoadedProjectInfo ( path : string ) customProperties project : Result < LoadedProjectInfo , string > =
950
969
// let (LoadedProject p) = project
@@ -1001,6 +1020,7 @@ module ProjectLoader =
1001
1020
else
1002
1021
let proj = mapToProject path commandLineArgs p2pRefs compileItems nuGetRefs sdkInfo props customProps
1003
1022
Ok( LoadedProjectInfo.StandardProjectInfo proj)
1023
+ | LoadedProject.Other p -> Ok( LoadedProjectInfo.OtherProjectInfo p)
1004
1024
1005
1025
/// A type that turns project files or solution files into deconstructed options.
1006
1026
/// Use this in conjunction with the other ProjInfo libraries to turn these options into
@@ -1105,42 +1125,32 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
1105
1125
paths
1106
1126
|> Seq.iter ( fun p -> loadingNotification.Trigger( WorkspaceProjectState.Loading p))
1107
1127
1128
+ let designTimeTargets = ProjectLoader.designTimeBuildTargets false
1129
+
1108
1130
let graph =
1109
- match
1131
+ let entryPoints =
1110
1132
paths
1133
+ |> Seq.map ProjectGraphEntryPoint
1111
1134
|> 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
1142
1135
1136
+ let g : ProjectGraph =
1143
1137
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)
1144
1154
1145
1155
graph
1146
1156
@@ -1205,9 +1215,11 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
1205
1215
let gbr =
1206
1216
GraphBuildRequestData(
1207
1217
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)
1211
1223
)
1212
1224
1213
1225
let bm = BuildManager.DefaultBuildManager
@@ -1260,7 +1272,6 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
1260
1272
let projects =
1261
1273
builtProjects
1262
1274
|> Seq.map ( fun p -> p.FullPath, ProjectLoader.getLoadedProjectInfo p.FullPath customProperties ( ProjectLoader.StandardProject p))
1263
-
1264
1275
|> Seq.choose ( fun ( projectPath , projectOptionResult ) ->
1265
1276
match projectOptionResult with
1266
1277
| Ok projectOptions ->
@@ -1303,6 +1314,12 @@ type WorkspaceLoaderViaProjectGraph private (toolsPath, ?globalProperties: (stri
1303
1314
)
1304
1315
1305
1316
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
+
1306
1323
)
1307
1324
1308
1325
allStandardProjects :> seq<_>
@@ -1417,6 +1434,7 @@ type WorkspaceLoader private (toolsPath: ToolsPath, ?globalProperties: (string *
1417
1434
match project with
1418
1435
| ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> p.ReferencedProjects
1419
1436
| ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> p
1437
+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> []
1420
1438
1421
1439
let lst =
1422
1440
referencedProjects
@@ -1432,6 +1450,7 @@ type WorkspaceLoader private (toolsPath: ToolsPath, ?globalProperties: (string *
1432
1450
match project with
1433
1451
| ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> Some p
1434
1452
| ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> None
1453
+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> None
1435
1454
1436
1455
lst, info
1437
1456
| Error msg ->
@@ -1446,13 +1465,14 @@ type WorkspaceLoader private (toolsPath: ToolsPath, ?globalProperties: (string *
1446
1465
1447
1466
match project with
1448
1467
| ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> loadingNotification.Trigger( WorkspaceProjectState.Loaded( p, getAllKnown (), true ))
1449
-
1450
1468
| ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> ()
1469
+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> ()
1451
1470
1452
1471
let referencedProjects =
1453
1472
match project with
1454
1473
| ProjectLoader.LoadedProjectInfo.StandardProjectInfo p -> p.ReferencedProjects
1455
1474
| ProjectLoader.LoadedProjectInfo.TraversalProjectInfo p -> p
1475
+ | ProjectLoader.LoadedProjectInfo.OtherProjectInfo p -> []
1456
1476
1457
1477
let lst =
1458
1478
referencedProjects
0 commit comments