public void regenerateMakefile()
        {
            var names            = typeof(ArduinoProjectHelper).Assembly.GetManifestResourceNames();
            var streamOfTemplate = typeof(ArduinoProjectHelper).Assembly.GetManifestResourceStream(ManifestPrefix + "." + kManifestStringName);

            if (streamOfTemplate == null || streamOfTemplate.Length == 0)
            {
                throw new Exception("Expecting template in resources");
            }

            ArduinoBoardInfo currentVariant = ArduinoVariantInfo;

            using (StreamWriter newMakeFile = new StreamWriter(_pathToMakeFile, false))
            {
                // squirt out the basics
                newMakeFile.WriteLine("ARDUINO_INSTALL=" + ArduinoPathHelper.ArduinoPathShort);
                newMakeFile.WriteLine("ARDUINO_FIRMWARE=" + ArduinoPathHelper.ArduinoFirmwarePathShort);
                newMakeFile.WriteLine("ARDUINO_TOOLS=" + ArduinoPathHelper.ArduinoToolsPathShort);
                newMakeFile.WriteLine("VARIANT_PATH=" + ArduinoPathHelper.GetArduinoVariantPathShort(ArduinoVariant));

                // Write out CPP & c files
                var cppFiles = getArduinoFiles("*.cpp");
                var cFiles   = getArduinoFiles("*.c");

                // Find libraries
                var libraries = extractLibrariesFromIno();

                foreach (var lib in libraries)
                {
                    foreach (var cppFile in lib.CPPSourceFiles)
                    {
                        cppFiles.Add(cppFile);
                    }

                    foreach (var cFile in lib.CSourceFiles)
                    {
                        cFiles.Add(cFile);
                    }

                    newMakeFile.WriteLine("CFLAGS= $(CFLAGS) -I " + ArduinoPathHelper.GetShortPath(lib.headerPath));
                    newMakeFile.WriteLine("CXXFLAGS= $(CXXFLAGS) -I " + ArduinoPathHelper.GetShortPath(lib.headerPath));
                }

                newMakeFile.Write("CXXSRC=");
                foreach (var cppFile in cppFiles)
                {
                    newMakeFile.WriteLine("\t\\");
                    newMakeFile.Write(string.Format("\t{0}", ArduinoPathHelper.GetShortPath(cppFile)));
                }
                newMakeFile.WriteLine("");

                newMakeFile.Write("CSRC=");

                foreach (var cFile in cFiles)
                {
                    newMakeFile.WriteLine("\t\\");
                    newMakeFile.Write(string.Format("\t{0}", ArduinoPathHelper.GetShortPath(cFile)));
                }
                newMakeFile.WriteLine("");

                if (_pathToIno != null)
                {
                    newMakeFile.Write("INOSRC=\\");
                    newMakeFile.Write(string.Format("\t{0}", ArduinoPathHelper.GetShortPath(_pathToIno)));

                    newMakeFile.WriteLine("");
                }

                // Write out OBJs

                newMakeFile.Write("OBJ=");
                foreach (var cppFile in cppFiles)
                {
                    var objName = Path.GetFileNameWithoutExtension(cppFile) + ".obj";
                    newMakeFile.WriteLine("\t\\");
                    newMakeFile.Write(string.Format("\t$(O)\\{0}", objName));
                }
                foreach (var cFile in cFiles)
                {
                    var objName = Path.GetFileNameWithoutExtension(cFile) + ".obj";

                    newMakeFile.WriteLine("\t\\");
                    newMakeFile.Write(string.Format("\t$(O)\\{0}", objName));
                }

                if (_pathToIno != null)
                {
                    var objName = Path.GetFileNameWithoutExtension(_pathToIno) + ".obj";

                    newMakeFile.WriteLine("\t\\");
                    newMakeFile.Write(string.Format("\t$(O)\\{0}", objName));
                }

                newMakeFile.WriteLine("");
                newMakeFile.WriteLine("");

                newMakeFile.WriteLine(string.Format("TARGET={0}", Target));
                newMakeFile.WriteLine(string.Format("O={0}", Intermediate));
                newMakeFile.WriteLine("");
                newMakeFile.WriteLine(string.Format("MCU={0}", currentVariant.MCU));
                newMakeFile.WriteLine(string.Format("F_CPU={0}", currentVariant.F_CPU));
                newMakeFile.WriteLine(string.Format("VARIANT={0}", currentVariant.VARIANT));
                newMakeFile.WriteLine(string.Format("DEF_CPU={0}", currentVariant.DEF_CPU));
                newMakeFile.WriteLine(string.Format("D_USB_VID=USB_VID={0}", currentVariant.USB_VID));
                newMakeFile.WriteLine(string.Format("D_USB_PID=USB_PID={0}", currentVariant.USB_PID));
                newMakeFile.WriteLine("");


                using (StreamReader templateReader = new StreamReader(streamOfTemplate))
                {
                    while (!templateReader.EndOfStream)
                    {
                        string readLine = templateReader.ReadLine();
                        newMakeFile.WriteLine(readLine);
                    }
                }
            }
        }
        public Dictionary <string, ArduinoBoardInfo> getBoardInfo()
        {
            var dict = new Dictionary <string, ArduinoBoardInfo>();

            ArduinoBoardInfo currentBoard = new ArduinoBoardInfo();

            using (StreamReader boardTextFile = new StreamReader(ArduinoPathHelper.ArduinoBoardPath, false))
            {
                while (!boardTextFile.EndOfStream)
                {
                    string line = boardTextFile.ReadLine();
                    if (!string.IsNullOrEmpty(line))
                    {
                        if (line.Contains(".name="))
                        {
                            string[] processed = line.Split('.', '=');

                            if (currentBoard.VARIANT != null)
                            {
                                dict.Add(currentBoard.VARIANT.ToLower(), currentBoard);
                            }

                            currentBoard              = new ArduinoBoardInfo();
                            currentBoard.VARIANT      = processed[0];
                            currentBoard.FriendlyName = processed[processed.Length - 1];
                        }
                        else
                        {
                            string[] kvp = line.Split('=');
                            if (kvp.Length > 1)
                            {
                                if (line.Contains("mcu"))
                                {
                                    currentBoard.MCU = kvp[kvp.Length - 1];
                                }
                                else if (line.Contains("build.f_cpu"))
                                {
                                    currentBoard.F_CPU = kvp[kvp.Length - 1];
                                }
                                else if (line.Contains("build.board"))
                                {
                                    currentBoard.DEF_CPU = kvp[kvp.Length - 1];
                                }
                                else if (line.Contains("build.vid"))
                                {
                                    currentBoard.USB_VID = kvp[kvp.Length - 1];
                                }
                                else if (line.Contains("build.pid"))
                                {
                                    currentBoard.USB_PID = kvp[kvp.Length - 1];
                                }
                            }
                        }
                    }
                }
            }

            if (!dict.ContainsKey(currentBoard.VARIANT.ToLower()))
            {
                dict.Add(currentBoard.VARIANT.ToLower(), currentBoard);
            }

            return(dict);
        }