예제 #1
0
        public void SimpleAddAndRetrieveProject()
        {
            // Initialize engine.
            Engine engine = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up variables that represent the information we would be getting from 
            // the "MSBuild" task.
            string fullPath = @"c:\rajeev\temp\myapp.proj";
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Debug");

            // Create a new project that matches the information that we're pretending
            // to receive from the MSBuild task.
            Project project1 = new Project(engine);
            project1.FullFileName = fullPath;
            project1.GlobalProperties = globalProperties;

            // Add the new project to the ProjectManager.
            projectManager.AddProject(project1);

            // Try and retrieve the project from the ProjectManager based on the fullpath + globalprops,
            // and make sure we get back the same project we added.
            Assertion.AssertEquals(project1, projectManager.GetProject(fullPath, globalProperties, null));
        }
예제 #2
0
 internal Introspector(Engine parentEngine, ProjectManager projectManager, NodeManager nodeManager)
 {
     this.parentEngine   = parentEngine;
     this.projectManager = projectManager;
     this.nodeManager    = nodeManager;
     this.ignoreTimeout  = 0;
 }
예제 #3
0
        public void TestForDuplicatesInProjectTable()
        {
            ProjectManager projectManager = new ProjectManager();

            string fullPath = @"c:\foo\bar.proj";
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("p1", "v1");

            Project p = new Project(new Engine());
            p.FullFileName = fullPath;
            p.GlobalProperties = globalProperties;
            p.ToolsVersion = "4.0";

            // Add the new project to the ProjectManager, twice
            Hashtable table = new Hashtable(StringComparer.OrdinalIgnoreCase);
            ProjectManager.AddProject(table, p);
            ProjectManager.AddProject(table, p);

            Assertion.AssertEquals(1, ((ArrayList)table[fullPath]).Count); // Didn't add a duplicate

            // Add a second, slightly different project, and ensure it DOES get added
            Project p2 = new Project(new Engine());
            p2.FullFileName = fullPath;
            p2.GlobalProperties = globalProperties;
            p2.ToolsVersion = "2.0";

            ProjectManager.AddProject(table, p2);

            Project p3 = new Project(new Engine());
            p3.FullFileName = fullPath;
            p3.GlobalProperties = new BuildPropertyGroup();
            p3.ToolsVersion = "2.0";

            ProjectManager.AddProject(table, p3);

            Assertion.AssertEquals(3, ((ArrayList)table[fullPath]).Count);
        }
