protected virtual void SetMsbuildEngine(ProjectFactory factory) { FieldInfo buildEngine = typeof(ProjectFactory).GetField("buildEngine", BindingFlags.Instance | BindingFlags.NonPublic); buildEngine.SetValue(factory, Engine.GlobalEngine); Microsoft.Build.BuildEngine.Project msbuildproject = Engine.GlobalEngine.CreateNewProject(); FieldInfo buildProject = typeof(ProjectFactory).GetField("buildProject", BindingFlags.Instance | BindingFlags.NonPublic); buildProject.SetValue(factory, msbuildproject); }
protected virtual void SetMsbuildEngine(ProjectFactory factory) { ProjectCollection.GlobalProjectCollection.UnloadAllProjects(); FieldInfo buildEngine = typeof(ProjectFactory).GetField("buildEngine", BindingFlags.Instance | BindingFlags.NonPublic); buildEngine.SetValue(factory, ProjectCollection.GlobalProjectCollection); Microsoft.Build.Evaluation.Project msbuildproject = ProjectCollection.GlobalProjectCollection.LoadProject(projectFile); FieldInfo buildProject = typeof(ProjectFactory).GetField("buildProject", BindingFlags.Instance | BindingFlags.NonPublic); buildProject.SetValue(factory, msbuildproject); }