@@ -20,28 +20,18 @@ public static partial class Builder
2020 const string ToolsVersion = "14.0" ;
2121#endif
2222
23- public static BuildResult Build ( string projectOrSolution , string targets , Dictionary < string , string > properties = null , ILogger logger = null )
23+ public static BuildResult Build ( ProjectInstance project , string targets , Dictionary < string , string > properties = null , ILogger logger = null )
2424 {
25- if ( ! Path . IsPathRooted ( projectOrSolution ) )
26- projectOrSolution = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , projectOrSolution ) ;
27-
28- if ( ! File . Exists ( projectOrSolution ) )
29- throw new FileNotFoundException ( $ "Project or solution to build { projectOrSolution } was not found.", projectOrSolution ) ;
25+ properties = properties ?? new Dictionary < string , string > ( ) ;
3026
3127 // Without this, builds end up running in process and colliding with each other,
3228 // especially around the current directory used to resolve relative paths in projects.
3329 //Environment.SetEnvironmentVariable("MSBUILDNOINPROCNODE", "1", EnvironmentVariableTarget.Process);
3430 using ( var manager = new BuildManager ( Guid . NewGuid ( ) . ToString ( ) ) )
3531 {
36- properties = properties ?? new Dictionary < string , string > ( ) ;
37-
38- // If file is not a solution, build up a fake solution configuration so P2P references just work
39- if ( Path . GetExtension ( projectOrSolution ) != ".sln" )
40- AddSolutionConfiguration ( projectOrSolution , properties ) ;
41-
42- var request = new BuildRequestData ( projectOrSolution , properties , ToolsVersion , targets . Split ( ',' ) , null ) ;
32+ var request = new BuildRequestData ( project , targets . Split ( ',' ) , null ) ;
4333 var parameters = new BuildParameters
44- {
34+ {
4535 GlobalProperties = properties ,
4636 DisableInProcNode = ! Debugger . IsAttached ,
4737 EnableNodeReuse = false ,
@@ -61,6 +51,25 @@ public static BuildResult Build(string projectOrSolution, string targets, Dictio
6151 }
6252 }
6353
54+ public static BuildResult Build ( string projectOrSolution , string targets , Dictionary < string , string > properties = null , ILogger logger = null )
55+ {
56+ if ( ! Path . IsPathRooted ( projectOrSolution ) )
57+ projectOrSolution = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , projectOrSolution ) ;
58+
59+ if ( ! File . Exists ( projectOrSolution ) )
60+ throw new FileNotFoundException ( $ "Project or solution to build { projectOrSolution } was not found.", projectOrSolution ) ;
61+
62+ properties = properties ?? new Dictionary < string , string > ( ) ;
63+
64+ // If file is not a solution, build up a fake solution configuration so P2P references just work
65+ if ( Path . GetExtension ( projectOrSolution ) != ".sln" )
66+ AddSolutionConfiguration ( projectOrSolution , properties ) ;
67+
68+ var projectInstance = new ProjectInstance ( projectOrSolution , properties , ToolsVersion ) ;
69+
70+ return Build ( projectInstance , targets , properties , logger ) ;
71+ }
72+
6473 static void AddSolutionConfiguration ( string projectFile , Dictionary < string , string > properties )
6574 {
6675 var collection = new ProjectCollection ( properties ) ;
0 commit comments