Пример #1
0
        IEnumerable <ProjectElement> Import(ProjectImportElement import)
        {
            string dir = projects.GetEvaluationTimeThisFileDirectory(() => FullPath);
            // FIXME: use appropriate logger (but cannot be instantiated here...?)
            string path = ProjectCollection.FindFileInSeveralExtensionsPath(ref extensions_path_override, ExpandString, import.Project, TextWriter.Null.WriteLine);

            path = Path.IsPathRooted(path) ? path : dir != null?Path.Combine(dir, path) : Path.GetFullPath(path);

            if (projects.OngoingImports.Contains(path))
            {
                throw new InvalidProjectFileException(import.Location, null, string.Format("Circular imports was detected: {0} is already on \"importing\" stack", path));
            }
            projects.OngoingImports.Push(path);
            try {
                using (var reader = XmlReader.Create(path)) {
                    var root = ProjectRootElement.Create(reader, projects);
                    raw_imports.Add(new ResolvedImport(import, root, true));
                    return(this.EvaluatePropertiesAndUsingTasksAndImportsAndChooses(root.Children).ToArray());
                }
            } finally {
                projects.OngoingImports.Pop();
            }
        }