GetLoadedProject() public method

public GetLoadedProject ( string projectFullFileName ) : Microsoft.Build.BuildEngine.Project
projectFullFileName string
return 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
ファイル: Engine_Tests.cs プロジェクト: nikson/msbuild
        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
ファイル: BuildEngine.cs プロジェクト: fedorw/monodevelop
		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);
			});
		}