internal MSBuildProjectInstanceInfo LoadNativeInstance()
        {
            lock (readLock) {
                var supportsMSBuild = UseMSBuildEngine && GetGlobalPropertyGroup().GetValue("UseMSBuildEngine", true);

                if (engineManager == null)
                {
                    engineManager        = new MSBuildEngineManager();
                    engineManagerIsLocal = true;
                }

                MSBuildEngine e = engineManager.GetEngine(supportsMSBuild);

                if (nativeProjectInfo != null && nativeProjectInfo.Engine != null && (nativeProjectInfo.Engine != e || nativeProjectInfo.ProjectStamp != ChangeStamp))
                {
                    nativeProjectInfo.Engine.UnloadProject(nativeProjectInfo.Project);
                    nativeProjectInfo = null;
                }

                if (nativeProjectInfo == null)
                {
                    nativeProjectInfo = new MSBuildProjectInstanceInfo {
                        Engine       = e,
                        ProjectStamp = ChangeStamp
                    };
                }

                if (nativeProjectInfo.Project == null)
                {
                    // Use a private metadata property to assign an id to each item. This id is used to match
                    // evaluated items with the items that generated them.

                    try {
                        DisableChangeTracking();

                        var ctx = new WriteContext {
                            Evaluating = true,
                            ItemMap    = new Dictionary <string, MSBuildItem> ()
                        };
                        var xml = SaveToString(ctx);

                        foreach (var it in GetAllItems())
                        {
                            it.EvaluatedItemCount = 0;
                        }

                        nativeProjectInfo.Project = e.LoadProject(this, xml, FileName);
                    } 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(this, ex.Message);
                    } finally {
                        EnableChangeTracking();
                    }
                }
                return(nativeProjectInfo);
            }
        }
Beispiel #2
0
 protected MSBuildEngine(MSBuildEngineManager manager)
 {
     EngineManager = manager;
 }
Beispiel #3
0
 internal MSBuildProject(MSBuildEngineManager manager) : this()
 {
     engineManager = manager;
 }
Beispiel #4
0
		protected MSBuildEngine (MSBuildEngineManager manager)
		{
			EngineManager = manager;
		}
Beispiel #5
0
 public MSBuildEngineV12(MSBuildEngineManager manager) : base(manager)
 {
     projects = new ProjectCollection();
 }
Beispiel #6
0
		public MSBuildEngineV4 (MSBuildEngineManager manager): base (manager)
		{
			engine = new Engine ();
		}
Beispiel #7
0
 public DefaultMSBuildEngine(MSBuildEngineManager manager) : base(manager)
 {
 }
		internal MSBuildProjectInstanceInfo LoadNativeInstance ()
		{
			lock (readLock) {
				var supportsMSBuild = UseMSBuildEngine && GetGlobalPropertyGroup ().GetValue ("UseMSBuildEngine", true);

				if (engineManager == null) {
					engineManager = new MSBuildEngineManager ();
					engineManagerIsLocal = true;
				}

				MSBuildEngine e = engineManager.GetEngine (supportsMSBuild);

				if (nativeProjectInfo != null && nativeProjectInfo.Engine != null && (nativeProjectInfo.Engine != e || nativeProjectInfo.ProjectStamp != ChangeStamp)) {
					nativeProjectInfo.Engine.UnloadProject (nativeProjectInfo.Project);
					nativeProjectInfo = null;
				}

				if (nativeProjectInfo == null) {
					nativeProjectInfo = new MSBuildProjectInstanceInfo {
						Engine = e,
						ProjectStamp = ChangeStamp
					};
				}

				if (nativeProjectInfo.Project == null) {
					// Use a private metadata property to assign an id to each item. This id is used to match
					// evaluated items with the items that generated them.

					try {
						DisableChangeTracking ();

						var ctx = new WriteContext {
							Evaluating = true,
							ItemMap = new Dictionary<string, MSBuildItem> ()
						};
						var xml = SaveToString (ctx);

						foreach (var it in GetAllItems ())
							it.EvaluatedItemCount = 0;

						nativeProjectInfo.Project = e.LoadProject (this, xml, FileName);
					} 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 (this, ex.Message);
					} finally {
						EnableChangeTracking ();
					}
				}
				return nativeProjectInfo;
			}
		}
		internal MSBuildProject (MSBuildEngineManager manager) : this ()
		{
			engineManager = manager;
		}
		public DefaultMSBuildEngine (MSBuildEngineManager manager): base (manager)
		{
		}
Beispiel #11
0
 public MSBuildEngineV4(MSBuildEngineManager manager) : base(manager)
 {
     engine = new Engine();
 }
		public MSBuildEngineV12 (MSBuildEngineManager manager): base (manager)
		{
			projects = new ProjectCollection ();
		}