Esempio n. 1
0
 private static void UpdatePackageFiles(IEnumerable <FileInfo> files, SugarRushConfiguration config, Dictionary <string, string> assDic)
 {
     Parallel.ForEach <FileInfo>(files, pf => {
         Console.WriteLine("Updating file: " + pf.FullName);
         var doc = SugarRushHandler.GetXmlDoc(pf.FullName);
         doc.UpdatePackageConfig(config.packageID, config.packageVersion);
     });
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                var sw = new Stopwatch();
                sw.Start();

                _log("Getting configuration...");
                var config = SugarRushHandler.GetConfiguration();

                if (!SugarRushHandler.IsValidConfig(config))
                {
                    var errors = SugarRushHandler.GetValidationErrors(config);
                    _log("Invalid configuration: " + string.Join(", ", errors));
                    return;
                }

                LogConfig(config);

                _log($"Getting nuget package: {config.packageID}.{config.packageVersion}");
                var package = SugarRushHandler.GetPackage(config);

                if (package == null)
                {
                    _log($"Could not find nuget package \"{config.packageID}\" by version \"{config.packageVersion}\"" + config.packageID);
                    return;
                }

                _log("Getting csproj files...");
                var projFiles = SugarRushHandler.FilterFiles(SugarRushHandler.GetCsProjFiles(config.folderPath), config.exclusionPaths);

                _log("Getting Refresh files...");
                var refreshFiles = SugarRushHandler.FilterFiles(SugarRushHandler.GetRefreshFiles(config.folderPath), config.exclusionPaths);

                _log("Getting package.config files...");
                var packageFiles = SugarRushHandler.FilterFiles(SugarRushHandler.GetPackageFiles(config.folderPath), config.exclusionPaths);

                _log("Downloading nuget package locally...");
                DownloadNugetPackage(package, config.nugetRepoUrl);

                var assDic = GetAssemblyReferenceDic(package);

                _log("Updating files...");
                UpdateProjFiles(projFiles, config, assDic);
                UpdateRefreshFiles(refreshFiles, config, assDic);
                UpdatePackageFiles(packageFiles, config, assDic);

                sw.Stop();
                _log("Finished updating");
                _log("Ellapsed time: " + sw.Elapsed);
            }

            catch (Exception exc)
            {
                _log(String.Format($"Something went wrong: {exc.Message}"));
            }
        }