Project ConfigureProject(string file, string configuration, string platform) { var p = engine.GetLoadedProjects(file).FirstOrDefault(); if (p == null) { var content = buildEngine.GetUnsavedProjectContent(file); if (content == null) { p = engine.LoadProject(file); } else { p = engine.LoadProject(new XmlTextReader(new StringReader(content))); p.FullPath = file; } } p.SetProperty("Configuration", configuration); if (!string.IsNullOrEmpty(platform)) { p.SetProperty("Platform", platform); } else { p.SetProperty("Platform", ""); } return(p); }
Project ConfigureProject(string file, string configuration, string platform, string slnConfigContents) { var p = engine.GetLoadedProjects(file).FirstOrDefault(); if (p == null) { var content = buildEngine.GetUnsavedProjectContent(file); if (content == null) { p = engine.LoadProject(file); } else { Environment.CurrentDirectory = Path.GetDirectoryName(file); p = engine.LoadProject(new XmlTextReader(new StringReader(content))); p.FullPath = file; } } p.SetProperty("CurrentSolutionConfigurationContents", slnConfigContents); p.SetProperty("Configuration", configuration); if (!string.IsNullOrEmpty(platform)) { p.SetProperty("Platform", platform); } else { p.SetProperty("Platform", ""); } return(p); }
Project SetupProject(ProjectConfigurationInfo[] configurations) { Project project = null; foreach (var pc in configurations) { var p = engine.GetLoadedProject(pc.ProjectFile); if (p == null) { p = new Project(engine); var content = buildEngine.GetUnsavedProjectContent(pc.ProjectFile); if (content == null) { p.Load(pc.ProjectFile); } else { p.FullFileName = pc.ProjectFile; if (HasXbuildFileBug()) { // Workaround for Xamarin bug #14295: Project.Load incorrectly resets the FullFileName property var t = p.GetType(); t.InvokeMember("PushThisFileProperty", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { p.FullFileName }); t.InvokeMember("DoLoad", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { new StringReader(content) }); } else { p.Load(new StringReader(content)); } } } if (!string.IsNullOrEmpty(solutionFile)) { p.GlobalProperties.SetProperty("SolutionPath", Path.GetFullPath(solutionFile)); p.GlobalProperties.SetProperty("SolutionName", Path.GetFileNameWithoutExtension(solutionFile)); p.GlobalProperties.SetProperty("SolutionFilename", Path.GetFileName(solutionFile)); p.GlobalProperties.SetProperty("SolutionDir", Path.GetDirectoryName(solutionFile) + Path.DirectorySeparatorChar); } ; p.GlobalProperties.SetProperty("Configuration", pc.Configuration); if (!string.IsNullOrEmpty(pc.Platform)) { p.GlobalProperties.SetProperty("Platform", pc.Platform); } else { p.GlobalProperties.RemoveProperty("Platform"); } if (pc.ProjectFile == file) { project = p; } } Environment.CurrentDirectory = Path.GetDirectoryName(file); return(project); }
Project ConfigureProject(string file, string configuration, string platform) { var p = engine.GetLoadedProjects(file).FirstOrDefault(); if (p == null) { var content = buildEngine.GetUnsavedProjectContent(file); if (content == null) { p = engine.LoadProject(file); } else { p = engine.LoadProject(new XmlTextReader(new StringReader(content))); p.FullPath = file; } if (!string.IsNullOrEmpty(solutionFile)) { p.SetProperty("SolutionPath", Path.GetFullPath(solutionFile)); p.SetProperty("SolutionName", Path.GetFileNameWithoutExtension(solutionFile)); p.SetProperty("SolutionFilename", Path.GetFileName(solutionFile)); p.SetProperty("SolutionDir", Path.GetDirectoryName(solutionFile) + Path.DirectorySeparatorChar); } ; } p.SetProperty("Configuration", configuration); if (!string.IsNullOrEmpty(platform)) { p.SetProperty("Platform", platform); } else { p.SetProperty("Platform", ""); } return(p); }
Project SetupProject(ProjectConfigurationInfo[] configurations) { Project project = null; foreach (var pc in configurations) { var p = buildEngine.Engine.GetLoadedProject(pc.ProjectFile); if (p != null && pc.ProjectFile == file) { // building the project may create new items and/or modify some properties, // so we always need to use a new instance of the project when building buildEngine.Engine.UnloadProject(p); p = null; } Environment.CurrentDirectory = Path.GetDirectoryName(file); if (p == null) { p = new Project(buildEngine.Engine); var content = buildEngine.GetUnsavedProjectContent(pc.ProjectFile); if (content == null) { p.Load(pc.ProjectFile); } else { p.FullFileName = pc.ProjectFile; if (HasXbuildFileBug()) { // Workaround for Xamarin bug #14295: Project.Load incorrectly resets the FullFileName property var t = p.GetType(); t.InvokeMember("PushThisFileProperty", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { p.FullFileName }); t.InvokeMember("DoLoad", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { new StringReader(content) }); } else { p.Load(new StringReader(content)); } } } p.GlobalProperties.SetProperty("Configuration", pc.Configuration); if (!string.IsNullOrEmpty(pc.Platform)) { p.GlobalProperties.SetProperty("Platform", pc.Platform); } else { p.GlobalProperties.RemoveProperty("Platform"); } if (pc.ProjectFile == file) { project = p; } } Environment.CurrentDirectory = Path.GetDirectoryName(file); return(project); }