public void StartBuild(FilePackageGenerator.Context context) { BuildViewModel buildViewModel = new BuildViewModel(context); buildViewModel.CloseMode = _commandLine.IsGenerateMode ? CloseMode.AlwaysClose : CloseMode.CloseOnlyWhenSuccess; if (_commandLine.IsGenerateMode) { buildViewModel.Messages.CollectionChanged += Messages_CollectionChanged; } RunMode mode = _commandLine.IsGenerateMode && !_commandLine.ShowProgressUi ? RunMode.Blocking : RunMode.Async; buildViewModel.Start(mode); if (mode == RunMode.Async) { BuildView buildView = new BuildView(); buildView.DataContext = buildViewModel; buildView.ShowDialog(); } buildViewModel.Detach(); if (_commandLine.IsGenerateMode) { buildViewModel.Messages.CollectionChanged -= Messages_CollectionChanged; } }
public BuildViewModel(FilePackageGenerator.Context context) { CurrentOperation = Properties.Resources.PreparingBuild; _context = context; _worker.DoWork += Worker_DoWork; _worker.WorkerSupportsCancellation = true; _worker.RunWorkerCompleted += Worker_RunWorkerCompleted; }
private void BuildPackages(IEnumerable <PackageViewModel> packages) { if (Errors.Any()) { throw new InvalidDataException(Errors.ToString("\n")); } // Setup the generation context FilePackageGenerator.Context context = new FilePackageGenerator.Context(); string basePath = string.Empty; if (System.IO.Path.IsPathRooted(OutputDirectory)) { basePath = OutputDirectory; } else { basePath = Path.Combine(System.IO.Path.GetDirectoryName(InfoFilePathResolved), OutputDirectory); } Directory.CreateDirectory(basePath); context.Global.BasePlatform = BasePlatform; context.Global.SoundBanksRoot = SoundBanksRoot; context.Global.SourceFilesRoot = SourceFilesRoot; context.Packages = packages.Select(p => new FilePackageGenerator.Context.PackageInfo() { FilePackageFilename = BuildPackageFileName(basePath, p.Name), BlockSize = _manualPackagingInfoViewModel.BlockSize, Files = p.ResolvedLayoutItems.Where(i => !i.IsMissing).Select(i => i.ContentItem).Select(ci => new FilePackageGenerator.Context.PackageItem(ci.FileDescriptor, ci.ExternalSourceInfo)), MissingFiles = p.MissingItems.Select(i => i.FileName) .Concat(p.ResolvedLayoutItems.Where(i => i.IsMissing).Select(i => i.FileName)), MissingFromPackageFiles = p.LayoutItems.Where(i => i.IsMissingFromPackage).Select(i => i.FileName) }); MainViewModel.Instance.Application.StartBuild(context); }