GetLoadedProject() 공개 메소드

public GetLoadedProject ( string projectFullFileName ) : Microsoft.Build.BuildEngine.Project
projectFullFileName string
리턴 Microsoft.Build.BuildEngine.Project
예제 #1
0
        /// <summary>
        /// Initializes the in memory project. Sets BuildEnabled on the project to true.
        /// </summary>
        /// <param name="engine">The build engine to use to create a build project.</param>
        /// <param name="fullProjectPath">The full path of the project.</param>
        /// <returns>A loaded msbuild project.</returns>
        internal static MSBuild.Project InitializeMsBuildProject(MSBuild.Engine buildEngine, string fullProjectPath)
        {
            if (buildEngine == null)
            {
                throw new ArgumentNullException("engine");
            }

            if (String.IsNullOrEmpty(fullProjectPath))
            {
                throw new ArgumentException(SR.GetString(SR.InvalidParameter), "fullProjectPath");
            }

            // Check if the project already has been loaded with the fullProjectPath. If yes return the build project associated to it.
            MSBuild.Project buildProject = buildEngine.GetLoadedProject(fullProjectPath);

            if (buildProject == null)
            {
                buildProject = buildEngine.CreateNewProject();
                buildProject.BuildEnabled = true;
                buildProject.Load(fullProjectPath);
            }

            return(buildProject);
        }
예제 #2
0
        public void MalformedProjectDoesNotGetAddedToEngine
            (
            )
        {
            Engine myEngine = new Engine(@"c:\");
            Project myProject = myEngine.CreateNewProject();

            // Create a temp file to be used as our project file.
            string projectFile = Path.GetTempFileName();
            try
            {
                // Write some garbage into a project file.
                File.WriteAllText(projectFile, "blah");
                Assertion.AssertNull("Engine should not know about project before project has been loaded",
                    myEngine.GetLoadedProject(projectFile));

                int exceptionCount = 0;

                // Load the garbage project file.  We should get an exception.
                try
                {
                    myProject.Load(projectFile);
                }
                catch (InvalidProjectFileException)
                {
                    exceptionCount++;
                }

                Assertion.AssertEquals("Should have received invalid project file exception.", 1, exceptionCount);

                Assertion.AssertNull("Engine should not know about project if project load failed.",
                    myEngine.GetLoadedProject(projectFile));
            }
            finally
            {
                // Get a little extra code coverage
                myEngine.UnregisterAllLoggers();
                myEngine.UnloadAllProjects();
                
                File.Delete(projectFile);
            }
        }
예제 #3
0
		internal void UnloadProject (Engine engine, string file, bool releaseEngine)
		{
			lock (unsavedProjects)
				unsavedProjects.Remove (file);

			RunSTA (delegate {
				var loadedProj = engine.GetLoadedProject (file);
				if (loadedProj != null)
					engine.UnloadProject (loadedProj);
			});
		}