Ejemplo n.º 1
0
        internal override void InternalExecute()
        {
            using (var zipInputStream = new ZipInputStream(_fileSystemHelper.ReadFile(_pathToArchive)))
            {
                zipInputStream.Password = _password;

                ZipEntry entry;
                while ((entry = zipInputStream.GetNextEntry()) != null)
                {
                    Stream streamWriter = _fileSystemHelper.CreateFile(System.IO.Path.Combine(_outputPath + "\\", entry.Name));
                    long   size         = entry.Size;
                    var    data         = new byte[size];
                    while (true)
                    {
                        size = zipInputStream.Read(data, 0, data.Length);
                        if (size > 0)
                        {
                            streamWriter.Write(data, 0, (int)size);
                        }
                        else
                        {
                            break;
                        }
                    }
                    streamWriter.Close();
                }
            }
        }
Ejemplo n.º 2
0
 internal override void InternalExecute()
 {
     using (var fs = _fileSystemHelper.CreateFile(_outputPath))
         using (var sw = new StreamWriter(fs))
         {
             sw.Write(AssemblyInfoBuilder.Build(this));
         }
 }
Ejemplo n.º 3
0
        internal override void InternalExecute()
        {
            if (string.IsNullOrEmpty(_pathToNuGetExecutable))
            {
                _pathToNuGetExecutable = _fileSystemHelper.Find("nuget.exe");
            }

            if (string.IsNullOrEmpty(_pathToNuGetExecutable))
            {
                throw new FileNotFoundException("Could not locate nuget.exe. Please specify it manually using PathToNuGetExecutable()");
            }

            var stream = _fileSystemHelper.CreateFile(_deployFolder.File(_projectId + ".nuspec").ToString());

            using (var fs = new StreamWriter(stream))
            {
                fs.Write(CreateSchema());
            }

            //ensure latest version of nuget
            Defaults.Logger.WriteDebugMessage("Updating NuGet to the latest version");
            var ab = new ArgumentBuilder {
                StartOfEntireArgumentString = "Update -self"
            };

            _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).Execute();

            //configure the API key
            Defaults.Logger.WriteDebugMessage("Configuring the API Key");
            ab.StartOfEntireArgumentString = "setApiKey " + _apiKey;
            _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).Execute();

            //package it
            Defaults.Logger.WriteDebugMessage("Creating the package");
            ab.StartOfEntireArgumentString = "Pack " + _projectId + ".nuspec";
            var inWorkingDirectory = _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).InWorkingDirectory(_deployFolder);

            inWorkingDirectory.Execute();

            //NuGet Push YourPackage.nupkg
            Defaults.Logger.WriteDebugMessage("publishing the package");
            ab.StartOfEntireArgumentString = "Push " + _projectId + "." + _version + ".nupkg";
            _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).InWorkingDirectory(_deployFolder).Execute();
        }
Ejemplo n.º 4
0
        internal override void InternalExecute()
        {
            using (var zipOut = new ZipOutputStream(_fileSystemHelper.CreateFile(_outputPath)))
            {
                zipOut.SetLevel(CompressionLevel);

                zipOut.Password = _password;

                foreach (string fileName in GetFiles())
                {
                    //strip of the base folder
                    //this will keep folders preserved
                    string path;
                    if (_path == null) //we are only compressing a single file
                    {
                        path = fileName;
                    }
                    else
                    {
                        path = fileName.Replace(_path, "");
                    }

                    if (path.StartsWith("\\"))
                    {
                        path = path.Substring(1); //removes the leading \
                    }
                    var    entry   = new ZipEntry(path);
                    Stream sReader = _fileSystemHelper.ReadFile(fileName);
                    var    buff    = new byte[Convert.ToInt32(sReader.Length)];
                    sReader.Read(buff, 0, (int)sReader.Length);

                    var fileInfo = new FileInfo(fileName);
                    entry.DateTime = fileInfo.LastWriteTime;
                    entry.Size     = sReader.Length;
                    sReader.Close();
                    zipOut.PutNextEntry(entry);
                    zipOut.Write(buff, 0, buff.Length);
                }
                zipOut.Finish();
                zipOut.Close();
            }
        }