Ejemplo n.º 1
0
        private static void ProcessAlign( string rootFolder, CsUpdateOptions options )
        {
            if ( !Directory.Exists( rootFolder ) ) {
            LogManager.GetCurrentClassLogger().Error( "Target folder " + rootFolder + " does not exist" );
            return;
              }

              LogManager.GetCurrentClassLogger().Info( "Updating/aligning references in " + rootFolder );

              // TODO: Check specifically for known VS extensions only"
              var projectFiles = new DirectoryInfo( rootFolder ).GetFiles( "*.*sproj", SearchOption.AllDirectories ).Select( f => f.FullName ).ToArray();

              // Restore packages now
              NuGetExtensions.RestorePackages( rootFolder );

              TargetPackageIndex targetPackageIndex = new TargetPackageIndex( projectFiles, options.PackageIds.Select( p => new TargetPackage( p ) ) );

              foreach ( var projectFile in projectFiles ) {
            try {
              new PackageReferenceAligner( projectFile, targetPackageIndex ).AlignReferences();
            }
            catch ( Exception e ) {
              LogManager.GetCurrentClassLogger().Error( e, projectFile );
            }
              }
        }
 public PackageReferenceAligner( string projectFile, TargetPackageIndex packageIndex )
 {
     _projectFile = projectFile;
       _packageIndex = packageIndex;
 }