コード例 #1
0
        private static string GetSource(ServerInfo pushData)
        {
            const string Protocol = "://";

              // add a default http protocol if omitted
              var server = pushData.Server;
              if (!server.Contains(Protocol))
              {
            server = "http" + Protocol + server;
              }

              // add a default /nuget/Default feed if omitted
              var position = server.IndexOf(Protocol) + Protocol.Length;
              if (server.TrimEnd('/').IndexOf("/", position) < 0)
              {
            server = server + "/nuget/Default";
              }

              return server;
        }
コード例 #2
0
        private static void ProcessFolder(string directory, string outputFolderPath, bool force, bool sitecoreOnlyAssemblies, bool usePrefix, ServerInfo pushData)
        {
            var pattern = "*rev.*.zip";

              var zipfiles = Directory.GetFiles(directory, pattern, SearchOption.AllDirectories);
              if (zipfiles.Length <= 0)
              {
            return;
              }

              foreach (var file in zipfiles)
              {
            try
            {
              Console.WriteLine("File: " + file);

              // Create nupkg file
              ProcessFile(file, outputFolderPath, force, sitecoreOnlyAssemblies, usePrefix, pushData);
            }
            catch (Exception ex)
            {
              Console.WriteLine("Error processing file " + file + ". " + ex.Message + Environment.NewLine + "Stack trace:" + Environment.NewLine + ex.StackTrace);
            }
              }
        }
コード例 #3
0
        private static void PublishPackage(string nupkgPath, ServerInfo pushData)
        {
            if (pushData == null)
              {
            return;
              }

              Console.WriteLine("Pushing to the server");

              var source = GetSource(pushData);
              var credentials = pushData.Credentials;
              var arguments = string.Format("push \"{0}\" -Source {1} -apikey {2}", nupkgPath, source, credentials);
              var processStartInfo = CreateNuGetProcessStartInfo(arguments);
              var process = System.Diagnostics.Process.Start(processStartInfo);

              // wait for end
              process.WaitForExit();
        }
コード例 #4
0
        private static void ProcessFile(string file, string outputFolderPath, bool force, bool sitecoreOnlyAssemblies, bool usePrefix, ServerInfo pushData)
        {
            string filename = Path.GetFileName(file);
              Console.WriteLine("File: " + filename);
              var match = ProductFileNameRegex.Match(filename);
              if (!match.Success)
              {
            Console.WriteLine("Skipped (regex)");
              }
              else
              {
            var v = VersionInfo.Parse(match);
            if (v == null || v.Major < 0)
            {
              return;
            }

            // Create nupkg file
            var nupkgFiles = new PackageGenerator().Generate(file, outputFolderPath, usePrefix, sitecoreOnlyAssemblies, force);

            // Publish nupkg files
            foreach (var nupkgFile in nupkgFiles)
            {
              PublishPackage(nupkgFile, pushData);
            }
              }
        }