@@ -948,15 +948,7 @@ private ProjectInstance CreateTraversalInstance(string wrapperProjectToolsVersio
948
948
// Add our local extensibility points to the project representing the solution
949
949
// Imported at the top: before.mysolution.sln.targets
950
950
// Imported at the bottom: after.mysolution.sln.targets
951
- string escapedSolutionFile = EscapingUtilities . Escape ( Path . GetFileName ( _solutionFile . FullPath ) ) ;
952
- string escapedSolutionDirectory = EscapingUtilities . Escape ( _solutionFile . SolutionFileDirectory ) ;
953
- string localFile = Path . Combine ( escapedSolutionDirectory , "before." + escapedSolutionFile + ".targets" ) ;
954
- ProjectImportElement importBeforeLocal = traversalProject . CreateImportElement ( localFile ) ;
955
- importBeforeLocal . Condition = @"exists('" + localFile + "')" ;
956
-
957
- localFile = Path . Combine ( escapedSolutionDirectory , "after." + escapedSolutionFile + ".targets" ) ;
958
- ProjectImportElement importAfterLocal = traversalProject . CreateImportElement ( localFile ) ;
959
- importAfterLocal . Condition = @"exists('" + localFile + "')" ;
951
+ ( ProjectImportElement importBeforeLocal , ProjectImportElement importAfterLocal ) = CreateBeforeAndAfterSolutionImports ( traversalProject ) ;
960
952
961
953
// Put locals second so they can override globals if they want
962
954
traversalProject . PrependChild ( importBeforeLocal ) ;
@@ -1025,6 +1017,27 @@ private ProjectInstance CreateTraversalInstance(string wrapperProjectToolsVersio
1025
1017
return traversalInstance ;
1026
1018
}
1027
1019
1020
+ private ( ProjectImportElement ImportBeforeSln , ProjectImportElement ImportAfterSln ) CreateBeforeAndAfterSolutionImports ( ProjectRootElement traversalProject )
1021
+ {
1022
+ string escapedSolutionFileName = EscapingUtilities . Escape ( Path . GetFileName ( _solutionFile . FullPath ) ) ;
1023
+ if ( escapedSolutionFileName . EndsWith ( ".slnx" ) )
1024
+ {
1025
+ // We want to load only after.{solutionFileName}.sln.targets for solution files with .slnx extension
1026
+ escapedSolutionFileName = escapedSolutionFileName . Substring ( 0 , escapedSolutionFileName . Length - 1 ) ;
1027
+ }
1028
+
1029
+ string escapedSolutionDirectory = EscapingUtilities . Escape ( _solutionFile . SolutionFileDirectory ) ;
1030
+ string localFile = Path . Combine ( escapedSolutionDirectory , $ "before.{ escapedSolutionFileName } .targets") ;
1031
+ ProjectImportElement importBeforeLocal = traversalProject . CreateImportElement ( localFile ) ;
1032
+ importBeforeLocal . Condition = $ "exists('{ localFile } ')";
1033
+
1034
+ localFile = Path . Combine ( escapedSolutionDirectory , $ "after.{ escapedSolutionFileName } .targets") ;
1035
+ ProjectImportElement importAfterLocal = traversalProject . CreateImportElement ( localFile ) ;
1036
+ importAfterLocal . Condition = $ "exists('{ localFile } ')";
1037
+
1038
+ return ( importBeforeLocal , importAfterLocal ) ;
1039
+ }
1040
+
1028
1041
private void EmitMetaproject ( ProjectRootElement metaproject , string path )
1029
1042
{
1030
1043
if ( Traits . Instance . EmitSolutionMetaproj )
0 commit comments