Exemplo n.º 1
0
        internal void GenerateLibraryProjectFile(CodeGeneratorOptions options, IEnumerable <string> enumFiles, string path = null)
        {
            if (path == null)
            {
                var name = Assembly ?? "GeneratedFiles";
                int idx  = name.IndexOf(',');
                name = idx < 0 ? name : name.Substring(0, idx);
                path = Path.Combine(csdir, name + ".projitems");
            }

            var msbuild = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
            var compile = msbuild + "Compile";
            var project = new XElement(
                msbuild + "Project",
                ToDefineConstants(options, msbuild),
                new XComment(" Classes "),
                new XElement(
                    msbuild + "ItemGroup",
                    GeneratedFiles
                    .OrderBy(f => f, StringComparer.OrdinalIgnoreCase)
                    .Select(f => ToCompileElement(compile, f))),
                new XComment(" Enums "),
                new XElement(
                    msbuild + "ItemGroup",
                    enumFiles
                    ?.OrderBy(f => f, StringComparer.OrdinalIgnoreCase)
                    ?.Select(f => ToCompileElement(compile, f))));

            project.Save(path);
        }