예제 #1
0
        public async Task <ExitCode> RunAsync(
            DeploymentTaskPackage deploymentTaskPackage,
            ILogger jobLogger,
            CancellationToken cancellationToken)
        {
            using var manifestFile = TempFile.CreateTempFile("manifest", ".json");
            using var nugetConfig  = TempFile.CreateTempFile("nuget", ".config");

            // Deserialize manifest, add NuGet config, serialize

            if (string.IsNullOrWhiteSpace(deploymentTaskPackage.ManifestJson))
            {
                throw new InvalidOperationException("JSON manifest is missing");
            }

            var definitions = JsonConvert.DeserializeAnonymousType(deploymentTaskPackage.ManifestJson,
                                                                   new { definitions = Array.Empty <DeploymentExecutionDefinition>() });

            if (definitions?.definitions.Length != 1)
            {
                throw new InvalidOperationException($"Expected exactly 1 {nameof(DeploymentExecutionDefinition)}");
            }

            var deploymentExecutionDefinition = definitions.definitions[0];

            if (!string.IsNullOrWhiteSpace(deploymentTaskPackage.NuGetSource))
            {
                deploymentExecutionDefinition = deploymentExecutionDefinition with
                {
                    NuGetPackageSource = deploymentTaskPackage.NuGetSource
                };
            }

            if (!string.IsNullOrWhiteSpace(deploymentTaskPackage.NuGetConfigXml))
            {
                string?nuGetConfigFile = nugetConfig.File?.FullName;

                if (nuGetConfigFile is { })
 public CreateDeploymentTaskPackage(DeploymentTaskPackage deploymentTaskPackage) =>