public static int Package(PackageOptions options, TextWriter output, TextWriter error) { #pragma warning disable VSTHRD002 // Ignoring as this is only a helper tool, that is called from console var action = InferPackageAction(options); switch (action) { case PackageTask.Create: PackageWorker.CreateAsync(options.CreateNew, options.OutFile, options.CertThumbprint, output, error).Wait(); break; case PackageTask.Extract: PackageWorker.ExtractAsync(options.Extract, options.DestionationDir, output, error).Wait(); break; case PackageTask.Info: PackageWorker.GetInfo(options.Info, output, error); break; case PackageTask.Prepare: PackageWorker.Prepare(options.PrepareDir, options.Exclusions, options.Version, options.Verbose, output, error); break; default: error.WriteLine($"Unexpected action '{action.ToString()}'"); return(1); } return(0); #pragma warning restore VSTHRD002 // Avoid problematic synchronous waits }
public static int Package(PackageOptions options, TextWriter output, TextWriter error) { var action = InferPackageAction(options); switch (action) { case PackageTask.Create: PackageWorker.Create(options.CreateNew, options.OutFile, options.CertThumbprint, output, error); break; case PackageTask.Extract: PackageWorker.Extract(options.Extract, options.DestionationDir, output, error); break; case PackageTask.Info: PackageWorker.GetInfo(options.Info, output, error); break; case PackageTask.Prepare: PackageWorker.Prepare(options.PrepareDir, options.Exclusions, options.Version, options.Verbose, output, error); break; default: error.WriteLine($"Unexpected action '{action.ToString()}'"); return(1); } return(0); }
public void ProxyOption_ProxySystemAuth_Should_Be_True() { var options = new PackageOptions { ProxySystemAuth = true }; options.ProxySystemAuth.Should().Be(true); }
public void UniqueMappingsOption_When_Set_Should_Replace_Default_Mappings() { var options = new PackageOptions { UniqueOnly = true }; options.UniqueOnly.Should().BeTrue(); }
public void ProxyOption_ProxyURL_Included() { var options = new PackageOptions { ProxyURL = "http://proxy:8080" }; options.ProxyURL.Should().Be("http://proxy:8080"); }
public void PackagesFilterOption_IncorrectPackagesFilterPath_Should_Throw_FileNotFoundException() { var options = new PackageOptions { PackagesFilterOption = @"../../../DoesNotExist.json", }; Assert.Throws(typeof(FileNotFoundException), () => { var regex = options.PackageFilter; }); }
public void PackagesFilterOption_IncorrectRegexPackagesFilter_Should_Throw_ArgumentException() { var options = new PackageOptions { PackagesFilterOption = "/(?/", }; Assert.Throws(typeof(ArgumentException), () => { var regex = options.PackageRegex; }); }
private static int RunPackage(PackageOptions options) { var root = Path.GetFullPath(options.Root, Environment.CurrentDirectory); var outputRoot = Path.Combine(root, options.OutputDir); Directory.CreateDirectory(outputRoot); var packager = new Packager(BuildServiceDiscoveryOptions(options, root), options); packager.Package(outputRoot); return(0); }
public void AddPreDeployment_FilesExist() { // Arrange var tempFile = new FileInfo(Path.GetTempFileName()); var packageBuilder = new PackageBuilder(); packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); packageBuilder.UsingVersion(SqlServerVersion.Sql150); packageBuilder.ValidateModel(); var packageOptions = new PackageOptions() { RefactorLogPath = "../../../../TestProjectWithPrePost/RefactorLog/TestProjectWithPrePost.refactorlog" }; // Act packageBuilder.SaveToDisk(tempFile, packageOptions); packageBuilder.AddPreDeploymentScript( new FileInfo("../../../../TestProjectWithPrePost/Pre-Deployment/Script.PreDeployment.sql"), tempFile); packageBuilder.AddPostDeploymentScript( new FileInfo("../../../../TestProjectWithPrePost/Post-Deployment/Script.PostDeployment.sql"), tempFile); // Assert var package = Package.Open(tempFile.FullName); var prePart = package.GetPart(new Uri("/predeploy.sql", UriKind.Relative)); var postPart = package.GetPart(new Uri("/postdeploy.sql", UriKind.Relative)); var refactorPart = package.GetPart(new Uri("/refactor.xml", UriKind.Relative)); prePart.ShouldNotBeNull(); prePart.ContentType.ShouldBe("text/plain"); prePart.GetStream().ShouldNotBeNull(); postPart.ShouldNotBeNull(); postPart.ContentType.ShouldBe("text/plain"); postPart.GetStream().ShouldNotBeNull(); refactorPart.ShouldNotBeNull(); refactorPart.ContentType.ShouldBe("text/xml"); refactorPart.GetStream().ShouldNotBeNull(); // Cleanup package.Close(); tempFile.Delete(); }
public void LicenseToUrlMappingsOption_When_Set_Should_Replace_Default_Mappings() { var testMappings = new Dictionary <string, string> { { "url1", "license1" }, { "url2", "license1" }, }; var testFile = "test-mappings.json"; File.WriteAllText(testFile, JsonConvert.SerializeObject(testMappings)); var options = new PackageOptions { LicenseToUrlMappingsOption = testFile }; options.LicenseToUrlMappingsDictionary.Should().HaveCount(2) .And.BeEquivalentTo(testMappings); }
public void SaveToDisk(FileInfo outputFile, PackageOptions packageOptions = null) { // Ensure that the model has been created and metadata has been set EnsureModelCreated(); EnsureModelValidated(); EnsureMetadataCreated(); // Check if the file already exists if (outputFile.Exists) { // Delete the existing file Console.WriteLine($"Deleting existing file {outputFile.FullName}"); outputFile.Delete(); } Console.WriteLine($"Writing model to {outputFile.FullName}"); DacPackageExtensions.BuildPackage(outputFile.FullName, Model, Metadata, packageOptions ?? new PackageOptions { }); }
public void Package(PackageOptions options) { try { var deployableProjects = this.BuildAndPublishSolution( build: !options.ExcludeBuild, parameteriseConnectionStrings: options.ParameteriseConnectionStrings, solutionFile: options.SolutionFile, platform: options.Platform, configuration: options.Configuration); var date = DateTime.Now; var applicationPath = new ApplicationService().GetApplicationDirectory(); var fileCopyService = new FileService(); foreach (var deployableProject in deployableProjects) { var packagePath = Path.Combine( deployableProject.Folder, $@"obj\{options.Configuration}\Package\PackageTmp"); var webConfigPath = Path.Combine(packagePath, "Web.config"); var outputFolder = Path.Combine( applicationPath, $@"output\{date:yyyy-MM-dd}\{deployableProject.ProjectName}\build"); fileCopyService.CopyFile(webConfigPath, outputFolder); } this.logger.Information("Package complete."); } catch (Exception exception) { this.logger.Error($"An error occurred packaging: {exception}"); throw; } }
private static object InferPackageAction(PackageOptions options) { if (!string.IsNullOrEmpty(options.Info)) { return(PackageTask.Info); } if (!string.IsNullOrEmpty(options.CreateNew)) { return(PackageTask.Create); } if (!string.IsNullOrEmpty(options.Extract)) { return(PackageTask.Extract); } if (!string.IsNullOrEmpty(options.PrepareDir)) { return(PackageTask.Prepare); } return(PackageTask.None); }
public PackageOptions AddPackageToProject(PackageOptions packageOptions, int projectId) { var project = dbContext.Set <Project>() .Where(p => p.Id == projectId) .Include(pac => pac.Packages) .SingleOrDefault(); var package = new Package() { Price = packageOptions.Price, ProjectId = projectId, Reward = packageOptions.Reward }; project.Packages.Add(package); dbContext.Update(project); dbContext.SaveChanges(); return(new PackageOptions() { Id = package.Id, Price = package.Price, ProjectId = package.ProjectId, Reward = package.Reward }); }
public Packager(ServiceDiscoveryOptions serviceDiscoveryOptions, PackageOptions options) { _serviceDiscoveryOptions = serviceDiscoveryOptions; _options = options; }
public PackageOptions AddPackageToProject([FromForm] PackageOptions packageOptions, int projectId) { return(packageService.AddPackageToProject(packageOptions, projectId)); }