Пример #1
0
        public void Evaluate()
        {
            if (projectInstance != null)
            {
                engine.DisposeProjectInstance(projectInstance);
            }

            info = msproject.LoadNativeInstance();

            engine          = info.Engine;
            projectInstance = engine.CreateProjectInstance(info.Project);

            try {
                foreach (var prop in globalProperties)
                {
                    engine.SetGlobalProperty(projectInstance, prop.Key, prop.Value);
                }

                engine.Evaluate(projectInstance);

                SyncBuildProject(info.ItemMap, info.Engine, projectInstance);
            } catch (Exception ex) {
                // If the project can't be evaluated don't crash
                LoggingService.LogError("MSBuild project could not be evaluated", ex);
                throw new ProjectEvaluationException(msproject, ex.Message);
            }
        }
        public void Evaluate()
        {
            object oldProjectInstance = null;

            if (projectInstance != null)
            {
                oldProjectInstance = projectInstance;
            }

            info = msproject.LoadNativeInstance(!OnlyEvaluateProperties);

            engine          = info.Engine;
            projectInstance = engine.CreateProjectInstance(info.Project);

            try {
                // Set properties defined by global property providers, and then
                // properties explicitly set to this instance

                foreach (var gpp in MSBuildProjectService.GlobalPropertyProviders)
                {
                    foreach (var prop in gpp.GetGlobalProperties())
                    {
                        engine.SetGlobalProperty(projectInstance, prop.Key, prop.Value);
                    }
                }
                foreach (var prop in globalProperties)
                {
                    engine.SetGlobalProperty(projectInstance, prop.Key, prop.Value);
                }

                engine.Evaluate(projectInstance, OnlyEvaluateProperties);

                SyncBuildProject(info.ItemMap, info.Engine, projectInstance);
            } catch (UserException ex) {
                LoggingService.LogError("MSBuild project could not be evaluated", ex);
                throw;
            } catch (Exception ex) {
                // If the project can't be evaluated don't crash
                LoggingService.LogError("MSBuild project could not be evaluated", ex);
                throw new ProjectEvaluationException(msproject, ex.Message);
            } finally {
                if (oldProjectInstance != null)
                {
                    engine.DisposeProjectInstance(oldProjectInstance);
                }
            }
        }
		public void Evaluate ()
		{
			if (projectInstance != null)
				engine.DisposeProjectInstance (projectInstance);

			info = msproject.LoadNativeInstance ();

			engine = info.Engine;
			projectInstance = engine.CreateProjectInstance (info.Project);

			try {
				foreach (var prop in globalProperties)
					engine.SetGlobalProperty (projectInstance, prop.Key, prop.Value);

				engine.Evaluate (projectInstance);

				SyncBuildProject (info.ItemMap, info.Engine, projectInstance);
			} catch (Exception ex) {
				// If the project can't be evaluated don't crash
				LoggingService.LogError ("MSBuild project could not be evaluated", ex);
				throw new ProjectEvaluationException (msproject, ex.Message);
			}
		}