Program.cs 30.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
๏ปฟusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.VCProjectEngine;
using System.Threading;
using System.Text.RegularExpressions;

namespace Convert_vc6TOvc9_cmd
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            string oTxt = "";
            string rCOM = "";
            string rNET = "";
            string build = "";
            string assembly ="";
            string comEXE = "";
            string netEXE ="";
            //string argsStr = String.Join(" ", args);
            string tipocompilazione = "0"; //solo .NET
            //string tipocompilazione = "1"; //solo .COM
            //string tipocompilazione = "2"; //.COM e .NET
            if (args.Length > 1)
                tipocompilazione = args[1];
            string[] sep = { "," };
            string[] prjConv = args[0].Split(sep, StringSplitOptions.None);

            for (int i = 0; i < prjConv.Length; i++)
            {
                string[] pathEXE = prjConv[i].Split(@"\".ToCharArray());
                //creo folder e copio sorgenti
                //manageFolder(build + prjConv[i], assembly + prjConv[i], true);
                //prjConv[i] = assembly + prjConv[i];
                switch (tipocompilazione)
                {
                    case "0":
                        netEXE=@""+prjConv[i]+"\\NET";
                        if (!System.IO.Directory.Exists(netEXE))
                        {
                            System.IO.Directory.CreateDirectory(netEXE);
                            Console.WriteLine("creato il path "+netEXE);
                        }
                        rNET = netCompile(prjConv[i], netEXE);
                        break;
                    case "1":
                        comEXE=@""+prjConv[i]+"\\COM";
                        if (!System.IO.Directory.Exists(comEXE))
                        {
                            System.IO.Directory.CreateDirectory(comEXE);
                            Console.WriteLine("creato il path "+comEXE);
                        }
                        rCOM = comCompile(prjConv[i], comEXE);
                        break;
                    case "2":
                         netEXE=@""+prjConv[i]+"\\NET";
                        if (!System.IO.Directory.Exists(netEXE))
                        {
                            System.IO.Directory.CreateDirectory(netEXE);
                            Console.WriteLine("creato il path "+netEXE);
                        }
                        comEXE=@""+prjConv[i]+"\\COM";
                        if (!System.IO.Directory.Exists(comEXE))
                        {
                            System.IO.Directory.CreateDirectory(comEXE);
                            Console.WriteLine("creato il path "+comEXE);
                        }
                        rNET = netCompile(prjConv[i],netEXE );
                        Console.WriteLine("");
                        Console.WriteLine("");
                        Console.WriteLine("");
                        Console.WriteLine("");
                        rCOM = comCompile(prjConv[i], comEXE);
                        break;
                }
                /*
                try
                {
                    manageFolder("", prjConv[i], false);
                }
                catch {
                    //azzo
                }
                */
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("###############################################");
                if (rNET.Length > 0)
                {
                    Console.WriteLine("NET compile: " + rNET);
                }
                if (rCOM.Length > 0)
                {
                    Console.WriteLine("COM compile: " + rCOM);
                }
                Console.WriteLine("###############################################");
            }

        }

        static void CopyDirectory(DirectoryInfo source, DirectoryInfo destination)
        {
            try
            {
                if (!destination.Exists)
                {
                    destination.Create();
                }

                // Copy all files. 
                FileInfo[] files = source.GetFiles();
                foreach (FileInfo file in files)
                {
                    file.IsReadOnly = false;
                    file.CopyTo(Path.Combine(destination.FullName,
                        file.Name), true);
                }

                // Process subdirectories. 
                DirectoryInfo[] dirs = source.GetDirectories();
                foreach (DirectoryInfo dir in dirs)
                {
                    // Get destination directory. 
                    string destinationDir = Path.Combine(destination.FullName, dir.Name);

                    // Call CopyDirectory() recursively. 
                    CopyDirectory(dir, new DirectoryInfo(destinationDir));
                }
            }
            catch (Exception e)
            {
                throw new Exception("ERRORE CopyDirectory : [" + e + "]");
                Environment.Exit(6);
            }
        }

        static void manageFolder(string pathOrig, string path, bool create)
        {
            
            try
            {
                if (create)
                {
                    Console.WriteLine("Copy folder: [" + pathOrig + "] to [" + path + "]");
                    DirectoryInfo sourceDir = new DirectoryInfo(pathOrig);
                    DirectoryInfo targetDir = new DirectoryInfo(path);
                    CopyDirectory(sourceDir, targetDir);
                }
                else
                {
                    //Thread.Sleep(10000);
                    Console.WriteLine("Delete folder: [" + path + "]");
                    
                    /*
                    if (System.IO.Directory.Exists(path))
                        System.IO.Directory.Delete(path, true);
                    */
                    Console.WriteLine("Folder exist: [" + System.IO.Directory.Exists(path).ToString() + "]");
                }
            }
            catch (Exception e)
            {
                Environment.Exit(7);
            }
        
        }

        static string comCompile(string path, string pathExe)
        {
            bool okCompile = false;
            string retRegExp = null;
            Regex RegexObj = null;
            int mR = 0;
            try
            {
                Console.WriteLine("Start make COM [" + path + "]...");
                DirectoryInfo diIn = new DirectoryInfo(path);
                FileInfo[] dspFile = diIn.GetFiles("*.dsp");
                string dll = dspFile[0].Name.Replace(".dsp", ".dll");
                string s = "";
                string ee = "";
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                string strRun = @"/rebuild """ + path +@"\"+ dspFile[0].Name + @""" /MAKE ""all - Win32 Test Release""";
                Console.WriteLine("Parametri make [" + strRun + "]");
                //proc.StartInfo.FileName = @"C:\Program Files\Microsoft Visual Studio\COMMON\MSDev98\Bin\msdev.exe";
                proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Visual Studio\COMMON\MSDev98\Bin\msdev.exe";

                //proc.StartInfo.FileName = @"C:\program files\MSDev98\Bin\msdev.exe";
                Console.WriteLine("Parametri make exe [" + proc.StartInfo.FileName + "]");
                proc.StartInfo.Arguments = strRun;
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.CreateNoWindow = true;
                proc.StartInfo.RedirectStandardInput = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError = true;
                Console.WriteLine("Start make [" + path + "]");
                proc.Start();
                s = proc.StandardOutput.ReadToEnd();
                ee = proc.StandardError.ReadToEnd();
                proc.WaitForExit();
                Console.WriteLine("End make [" + path + "]");
                if (ee.Length > 0)
                {
                    Console.WriteLine("ERRORE: [" + ee + "]");
                    Environment.Exit(4);
                    return "ERRORE: [" + ee + "]";
                }
                else
                {
                    Console.WriteLine(s);
                    try
                    {
                        string r = "";
                        RegexObj = new Regex(".+error\\(s\\).+");
                        retRegExp = RegexObj.Match(s).Value;
                        Console.WriteLine("Make result [" + retRegExp + "]");
                        //RegexObj = new Regex("[0-9]+");
						//analisi dei log per le dll che nel nome contengono un numero (es:P2P)
						RegexObj = new Regex("\\s[0-9]+");
                        Match MatchResults = RegexObj.Match(retRegExp);
                        while (MatchResults.Success)
                        {
                            if (mR == 0)
                            {
                                //Errori
                                if (Convert.ToInt32(MatchResults.Value) != 0)
                                {
                                    Console.WriteLine("ERRORE Make: [vedi log per dettagli]");
                                    r = "ERRORE Make: [vedi log per dettagli]";
                                }
                                else
                                {
                                    Console.WriteLine("Make result Ok!");
                                    okCompile = true;
                                    r = "Make result Ok!";
                                    try
                                    {
                                        //copy dll
                                        Console.WriteLine("Copy to: [" + pathExe + dll + "]");
                                        FileInfo fi = new FileInfo(@"T:\dll\" + dll);
                                        fi.CopyTo(pathExe + @"\" + dll, true);
                                        Console.WriteLine("Copy to: [" + pathExe + dll + "] ok...");
                                    }
                                    catch (Exception e)
                                    {
                                        okCompile = false;
                                        Console.WriteLine("ERRORE copy postMake [" + e.Message + "]");
                                        r = "ERRORE copy postMake [" + e.Message + "]";
                                        Environment.Exit(5);
                                    }
                                }
                            }
                            else
                            {
                                //Warning
                            }
                            MatchResults = MatchResults.NextMatch();
                            mR = mR + 1;
                        }
                        return r;
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine("ERRORE Match result: [" + ee + "]");
                        Environment.Exit(4);
                        return "ERRORE Match result: [" + ee + "]";
                    }
                }
                proc.Close();
                //return okCompile;
            }
            catch (Exception err)
            {
                Console.WriteLine("ERRORE make [" + err.Message + "]");
                Environment.Exit(4);
                return "ERRORE make [" + err.Message + "]";
            }
        }

        static string netCompile(string prg,string pathExe)
        {
            Console.WriteLine("Start netCompile: [" + prg + "]");
            string sExecute = "";
            DirectoryInfo diIn = new DirectoryInfo(prg);
            FileInfo[] dspFile = diIn.GetFiles("*.dsp");
            FileInfo[] VcprojFile = diIn.GetFiles("*.vcproj");
            if (VcprojFile.Length == 0)
            {
                Console.WriteLine("start execute");
                sExecute = execute(prg + @"\" + dspFile[0].Name, dspFile[0].Name);
                Console.WriteLine("finish execute");
            }
            else
            {
                sExecute = "RUN";
            }
            Console.WriteLine("Convert: [" + sExecute.ToString() + "]");
            if (sExecute != "CATCH" && sExecute != "RUN")
            {
                Console.WriteLine("ReplaceVcproj: init");
                bool compile=replaceVcproj(diIn.FullName + @"\" + sExecute.Replace(".dsp", ""), sExecute.Replace(".dsp", ""));
                Console.WriteLine("ReplaceVcproj: step1 [" + compile.ToString() + "]");
                //Replace _L( in SOURCEFILE
                DirectoryInfo diIn2 = new DirectoryInfo(prg + "\\src");
                FileInfo[] coFile = diIn2.GetFiles("Co*.cpp");
                FileStream fs = File.Open(coFile[0].FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                StreamReader reader = new StreamReader(fs);
                string contentFile = reader.ReadToEnd();
                if (contentFile.IndexOf("_L(") > -1)
                {
                    Console.WriteLine("Replace _L");
                    contentFile = contentFile.Replace("_L(", "_T(");
                    reader.Close();
                    fs.Close();
                    FileInfo tw = new FileInfo(coFile[0].FullName);
                    StreamWriter texW = tw.CreateText();
                    texW.Write(contentFile);
                    texW.Close();
                }
                else
                {
                    reader.Close();
                    fs.Close();
                }
                Console.WriteLine("ReplaceVcproj: end");
                if (compile)
                {
                    responseMsg rp = compileVcproj(diIn.FullName + @"\" + sExecute.Replace(".dsp", ""), sExecute.Replace(".dsp", ""), pathExe);
                    return rp.message;
                }
                else
                {
                    Environment.Exit(2);
                    return "ERRORE: replace vcproj failed!";
                }
            }
            else
            {
                //traccio ko
                if (sExecute == "CATCH")
                {
                    Console.WriteLine("execute: ko");
                    Environment.Exit(2);
                    return "ERRORE: create vcproj failed!";
                }
                else
                {
                    Console.WriteLine("execute: ok, gia trovato");
                    responseMsg rp = compileVcproj(diIn.FullName + @"\" + VcprojFile[0].Name, VcprojFile[0].Name, pathExe);
                    return rp.message;
                }
            }        
        }

        static bool replaceVcproj(string path, string sExecute)
        {
            FileInfo fi = new FileInfo(path);
            StreamReader sw = fi.OpenText();
            string sLine;
            string tmp;
            string sLineAll = "";
            bool inizioAnalisi = false;
            string countTmp = "000000";
            bool ok = false;
            bool okFirstTime = true;
            string[] replaceStr = {@"Name=""Svil Debug|Win32", 
                                  @"ATLMinimizesCRunTimeLibraryUsage=""false",
                                  @"PreprocessorDefinitions=""WIN32;_DEBUG;_WINDOWS;_USRDLL",
                                  @"RuntimeLibrary=""0",
                                  @"AdditionalDependencies=""qtlbased.lib libcpmtd.lib atl.lib LIBCMTD.lib COMSUPP.lib xlibd.lib",
                                  @"IgnoreAllDefaultLibraries=""true",
                                  @"&#x0A;copy $(TargetPath)",
                                  @"AdditionalDependencies=""qtlbased.lib libcpmtd.lib atl.lib LIBCMTD.lib COMSUPP.lib",
                                  @"AdditionalDependencies=""Xlibd.lib qtlbased.lib libcpmtd.lib atl.lib LIBCMTD.lib COMSUPP.lib",
                                  @"AdditionalDependencies=""qtlbased.lib libcpmtd.lib atl.lib LIBCMTD.lib Xlibd.lib COMSUPP.lib"
                                  };
            string[] replaceStrCon = {"", 
                                  @"CharacterSet=""2""",
                                  @"PreprocessorDefinitions=""WIN32;_DEBUG;_WINDOWS;""",
                                  @"RuntimeLibrary=""3""",
                                  @"AdditionalDependencies=""qtlbased.lib xlibd.lib""",
                                  @"IgnoreAllDefaultLibraries=""false""",
                                  @"&#x0A;copy &quot;$(TargetPath)&quot;",
                                  @"AdditionalDependencies=""qtlbased.lib""",
                                  @"AdditionalDependencies=""qtlbased.lib xlibd.lib""",
                                  };
            string[] replaceStrCon2 = {"", 
                                  "",
                                  "",
                                  @"EnableFunctionLevelLinking=""false""",
                                  "",
                                  @"IgnoreDefaultLibraryNames=""msvcprtd.lib libcmtd.lib"""
                                  };
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("\t\t\t\t");
            while ((sLine = sw.ReadLine()) != null)
            {
                if (sLine.IndexOf(replaceStr[0]) > 0 && okFirstTime)
                {
                    inizioAnalisi = true;
                    countTmp = countTmp.Remove(0, 1);
                    countTmp = countTmp.Insert(0, "1");
                    okFirstTime = false;
                }
                if (inizioAnalisi)
                {
                    if (sLine.ToLower().IndexOf(replaceStr[1].ToLower()) > 0)
                    {
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[1], replaceStrCon[1]);
                        tmp = sb.ToString() + replaceStrCon[1];
                        sLineAll = sLineAll + tmp + "\r";
                        countTmp = countTmp.Remove(1, 1);
                        countTmp = countTmp.Insert(1, "1");
                    }
                    else if (sLine.ToLower().IndexOf(replaceStr[2].ToLower()) > 0)
                    {
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[2], replaceStrCon[2]);
                        tmp = sb.ToString() + replaceStrCon[2];
                        sLineAll = sLineAll + tmp + "\r";
                        countTmp = countTmp.Remove(2, 1);
                        countTmp = countTmp.Insert(2, "1");
                    }
                    else if (sLine.ToLower().IndexOf(replaceStr[3].ToLower()) > 0)
                    {
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[3], replaceStrCon[3]);
                        tmp = sb.ToString() + replaceStrCon[3];
                        sLineAll = sLineAll + tmp + "\r";
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[3], replaceStrCon2[3]);
                        tmp = sb.ToString() + replaceStrCon2[3];
                        sLineAll = sLineAll + tmp + "\r";
                        countTmp = countTmp.Remove(3, 1);
                        countTmp = countTmp.Insert(3, "1");
                    }
                    else if (sLine.ToLower().IndexOf(replaceStr[4].ToLower()) > 0 || sLine.ToLower().IndexOf(replaceStr[7].ToLower()) > 0 || sLine.ToLower().IndexOf(replaceStr[8].ToLower()) > 0 || sLine.ToLower().IndexOf(replaceStr[9].ToLower()) > 0)
                    {
                        int eccDovePrendo;
                        if (sLine.ToLower().IndexOf(replaceStr[4].ToLower()) > 0)
                        {
                            eccDovePrendo = 4;
                        }
                        else if (sLine.ToLower().IndexOf(replaceStr[7].ToLower()) > 0)
                        {
                            eccDovePrendo = 7;
                        }
                        else
                        {
                            eccDovePrendo = 8;
                        }
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[eccDovePrendo], replaceStrCon[eccDovePrendo]);
                        tmp = sb.ToString() + replaceStrCon[eccDovePrendo];
                        sLineAll = sLineAll + tmp + "\r";
                        countTmp = countTmp.Remove(4, 1);
                        countTmp = countTmp.Insert(4, "1");
                    }
                    else if (sLine.ToLower().IndexOf(replaceStr[5].ToLower()) > 0)
                    {
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[5], replaceStrCon[5]);
                        tmp = sb.ToString() + replaceStrCon[5];
                        sLineAll = sLineAll + tmp + "\r";
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[5], replaceStrCon2[5]);
                        tmp = sb.ToString() + replaceStrCon2[5];
                        sLineAll = sLineAll + tmp + "\r";
                        countTmp = countTmp.Remove(5, 1);
                        countTmp = countTmp.Insert(5, "1");
                    }
                    else if (sLine.ToLower().IndexOf(replaceStr[6].ToLower()) > 0)
                    {
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[6], replaceStrCon[6]);
                        //tmp = sb.ToString() + replaceStrCon[6];
                        sLineAll = sLineAll + tmp + "\r";
                    }
                    else if (sLine.IndexOf("</Configuration>") > 0)
                    {
                        sLineAll = sLineAll + sLine + "\r";
                        if (countTmp.IndexOf("0") >= 0)
                        {
                            //Manca qualche riferimento
                            inizioAnalisi = false;
                        }
                        else
                        {
                            //Tutto ok
                            ok = true;
                            inizioAnalisi = false;
                        }
                    }
                    else
                    {
                        if (sLine.IndexOf(replaceStr[6]) > 0)
                        {
                            tmp = sLine;
                            tmp = tmp.Replace(replaceStr[6], replaceStrCon[6]);
                            sLineAll = sLineAll + tmp + "\r";
                        }
                        else
                        {
                            sLineAll = sLineAll + sLine + "\r";
                        }
                    }
                }
                else
                {
                    if (sLine.IndexOf(replaceStr[6]) > 0)
                    {
                        tmp = sLine;
                        tmp = tmp.Replace(replaceStr[6], replaceStrCon[6]);
                        sLineAll = sLineAll + tmp + "\r";
                    }
                    else
                    {
                        sLineAll = sLineAll + sLine + "\r";
                    }
                }
            }
            sw.Close();
            if (ok)
            {
                StreamWriter swToFile = new StreamWriter(path);
                swToFile.Write(sLineAll);
                swToFile.Flush();
                swToFile.Close();
                return true;
            }
            else
            {
                return false;
            }
        }

        static string execute(string path, string nameDsp)
        {
            try
            {
                Console.WriteLine("Convert start: [" + nameDsp + "]");
                Microsoft.VisualStudio.VCProjectEngine.VCProjectEngineObject vcPengine = new VCProjectEngineObject();
                VCProject obj = vcPengine.LoadProject(path) as VCProject;
                obj.ProjectFile = nameDsp.Replace(".dsp", "") + ".vcproj";
                obj.Save();
                return nameDsp + ".vcproj";
            }
            catch (Exception ecc)
            {
                Console.WriteLine("Convert exception: [" + ecc.Message + "]");
                Environment.Exit(3);
                return "CATCH";

            }

        }

        static responseMsg compileVcproj(string path, string vcjproFile, string pathExe)
        {
            bool okCompile = false;
            string retRegExp = null;
            Regex RegexObj = null;
            int mR = 0;
            string dll = vcjproFile.Replace(".vcproj", ".dll");
            try
            {
                Console.WriteLine("Start make...");
                string s = "";
                string ee = "";
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                string strRun = @"/rebuild """ + path + @""" ""Prod Release""";
                Console.WriteLine("Parametri make [" + strRun + "]");
                //proc.StartInfo.FileName = @"""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages\VCBuild.exe""";
                proc.StartInfo.FileName = @"""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\VCBuild.exe""";

                Console.WriteLine("Parametri make exe [" + proc.StartInfo.FileName + "]");
                proc.StartInfo.Arguments = strRun;
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.CreateNoWindow = true;
                proc.StartInfo.RedirectStandardInput = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError = true;
                Console.WriteLine("Start make [" + path + "]");
                proc.Start();
                s = proc.StandardOutput.ReadToEnd();
                ee = proc.StandardError.ReadToEnd();
                proc.WaitForExit();
                Console.WriteLine("End make [" + path + "]");
                if (ee.Length > 0)
                {
                    Console.WriteLine("ERRORE: [" + ee + "]");
                    Environment.Exit(8);
                    return new responseMsg(true, "ERRORE Match result: [" + ee + "]");
                }
                else
                {
                    Console.WriteLine(s);
                    try
                    {
                        responseMsg rm=null;
                        RegexObj = new Regex(".+error\\(s\\).+");
                        retRegExp = RegexObj.Match(s).Value;
                        Console.WriteLine("Make result [" + retRegExp + "]");
                        //RegexObj = new Regex("[0-9]+");
						//analisi dei log per le dll che nel nome contengono un numero (es:P2P)
						RegexObj = new Regex("\\s[0-9]+");
                        Match MatchResults = RegexObj.Match(retRegExp);
                        while (MatchResults.Success)
                        {
                            if (mR == 0)
                            {
                                //Errori
                                if (Convert.ToInt32(MatchResults.Value) != 0)
                                {
                                    Console.WriteLine("ERRORE Make: [vedi log per dettagli]");
                                    Environment.Exit(8);
                                    rm = new responseMsg(true, "ERRORE Make: [vedi log per dettagli]");
                                }
                                else
                                {
                                    Console.WriteLine("Make result Ok!");
                                    okCompile = true;
                                    rm =new responseMsg(false, "Make result Ok!");
                                    try
                                    {

                                        //copy dll
                                        Console.WriteLine(@"Copy to: [P:\dll\" + dll + "]");
                                        FileInfo fi = new FileInfo(@"P:\dll\" + dll);
                                        fi.CopyTo(pathExe + @"\" + dll, true);
                                        Console.WriteLine("Copy to: [" + pathExe + dll + "] ok...");
                                    }
                                    catch (Exception e)
                                    {
                                        okCompile = false;
                                        Console.WriteLine("ERRORE make NET [" + e.Message + "]");
                                        rm = new responseMsg(true, "ERRORE copy postMakeNET result: [" + e + " vedi log per dettagli]");
                                        Environment.Exit(5);
                                    }
                                }
                            }
                            else
                            {
                                //Warning
                            }
                            MatchResults = MatchResults.NextMatch();
                            mR = mR + 1;
                        }
                        return rm;
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine("ERRORE Match result: [" + ee + "]");
                        Environment.Exit(8);
                        return new responseMsg(true, "ERRORE Match result: [" + ee + "]");
                    }
                }
                proc.Close();
                //return new responseMsg(false, "ERRORE Match result: [" + ee + "]");
            }
            catch (Exception err)
            {
                Console.WriteLine("ERRORE make [" + err.Message + "]");
                Environment.Exit(8);
                return new responseMsg(true, "ERRORE Make result: [" + err.Message + "]");
            }
        }

    }


    class responseMsg
    {
        private string _message;
        public string message
        {
            get { return _message; }
            set { _message = value; }
        }

        private bool _error;
        public bool error
        {
            get { return _error; }
            set { _error = value; }
        }

        public responseMsg(bool error, string message)
        {
            _message = message;
            _error = error;
        }
    }

}