Ejemplo n.º 1
0
        public void BuildProjectWithReservedGlobalProperty()
        {
            string childProject = ObjectModelHelpers.CreateTempFileOnDisk(@"
                <Project xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                    <Target Name=`1`></Target>
                 </Project>
            ");

            string mainProject = ObjectModelHelpers.CreateTempFileOnDisk(@"
                <Project xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                    <Target Name=`1`>
                        <MSBuild Projects=`@(ProjectReference)`/>
                    </Target>
                    <ItemGroup>
                        <ProjectReference Include=`{0}`><Properties>Target=1</Properties></ProjectReference>
                    </ItemGroup>
                 </Project>
                 ", childProject);

            ProjectIdLogger logger = new ProjectIdLogger();
            Engine engine = new Engine();
            engine.RegisterLogger(logger);

            Project project = new Project(engine, "4.0");
            project.Load(mainProject);

            bool success = project.Build(null, null);
            Assertion.Assert("Build succeded and should have failed.  See Standard Out tab for details", !success);
        }
Ejemplo n.º 2
0
        public void RestoringProjectIdFromCache()
        {
            string childProject = ObjectModelHelpers.CreateTempFileOnDisk(@"
                <Project xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>

                  <Target Name=`Build`>
                    <Message Text=`Hi`/>
                  </Target>
                </Project>
            ");

            string mainProject = ObjectModelHelpers.CreateTempFileOnDisk(@"
                <Project xmlns=`http://schemas.microsoft.com/developer/msbuild/2003`>
                  <Target Name=`Build`>
                    <MSBuild Projects=`{0}` UnloadProjectsOnCompletion=`true` UseResultsCache=`true`/>
                    <MSBuild Projects=`{0}` UnloadProjectsOnCompletion=`true` UseResultsCache=`true`/>
                  </Target>
                </Project>
            ", childProject);

            ProjectIdLogger logger = new ProjectIdLogger();
            Engine engine = new Engine();
            engine.RegisterLogger(logger);

            Project project = new Project(engine, "4.0");
            project.Load(mainProject);

            bool success = project.Build(null, null);
            Assertion.Assert("Build failed.  See Standard Out tab for details", success);

            Assert.AreEqual(3, logger.ProjectStartedEvents.Count);
            // Project ID should be preserved between runs
            Assert.AreEqual(logger.ProjectStartedEvents[1].ProjectId, logger.ProjectStartedEvents[2].ProjectId);
            // Project context ID should be different for every entry into the project.
            Assert.AreNotEqual(logger.ProjectStartedEvents[1].BuildEventContext.ProjectContextId, logger.ProjectStartedEvents[2].BuildEventContext.ProjectContextId);
        }