예제 #4
0
        public void RemoveProjectsByFullPath()
        {
            // Initialize engine.  Need two separate engines because we don't allow two
            // projects with the same full path to be loaded in the same Engine.
            Engine engine1 = new Engine(@"c:\");
            Engine engine2 = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up a global property group.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Release");

            // Create a few new projects.
            Project project1 = new Project(engine1);
            project1.FullFileName = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            Project project2 = new Project(engine1);
            project2.FullFileName = @"c:\blah\foo.proj";
            project2.GlobalProperties = globalProperties;

            Project project3 = new Project(engine2);
            project3.FullFileName = @"c:\blah\foo.proj";
            globalProperties.SetProperty("Configuration", "Debug");
            project3.GlobalProperties = globalProperties;

            // Add the new projects to the ProjectManager.
            projectManager.AddProject(project1);
            projectManager.AddProject(project2);
            projectManager.AddProject(project3);

            // Remove all projects with the full path "c:\blah\foo.proj" (case insenstively).
            projectManager.RemoveProjects(@"c:\BLAH\FOO.Proj");

            // Make sure project 1 is still there.
            Assertion.AssertEquals(project1, projectManager.GetProject(project1.FullFileName, project1.GlobalProperties, null));

            // Make sure projects 2 and 3 are gone.
            Assertion.AssertNull(projectManager.GetProject(project2.FullFileName, project2.GlobalProperties, null));
            Assertion.AssertNull(projectManager.GetProject(project3.FullFileName, project3.GlobalProperties, null));
        }
예제 #5
0
        public void ResetBuildStatusForAllProjects()
        {
            // Initialize engine.  Need two separate engines because we don't allow two
            // projects with the same full path to be loaded in the same Engine.
            Engine engine1 = new Engine(@"c:\");
            Engine engine2 = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up a global property group.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Release");

            // Create a few new projects.
            Project project1 = new Project(engine1);
            project1.FullFileName = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            Project project2 = new Project(engine1);
            project2.FullFileName = @"c:\blah\foo.proj";
            project2.GlobalProperties = globalProperties;

            Project project3 = new Project(engine2);
            project3.FullFileName = @"c:\blah\foo.proj";
            globalProperties.SetProperty("Configuration", "Debug");
            project3.GlobalProperties = globalProperties;

            // Add the new projects to the ProjectManager.
            projectManager.AddProject(project1);
            projectManager.AddProject(project2);
            projectManager.AddProject(project3);

            // Put all the projects in a non-reset state.
            project1.IsReset = false;
            project2.IsReset = false;
            project3.IsReset = false;

            // Call ResetAllProjects.
            projectManager.ResetBuildStatusForAllProjects();

            // Make sure they all got reset.
            Assertion.Assert(project1.IsReset);
            Assertion.Assert(project2.IsReset);
            Assertion.Assert(project3.IsReset);
        }
예제 #6
0
        public void SimpleAddAndRetrieveProjectWithDifferentFullPath()
        {
            // Initialize engine.
            Engine engine = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up variables that represent the information we would be getting from 
            // the "MSBuild" task.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Release");

            // Create a new project that matches the information that we're pretending
            // to receive from the MSBuild task.
            Project project1 = new Project(engine);
            project1.FullFileName = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            // Add the new project to the ProjectManager.
            projectManager.AddProject(project1);

            // Now search for a project with a different full path but same set of global
            // properties.  We expect to get back null, because no such project exists.
            Assertion.AssertNull(projectManager.GetProject(@"c:\blah\wrong.proj", globalProperties, null));
        }
예제 #7
0
        public void TestForDuplicatesInProjectEntryTable()
        {
            ProjectManager projectManager = new ProjectManager();

            string fullPath = @"c:\foo\bar.proj";
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("p1", "v1");
            string toolsVersion = "3.5";

            // Add the new project entry to the ProjectManager, twice
            Hashtable table = new Hashtable(StringComparer.OrdinalIgnoreCase);
            ProjectManager.AddProjectEntry(table, fullPath, globalProperties, toolsVersion, 0);

            ProjectManager.AddProjectEntry(table, fullPath, globalProperties, toolsVersion, 0);

            Assertion.AssertEquals(1, ((ArrayList)table[fullPath]).Count); // Didn't add a duplicate

            // Add a second, slightly different project entry, and ensure it DOES get added
            ProjectManager.AddProjectEntry(table, fullPath, globalProperties, "2.0", 0);
            ProjectManager.AddProjectEntry(table, fullPath, new BuildPropertyGroup(), "2.0", 0);

            Assertion.AssertEquals(3, ((ArrayList)table[fullPath]).Count);
        }
예제 #8
0
 /// <summary>
 /// Initalizes a new instance of the itemlist
 /// </summary>
 /// <param name="project"></param>
 public ItemList(ProjectManager project)
 {
     this.Project = project;
     root_hierarchy = (IVsHierarchy)project;
     root = CreateNode(VSConstants.VSITEMID_ROOT);
 }
예제 #9
0
파일: Engine.cs 프로젝트: nikson/msbuild
        /// <summary>
        /// Constructor to init all data except for BinPath which is initialized separately because 
        /// a parameterless constructor is needed for COM interop
        /// </summary>
        internal Engine
        (
            int numberOfCpus, 
            bool isChildNode, 
            int parentNodeId, 
            string localNodeProviderParameters,
            BuildPropertyGroup globalProperties, 
            ToolsetDefinitionLocations locations
        )
        {
            // No need to check whether locations parameter 
            // is null, because it is a value type

            this.startupDirectory = Environment.CurrentDirectory;
            this.engineGlobalProperties = globalProperties == null ? new BuildPropertyGroup() : globalProperties;
            this.environmentProperties = new BuildPropertyGroup();
            this.toolsetStateMap = new Dictionary<string, ToolsetState>(StringComparer.OrdinalIgnoreCase);
            this.toolsets = new ToolsetCollection(this);

            // Every environment variable can be referenced just like a property
            // from the project file.  Here, we go ahead and add all the environment
            // variables to the property bag, so they can be treated just like any
            // other property later on.
            this.environmentProperties.GatherEnvironmentVariables();

            this.projectsLoadedByHost = new Hashtable(StringComparer.OrdinalIgnoreCase);

            this.cacheOfBuildingProjects = new ProjectManager();

            this.eventSource = new EventSource();

            this.buildEnabled = true;

            this.flushRequestEvent = new ManualResetEvent(false);

            this.primaryLoggingServices = new EngineLoggingServicesInProc(eventSource, false, flushRequestEvent);

            // Read any toolsets from the registry and config file
            PopulateToolsetStateMap(locations);

            this.nodeId = parentNodeId;
            this.localNodeProviderParameters = localNodeProviderParameters;
            this.numberOfCpus = numberOfCpus;

            if (this.numberOfCpus == 1 && !isChildNode)
            {
                this.primaryLoggingServices.FlushBuildEventsImmediatly = true;
            }

            this.buildRequests = new DualQueue<BuildRequest>();

            this.taskOutputUpdates = new DualQueue<TaskExecutionContext>();

            this.engineCommands = new DualQueue<EngineCommand>();

            this.engineCallback = new EngineCallback(this);
            this.nodeManager = new NodeManager(this.numberOfCpus, isChildNode, this);
            this.scheduler = new Scheduler(this.nodeId, this);
            this.router = new Router(this, scheduler);
            this.cacheManager = new CacheManager(this.DefaultToolsVersion);

            this.lastUsedLoggerId = EngineLoggingServicesInProc.FIRST_AVAILABLE_LOGGERID;

            this.enabledCentralLogging = false;

            this.introspector = new Introspector(this, cacheOfBuildingProjects, nodeManager);

            // Initialize the node provider
            InitializeLocalNodeProvider(locations);
        }