protected override void ExecuteCommandImpl()

in nuget-extensions/nuget-commands/src/NuGetTeamCityListPackagesCommand.cs [25:69]


    protected override void ExecuteCommandImpl()
    {
      if (string.IsNullOrEmpty(Request) || !File.Exists(Request))
      {
        var message = string.Format("Request file '{0}' was not found", Request);
        System.Console.Error.WriteLine(message);
        throw new CommandLineException(message);
      }
      
      if (string.IsNullOrEmpty(Response))
      {
        var message = string.Format("Response file {0} was not found", Response);
        System.Console.Error.WriteLine(message);
        throw new CommandLineException(message);
      }
      
      new AssemblyResolver(GetType().Assembly.GetAssemblyDirectory());

      INuGetPackages reqs;
      try
      {
        reqs = XmlSerializerHelper.Load<NuGetPackages>(Request);
        reqs.ClearCheckResults();
      }
      catch (Exception e)
      {
        throw new CommandLineException("Invalid request file: {0}", e.Message);
      }
      
      var sourceToRequest = reqs.Packages.GroupBy(x => x.Feed, Id, NuGetSourceComparer.Comparer);
      foreach (var sourceRequest in sourceToRequest)
      {
        ProcessPackageSource(sourceRequest.Key, sourceRequest.ToList());
      }

      try
      {
        XmlSerializerHelper.Save(Response, (NuGetPackages) reqs);
      }
      catch (Exception e)
      {
        System.Console.Error.WriteLine("Unable to write response file: {0}", e.Message);
        throw;
      }
    }