Beispiel #1
0
        private static void WriteMetaData(VSSolution solution)
        {
            string metaUrl = Path.Combine(solution.metaFolderUrl, "solutions.meta");

            NjoxNode metaRoot = new NjoxNode("meta");
            NjoxNode cache    = new NjoxNode("cached_guids");

            foreach (var pair in cachedGuids)
            {
                cache.AddChild(new NjoxNode(pair.Key.Replace(" ", "_%20_"), pair.Value.ToString()));
            }

            metaRoot.AddChild(cache);
            NjoxStatics.TryWriteObjectToFile(metaUrl, metaRoot);
        }
Beispiel #2
0
        public static bool WriteAllDetails(VSSolution solution, VSFullConfiguration[] fullConfigurations)
        {
            LoadMetaData(solution);

            // Write all projects to files
            foreach (var project in solution.projects.Values)
            {
                if (!VSProjectIO.WriteToFile(project, fullConfigurations))
                {
                    return(false);
                }
            }

            // Write solution to file
            bool result = WriteToFile(solution, fullConfigurations);

            WriteMetaData(solution);
            return(result);
        }
Beispiel #3
0
        private static void LoadMetaData(VSSolution solution)
        {
            string metaUrl = Path.Combine(solution.metaFolderUrl, "solutions.meta");

            cachedGuids = new Dictionary <string, Guid>();

            NjoxNode metaRoot;

            if (NjoxStatics.TryReadObjectFromFile(metaUrl, out metaRoot))
            {
                NjoxNode cachedGuidNode;
                if (metaRoot.TryGetFirstChild("cached_guids", out cachedGuidNode))
                {
                    foreach (NjoxNode node in cachedGuidNode.ChildNodes)
                    {
                        Guid guid;
                        if (Guid.TryParse(node.PrimaryProperty.Value, out guid))
                        {
                            cachedGuids[node.PrimaryProperty.Key.Replace("_%20_", " ")] = guid;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public static bool WriteToFile(VSSolution solution, VSFullConfiguration[] fullConfigurations)
        {
            Directory.CreateDirectory(solution.folderUrl);

            using (FileStream fileStream = new FileStream(solution.fileUrl, FileMode.Create))
                using (StreamWriter writer = new StreamWriter(fileStream))
                {
                    writer.WriteLine("Microsoft Visual Studio Solution File, Format Version 12.00");
                    writer.WriteLine("# Visual Studio 14");
                    writer.WriteLine("VisualStudioVersion = 14.0.25420.1");
                    writer.WriteLine("MinimumVisualStudioVersion = 10.0.40219.1");

                    // List folders
                    foreach (var collection in solution.collections)
                    {
                        Guid guid;
                        if (cachedGuids.ContainsKey(collection.displayName))
                        {
                            guid = cachedGuids[collection.displayName];
                        }
                        else
                        {
                            guid = Guid.NewGuid();
                            cachedGuids[collection.displayName] = guid;
                        }

                        writer.WriteLine("Project(\"{" + folderProjId + "}\") = \"" + collection.displayName + "\", \"" + collection.displayName + "\", \"{" + guid.ToString().ToUpper() + "}\"");
                        writer.WriteLine("EndProject");
                    }

                    // List projects
                    foreach (var pair in solution.projects)
                    {
                        writer.WriteLine("Project(\"{" + cppProjId + "}\") = \"" + pair.Value.module.displayName + "\", \"" + pair.Value.projectUrl + "\", \"{" + pair.Key.ToString().ToUpper() + "}\"");

                        // TODO - Dependencies

                        writer.WriteLine("EndProject");
                    }


                    writer.WriteLine("Global");


                    // Solution Configurations
                    writer.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
                    foreach (var configuration in fullConfigurations)
                    {
                        string configName = configuration.configName + "|" + configuration.platform.name;
                        writer.WriteLine("\t\t" + configName + " = " + configName);
                    }
                    writer.WriteLine("\tEndGlobalSection");


                    // Project Configurations
                    writer.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");

                    foreach (var pair in solution.projects)
                    {
                        foreach (var configuration in fullConfigurations)
                        {
                            string configName = configuration.configName + "|" + configuration.platform.name;
                            writer.WriteLine("\t\t{" + pair.Key.ToString().ToUpper() + "}." + configName + ".ActiveCfg = " + configuration.configName + "|" + configuration.platform.platform);
                            writer.WriteLine("\t\t{" + pair.Key.ToString().ToUpper() + "}." + configName + ".Build.0 = " + configuration.configName + "|" + configuration.platform.platform);
                        }
                    }
                    writer.WriteLine("\tEndGlobalSection");


                    // Solution properties
                    writer.WriteLine("\tGlobalSection(SolutionProperties) = preSolution");
                    writer.WriteLine("\t\tHideSolutionNode = FALSE");
                    writer.WriteLine("\tEndGlobalSection");


                    // Put projects in folders
                    writer.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
                    foreach (var collection in solution.collections)
                    {
                        foreach (var module in collection.modules.Values)
                        {
                            writer.WriteLine("\t\t{" + module.guid.ToString().ToUpper() + "} = {" + cachedGuids[collection.displayName].ToString().ToUpper() + "}");
                        }
                    }
                    writer.WriteLine("\tEndGlobalSection");


                    writer.WriteLine("EndGlobal");



                    writer.Flush();
                    writer.Close();
                }

            return(true);
        }