Пример #1
0
        /// <summary>
        /// The entry point
        /// </summary>
        private static void Main(string[] args)
        {
            try
            {
                Log.clear();

                // We parse the config file and the command-line...
                MakeItSoConfig config = MakeItSoConfig.Instance;
                config.initialize(args);
                if (config.ConvertSolution == false)
                {
                    // Most likely because of a bad command-line, or /help reques t...
                    return;
                }

                // We get the name of the .sln file to parse...
                string solutionFilename = config.SolutionFile;
                if (solutionFilename == "")
                {
                    Log.log("No solution file found.");
                    return;
                }

                // We find the Visual Studio version, and create a parser for it...
                Log.log("Parsing " + solutionFilename);
                int version = getSolutionVersion(solutionFilename);
                SolutionParserBase parser = null;
                switch (version)
                {
                case 10:        // VS2008
                    parser = loadParser("SolutionParser_VS2008.dll");
                    break;

                case 11:        // VS2010
                    parser = loadParser("SolutionParser_VS2010.dll");
                    break;

                default:
                    throw new Exception("MakeItSo does not support this version of Visual Studio");
                }
                parser.parse(solutionFilename);
                Log.log("Parsing succeeded.");

                // We make any changes to the project that are specified in
                // the MakeItSo.config file...
                parser.updateSolutionFromConfig();

                // We create the makefile...
                Log.log("Creating makefile...");
                MakefileBuilder.createMakefile(parser.ParsedSolution);
                Log.log("Creating makefile succeeded.");
            }
            catch (Exception ex)
            {
                Log.log("Fatal error: " + ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// We load the parser dynamically.
        /// </summary><remarks>
        /// We do this so that we don't hold references to the parsing libraries
        /// in this project. They use incompatible versions of the same EnvDTE
        /// assemblies, and this causes conflicts that are hard to resolve using
        /// the app.config. So instead we don't reference them, but load them
        /// dynamically instead.
        /// </remarks>
        private static SolutionParserBase loadParser(string assemblyName)
        {
            // We load the assembly from the same folder as this executable...
            string   assemblyPath = AppDomain.CurrentDomain.BaseDirectory + assemblyName;
            Assembly assembly     = Assembly.LoadFrom(assemblyPath);

            // We find the class in it derived from SolutionParserBase...
            SolutionParserBase parser = null;

            foreach (Type type in assembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(SolutionParserBase)) == true)
                {
                    // We've found the solution-parser type, so we create
                    // one and return it...
                    parser = Activator.CreateInstance(type) as SolutionParserBase;
                    break;
                }
            }

            return(parser);
        }