예제 #1
0
    private void Window_Initialized(object sender, EventArgs e)
    {
      UpgradeConfiguration = new UpgradeConfiguration();
      var cfg = UpgradeConfiguration;
      cfg.UpdateByCommandLine();
      bool extractOptions = cfg.Options.ExtractOptions && cfg.SourcePath!=null;
      if (extractOptions) {
        ExtractOptions();
        cfg.UpdateByCommandLine();
      }
      if (cfg.Options.Auto) {
        var upgrader = new Upgrader(cfg);
        upgrader.Process();
        Close();
//        if (Debugger.IsAttached)
//          Console.ReadLine();
      }
      else if (!extractOptions) {
        // Let's suggest these options by default in UI
        cfg.Options.AddImports = true;
        cfg.Options.AddReferences = true;
      }
      Refresh();
    }
예제 #2
0
        // Constructors

        public Upgrader(UpgradeConfiguration configuration = null)
        {
            Configuration = configuration ?? new UpgradeConfiguration();
        }
예제 #3
0
        private void ProcessSolution()
        {
            if (Solution == null)
            {
                Solution = LoadSolution();
            }

            Console.WriteLine("  Processing solution file...");

            try {
                string versionString = Regex.Match(Solution,
                                                   @"^\s+Microsoft Visual Studio Solution File, Format Version (\d+\.\d+)\s*").Groups[1].Value;
                var version = Version.Parse(versionString);
                Console.WriteLine("    File format version: {0}", version);
                if (version.Major < 10.0 || version.Major > 11.0)
                {
                    throw new ApplicationException(
                              "Version {0} of solution file format is not supported.".FormatWith(versionString));
                }
            }
            catch (ApplicationException) {
                throw;
            }
            catch (Exception) {
                throw new ApplicationException("Invalid solution file format.");
            }

            var projects = new List <string>();

            try {
                var projectRegex = new Regex(@"^Project.+\s*=\s*""([^""]+)""\s*,\s*""([^""]+)""\s*,\s*""[^""]+""\s*", RegexOptions.Multiline);
                var match        = projectRegex.Match(Solution);
                while (match.Success)
                {
                    string projectName = match.Groups[1].Value;
                    string projectFile = match.Groups[2].Value;
                    if (projectName == projectFile)
                    {
                        Console.WriteLine("    Solution folder found: '{0}' - skipped", projectName);
                    }
                    else
                    {
                        Console.WriteLine("    Project found: '{0}'", projectName);
                        Console.WriteLine("      Path: {0}", projectFile);
                        projects.Add(projectFile);
                    }
                    match = match.NextMatch();
                }
            }
            catch (Exception) {
                throw new ApplicationException("Invalid solution file format.");
            }

            Console.WriteLine("  Done, total # of projects to upgrade: {0}.", projects.Count);

            // Upgrading projects

            var solutionDir = Path.GetDirectoryName(Configuration.SolutionPath);

            foreach (var project in projects)
            {
                try {
                    var cfg = new UpgradeConfiguration();
                    cfg.SourcePath             = Path.Combine(solutionDir, project);
                    cfg.Options.ExtractOptions = true;
                    cfg.Options.DebugMode      = Configuration.Options.DebugMode;
                    var upgrader = new Upgrader(cfg);
                    upgrader.ExtractOptions();
                    upgrader.Process();
                }
                catch (Exception error) {
                    ErrorReporter.Report(error);
                }
            }
        }
예제 #4
0
    // Constructors

    public Upgrader(UpgradeConfiguration configuration = null)
    {
      Configuration = configuration ?? new UpgradeConfiguration();
    }
예제 #5
0
    private void ProcessSolution()
    {
      if (Solution==null)
        Solution = LoadSolution();

      Console.WriteLine("  Processing solution file...");

      try {
        string versionString = Regex.Match(Solution, 
          @"^\s+Microsoft Visual Studio Solution File, Format Version (\d+\.\d+)\s*").Groups[1].Value;
        var version = Version.Parse(versionString);
        Console.WriteLine("    File format version: {0}", version);
        if (version.Major<10.0 || version.Major>11.0)
          throw new ApplicationException(
            "Version {0} of solution file format is not supported.".FormatWith(versionString));
      }
      catch (ApplicationException) {
        throw;
      }
      catch (Exception) {
        throw new ApplicationException("Invalid solution file format.");
      }

      var projects = new List<string>();
      try {
        var projectRegex = new Regex(@"^Project.+\s*=\s*""([^""]+)""\s*,\s*""([^""]+)""\s*,\s*""[^""]+""\s*", RegexOptions.Multiline);
        var match = projectRegex.Match(Solution);
        while (match.Success) {
          string projectName = match.Groups[1].Value;
          string projectFile = match.Groups[2].Value;
          if (projectName==projectFile) {
            Console.WriteLine("    Solution folder found: '{0}' - skipped", projectName);
          }
          else {
            Console.WriteLine("    Project found: '{0}'", projectName);
            Console.WriteLine("      Path: {0}", projectFile);
            projects.Add(projectFile);
          }
          match = match.NextMatch();
        }
      }
      catch (Exception) {
        throw new ApplicationException("Invalid solution file format.");
      }

      Console.WriteLine("  Done, total # of projects to upgrade: {0}.", projects.Count);

      // Upgrading projects

      var solutionDir = Path.GetDirectoryName(Configuration.SolutionPath);
      foreach (var project in projects) {
        try {
          var cfg = new UpgradeConfiguration();
          cfg.SourcePath = Path.Combine(solutionDir, project);
          cfg.Options.ExtractOptions = true;
          cfg.Options.DebugMode = Configuration.Options.DebugMode;
          var upgrader = new Upgrader(cfg);
          upgrader.ExtractOptions();
          upgrader.Process();
        }
        catch (Exception error) {
          ErrorReporter.Report(error);
        }
      }
    }