예제 #1
0
        public void Execute()
        {
            if (BuildDirectory == null)
            {
                throw new NullReferenceException("Build directory must be set.");
            }

            BuildDirectory.Refresh();
            if (!BuildDirectory.Exists)
            {
                throw new ArgumentException(string.Format("Build directory {0} does not exist.",
                                                          BuildDirectory.FullName));
            }

            if (Target == null || Target.Trim().Length == 0)
            {
                throw new NullReferenceException("Target must be set.");
            }

            if (Version == null)
            {
                throw new NullReferenceException("Version must be set.");
            }

            if (OutputDirectory == null)
            {
                throw new NullReferenceException("Output directory must be set.");
            }

            OutputDirectory.Refresh();
            if (!OutputDirectory.Exists)
            {
                OutputDirectory.Create();
            }

            var zipDir = BuildDirectory.FullName + "\\_PublishedWebsites\\" + ProjectName;

            if (!Directory.Exists(zipDir))
            {
                zipDir = BuildDirectory.FullName;
            }

            var paths = Directory.GetFiles(zipDir, "*.*", SearchOption.AllDirectories);

            if (paths.Length == 0)
            {
                Log.Warn(string.Format("No files found to zip in directory {0}. ", zipDir));
                return;
            }

            var taskItems = new ITaskItem[paths.Length];

            for (var i = 0; i < paths.Length; i++)
            {
                taskItems[i] = new TaskItem(paths[i]);
                Log.Info(string.Format("Compressing file: {0}.", paths[i]));
            }

            var zipFileName = string.Format("{0}\\{1}-{2}-{3}.zip", OutputDirectory.FullName, AssemblyName, Target,
                                            Version);
            var task = new Zip();

            task.TaskAction    = "Create";
            task.RemoveRoot    = new TaskItem(zipDir);
            task.CompressFiles = taskItems;
            task.ZipFileName   = new TaskItem(zipFileName);
            task.BuildEngine   = new FakeBuildEngine();
            task.Execute();

            ZipFile = new FileInfo(zipFileName);
            Log.Info(string.Format("Compression of directory {0} to zip file {1} complete.", zipDir, zipFileName));
        }
예제 #2
0
        public void Execute()
        {
            if (ProjectDirectory == null)
            {
                throw new NullReferenceException("Project directory must be set.");
            }

            if (!ProjectDirectory.Exists)
            {
                throw new ArgumentException(string.Format("Project directory {0} does not exist.",
                                                          ProjectDirectory.FullName));
            }

            if (BuildDirectory == null)
            {
                throw new NullReferenceException("Build directory must be set.");
            }

            BuildDirectory.Refresh();
            if (!BuildDirectory.Exists)
            {
                throw new ArgumentException(string.Format("Build directory {0} does not exist.",
                                                          BuildDirectory.FullName));
            }

            if (Executable == null)
            {
                throw new NullReferenceException("Assembly executable must be set.");
            }

            if (!Executable.Exists)
            {
                throw new ArgumentException(string.Format("Assembly executable {0} does not exist.", Executable.FullName));
            }

            if (Target == null || Target.Trim().Length == 0)
            {
                throw new NullReferenceException("Target must be set.");
            }

            if (Type == null)
            {
                throw new Exception("Installation must be set.");
            }

            if (Type == InstallType.WebService)
            {
                TransformWebConfig();
            }
            else
            {
                TransformAppConfig();
            }

            if (Type == InstallType.ScheduledTask || Type == InstallType.SelfHostedService)
            {
                TransformTaskConfig();
            }

            TransformLog4NetConfig();

            Log.Info("Config file transormation complete.");
        }
예제 #3
0
        public void Execute()
        {
            var sbsInstallHome = ConfigurationManager.AppSettings["SBS_INSTALL_HOME"];

            if (sbsInstallHome == null)
            {
                throw new NullReferenceException("The location of the SBSInstall.exe directory must be set in the config.");
            }

            if (BuildDirectory == null)
            {
                throw new NullReferenceException("Build directory must be set.");
            }

            BuildDirectory.Refresh();
            if (!BuildDirectory.Exists)
            {
                throw new ArgumentException(string.Format("Build directory {0} does not exist.",
                                                          BuildDirectory.FullName));
            }

            if (Target == null || Target.Trim().Length == 0)
            {
                throw new NullReferenceException("Target must be set.");
            }

            if (Version == null)
            {
                throw new NullReferenceException("Version must be set.");
            }

            if (Archive == null)
            {
                throw new NullReferenceException("Archive location must be set.");
            }

            if (Type == null)
            {
                throw new Exception("Installation must be set.");
            }

            if ((Type == InstallType.Service || Type == InstallType.WebService) &&
                string.IsNullOrEmpty(ServiceName))
            {
                throw new Exception("Sevice name must be specified for Service and WebService installations.");
            }

            var projectName = Path.GetFileNameWithoutExtension(ProjectFile.FullName);
            var zipDir      = BuildDirectory.FullName + "\\_PublishedWebsites\\" + projectName;

            if (!Directory.Exists(zipDir))
            {
                zipDir = BuildDirectory.FullName;
            }

            var paths = Directory.GetFiles(zipDir, "*.*", SearchOption.AllDirectories);

            if (paths.Length == 0)
            {
                Log.Warn(string.Format("No files found to zip in directory {0}. ", zipDir));
                return;
            }

            var zipFileName = string.Format("{0}\\Setup-{1}-{2}-{3}.zip", Archive.Uri, AssemblyName, Target, Version);

            var zip = new Zip();

            zip.ExeXmlConfig = ((SfxConfig)System.Configuration.ConfigurationManager.GetSection("SfxConfig")).ExeXmlConfig;
            zip.UnlockComponent("SHUTTEZIP_sYpChNabpHrd");
            zip.NewZip(zipFileName);

            zip.PathPrefix = "application/";
            zip.AppendFiles(zipDir, true);

            zip.PathPrefix = "installer/";
            zip.AppendFiles(sbsInstallHome, true);

            zip.AutoTemp = true;
            zip.AutoRun  = "installer/SBSInstaller.exe";
            var args = "-t {0} -a {1} -d application";

            if (!string.IsNullOrEmpty(ServiceName))
            {
                args += " -s \"{2}\"";
            }
            if (!string.IsNullOrEmpty(WebsiteName))
            {
                args += " -w \"{3}\"";
            }
            if (!string.IsNullOrEmpty(AppPoolName))
            {
                args += " -p \"{4}\"";
            }
            zip.AutoRunParams = string.Format(args, Type, AssemblyName, ServiceName, WebsiteName, AppPoolName);

            zip.ExeTitle = string.Format("Self Extracting Installation for {0} {1}", AssemblyName, Type);

            var fileName       = string.Format("Setup--{0}-{1}.exe", Target, Version);
            var zipExeFileName = Archive.Archive(zip, Target, fileName);

            ArchiveZipExeFile = zipExeFileName;

            Log.Info(string.Format("Compression of directory {0} to installation file {1} complete.", zipDir, zipExeFileName));
        }