diff --git a/deployment/cake/apps-web-tasks.cake b/deployment/cake/apps-web-tasks.cake deleted file mode 100644 index d5a59ad..0000000 --- a/deployment/cake/apps-web-tasks.cake +++ /dev/null @@ -1,207 +0,0 @@ -#l "apps-web-variables.cake" -#l "lib-octopusdeploy.cake" - -#addin "nuget:?package=Microsoft.Azure.KeyVault.Core&version=3.0.5" -#addin "nuget:?package=WindowsAzure.Storage&version=9.3.3" - -//------------------------------------------------------------- - -public class WebProcessor : ProcessorBase -{ - public WebProcessor(BuildContext buildContext) - : base(buildContext) - { - - } - - public override bool HasItems() - { - return BuildContext.Web.Items.Count > 0; - } - - public override async Task PrepareAsync() - { - if (!HasItems()) - { - return; - } - - // Check whether projects should be processed, `.ToList()` - // is required to prevent issues with foreach - foreach (var webApp in BuildContext.Web.Items.ToList()) - { - if (!ShouldProcessProject(BuildContext, webApp)) - { - BuildContext.Web.Items.Remove(webApp); - } - } - } - - public override async Task UpdateInfoAsync() - { - if (!HasItems()) - { - return; - } - - foreach (var webApp in BuildContext.Web.Items) - { - CakeContext.Information("Updating version for web app '{0}'", webApp); - - var projectFileName = GetProjectFileName(BuildContext, webApp); - - CakeContext.TransformConfig(projectFileName, new TransformationCollection - { - { "Project/PropertyGroup/PackageVersion", BuildContext.General.Version.NuGet } - }); - } - } - - public override async Task BuildAsync() - { - if (!HasItems()) - { - return; - } - - foreach (var webApp in BuildContext.Web.Items) - { - BuildContext.CakeContext.LogSeparator("Building web app '{0}'", webApp); - - var projectFileName = GetProjectFileName(BuildContext, webApp); - - var msBuildSettings = new MSBuildSettings - { - Verbosity = Verbosity.Quiet, // Verbosity.Diagnostic - ToolVersion = MSBuildToolVersion.Default, - Configuration = BuildContext.General.Solution.ConfigurationName, - MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform - PlatformTarget = PlatformTarget.MSIL - }; - - ConfigureMsBuild(BuildContext, msBuildSettings, webApp, "build"); - - // Always disable SourceLink - msBuildSettings.WithProperty("EnableSourceLink", "false"); - - RunMsBuild(BuildContext, webApp, projectFileName, msBuildSettings, "build"); - } - } - - public override async Task PackageAsync() - { - if (!HasItems()) - { - return; - } - - // For package documentation using Octopus Deploy, see https://octopus.com/docs/deployment-examples/deploying-asp.net-core-web-applications - - foreach (var webApp in BuildContext.Web.Items) - { - if (!ShouldPackageProject(BuildContext, webApp)) - { - CakeContext.Information("Web app '{0}' should not be packaged", webApp); - continue; - } - - BuildContext.CakeContext.LogSeparator("Packaging web app '{0}'", webApp); - - var projectFileName = System.IO.Path.Combine(".", "src", webApp, $"{webApp}.csproj"); - - var outputDirectory = System.IO.Path.Combine(BuildContext.General.OutputRootDirectory, webApp); - CakeContext.Information("Output directory: '{0}'", outputDirectory); - - CakeContext.Information("1) Using 'dotnet publish' to package '{0}'", webApp); - - var msBuildSettings = new DotNetMSBuildSettings(); - - msBuildSettings.WithProperty("PackageOutputPath", outputDirectory); - msBuildSettings.WithProperty("ConfigurationName", BuildContext.General.Solution.ConfigurationName); - msBuildSettings.WithProperty("PackageVersion", BuildContext.General.Version.NuGet); - - var publishSettings = new DotNetPublishSettings - { - MSBuildSettings = msBuildSettings, - OutputDirectory = outputDirectory, - Configuration = BuildContext.General.Solution.ConfigurationName - }; - - CakeContext.DotNetPublish(projectFileName, publishSettings); - - CakeContext.Information("2) Using 'octo pack' to package '{0}'", webApp); - - var toolSettings = new DotNetToolSettings - { - }; - - var octoPackCommand = string.Format("--id {0} --version {1} --basePath {0}", webApp, BuildContext.General.Version.NuGet); - CakeContext.DotNetTool(outputDirectory, "octo pack", octoPackCommand, toolSettings); - - BuildContext.CakeContext.LogSeparator(); - } - } - - public override async Task DeployAsync() - { - if (!HasItems()) - { - return; - } - - foreach (var webApp in BuildContext.Web.Items) - { - if (!ShouldDeployProject(BuildContext, webApp)) - { - CakeContext.Information("Web app '{0}' should not be deployed", webApp); - continue; - } - - BuildContext.CakeContext.LogSeparator("Deploying web app '{0}'", webApp); - - var packageToPush = System.IO.Path.Combine(BuildContext.General.OutputRootDirectory, string.Format("{0}.{1}.nupkg", webApp, BuildContext.General.Version.NuGet)); - var octopusRepositoryUrl = BuildContext.OctopusDeploy.GetRepositoryUrl(webApp); - var octopusRepositoryApiKey = BuildContext.OctopusDeploy.GetRepositoryApiKey(webApp); - var octopusDeploymentTarget = BuildContext.OctopusDeploy.GetDeploymentTarget(webApp); - - CakeContext.Information("1) Pushing Octopus package"); - - CakeContext.OctoPush(octopusRepositoryUrl, octopusRepositoryApiKey, packageToPush, new OctopusPushSettings - { - ReplaceExisting = true, - }); - - CakeContext.Information("2) Creating release '{0}' in Octopus Deploy", BuildContext.General.Version.NuGet); - - CakeContext.OctoCreateRelease(webApp, new CreateReleaseSettings - { - Server = octopusRepositoryUrl, - ApiKey = octopusRepositoryApiKey, - ReleaseNumber = BuildContext.General.Version.NuGet, - DefaultPackageVersion = BuildContext.General.Version.NuGet, - IgnoreExisting = true - }); - - CakeContext.Information("3) Deploying release '{0}'", BuildContext.General.Version.NuGet); - - CakeContext.OctoDeployRelease(octopusRepositoryUrl, octopusRepositoryApiKey, webApp, octopusDeploymentTarget, - BuildContext.General.Version.NuGet, new OctopusDeployReleaseDeploymentSettings - { - ShowProgress = true, - WaitForDeployment = true, - DeploymentTimeout = TimeSpan.FromMinutes(5), - CancelOnTimeout = true, - GuidedFailure = true, - Force = true, - NoRawLog = true, - }); - - await BuildContext.Notifications.NotifyAsync(webApp, string.Format("Deployed to Octopus Deploy"), TargetType.WebApp); - } - } - - public override async Task FinalizeAsync() - { - - } -} \ No newline at end of file diff --git a/deployment/cake/apps-web-variables.cake b/deployment/cake/apps-web-variables.cake deleted file mode 100644 index 5621d68..0000000 --- a/deployment/cake/apps-web-variables.cake +++ /dev/null @@ -1,49 +0,0 @@ -#l "./buildserver.cake" - -//------------------------------------------------------------- - -public class WebContext : BuildContextWithItemsBase -{ - public WebContext(IBuildContext parentBuildContext) - : base(parentBuildContext) - { - } - - protected override void ValidateContext() - { - } - - protected override void LogStateInfoForContext() - { - CakeContext.Information($"Found '{Items.Count}' web projects"); - } -} - -//------------------------------------------------------------- - -private WebContext InitializeWebContext(BuildContext buildContext, IBuildContext parentBuildContext) -{ - var data = new WebContext(parentBuildContext) - { - Items = WebApps ?? new List() - }; - - return data; -} - -//------------------------------------------------------------- - -List _webApps; - -public List WebApps -{ - get - { - if (_webApps is null) - { - _webApps = new List(); - } - - return _webApps; - } -} \ No newline at end of file diff --git a/deployment/cake/docker-tasks.cake b/deployment/cake/docker-tasks.cake index 007572d..4a20573 100644 --- a/deployment/cake/docker-tasks.cake +++ b/deployment/cake/docker-tasks.cake @@ -1,5 +1,4 @@ #l "docker-variables.cake" -#l "lib-octopusdeploy.cake" #addin "nuget:?package=Cake.Docker&version=1.3.0" @@ -311,9 +310,6 @@ public class DockerImagesProcessor : ProcessorBase var dockerRegistryUserName = GetDockerRegistryUserName(dockerImage); var dockerRegistryPassword = GetDockerRegistryPassword(dockerImage); var dockerImageName = GetDockerImageName(dockerImage); - var octopusRepositoryUrl = BuildContext.OctopusDeploy.GetRepositoryUrl(dockerImage); - var octopusRepositoryApiKey = BuildContext.OctopusDeploy.GetRepositoryApiKey(dockerImage); - var octopusDeploymentTarget = BuildContext.OctopusDeploy.GetDeploymentTarget(dockerImage); if (string.IsNullOrWhiteSpace(dockerRegistryUrl)) { @@ -347,44 +343,7 @@ public class DockerImagesProcessor : ProcessorBase CakeContext.DockerPush(dockerImagePushSettings, dockerImageTag); - if (string.IsNullOrWhiteSpace(octopusRepositoryUrl)) - { - CakeContext.Warning("Octopus Deploy url is not specified, skipping deployment to Octopus Deploy"); - continue; - } - - var imageVersion = BuildContext.General.Version.NuGet; - - CakeContext.Information("Creating release '{0}' in Octopus Deploy", imageVersion); - - CakeContext.OctoCreateRelease(dockerImage, new CreateReleaseSettings - { - Server = octopusRepositoryUrl, - ApiKey = octopusRepositoryApiKey, - ReleaseNumber = imageVersion, - DefaultPackageVersion = imageVersion, - IgnoreExisting = true, - Packages = new Dictionary - { - { dockerImageName, imageVersion } - } - }); - - CakeContext.Information("Deploying release '{0}' via Octopus Deploy", imageVersion); - - CakeContext.OctoDeployRelease(octopusRepositoryUrl, octopusRepositoryApiKey, dockerImage, octopusDeploymentTarget, - imageVersion, new OctopusDeployReleaseDeploymentSettings - { - ShowProgress = true, - WaitForDeployment = true, - DeploymentTimeout = TimeSpan.FromMinutes(5), - CancelOnTimeout = true, - GuidedFailure = true, - Force = true, - NoRawLog = true, - }); - - await BuildContext.Notifications.NotifyAsync(dockerImage, string.Format("Deployed to Octopus Deploy"), TargetType.DockerImage); + await BuildContext.Notifications.NotifyAsync(dockerImage, string.Format("Deployed to Docker"), TargetType.DockerImage); } } finally diff --git a/deployment/cake/lib-generic.cake b/deployment/cake/lib-generic.cake index c45cb4a..0902677 100644 --- a/deployment/cake/lib-generic.cake +++ b/deployment/cake/lib-generic.cake @@ -200,8 +200,6 @@ public enum TargetType VsExtension, - WebApp, - WpfApp } @@ -847,12 +845,6 @@ private static bool IsOnlyDependencyProject(BuildContext buildContext, string pr return false; } - if (buildContext.Web.Items.Contains(projectName)) - { - buildContext.CakeContext.Information($"Project is list of web apps, assuming not dependency only"); - return false; - } - if (buildContext.Wpf.Items.Contains(projectName)) { buildContext.CakeContext.Information($"Project is list of WPF apps, assuming not dependency only"); diff --git a/deployment/cake/lib-msbuild.cake b/deployment/cake/lib-msbuild.cake index 31ac4ba..7d7ce27 100644 --- a/deployment/cake/lib-msbuild.cake +++ b/deployment/cake/lib-msbuild.cake @@ -1,6 +1,6 @@ #addin "nuget:?package=Cake.Issues&version=5.5.0" #addin "nuget:?package=Cake.Issues.MsBuild&version=5.5.0" -#addin "nuget:?package=System.Configuration.ConfigurationManager&version=9.0.1" +#addin "nuget:?package=System.Configuration.ConfigurationManager&version=9.0.2" #tool "nuget:?package=MSBuild.Extension.Pack&version=1.9.1" diff --git a/deployment/cake/lib-octopusdeploy.cake b/deployment/cake/lib-octopusdeploy.cake deleted file mode 100644 index 1cc9416..0000000 --- a/deployment/cake/lib-octopusdeploy.cake +++ /dev/null @@ -1,40 +0,0 @@ -#tool "nuget:?package=OctopusTools&version=9.1.7" - -public class OctopusDeployIntegration : IntegrationBase -{ - public OctopusDeployIntegration(BuildContext buildContext) - : base(buildContext) - { - OctopusRepositoryUrl = buildContext.BuildServer.GetVariable("OctopusRepositoryUrl", showValue: true); - OctopusRepositoryApiKey = buildContext.BuildServer.GetVariable("OctopusRepositoryApiKey", showValue: false); - OctopusDeploymentTarget = buildContext.BuildServer.GetVariable("OctopusDeploymentTarget", "Staging", showValue: true); - } - - public string OctopusRepositoryUrl { get; set; } - public string OctopusRepositoryApiKey { get; set; } - public string OctopusDeploymentTarget { get; set; } - - //------------------------------------------------------------- - - public string GetRepositoryUrl(string projectName) - { - // Allow per project overrides via "OctopusRepositoryUrlFor[ProjectName]" - return GetProjectSpecificConfigurationValue(BuildContext, projectName, "OctopusRepositoryUrlFor", OctopusRepositoryUrl); - } - - //------------------------------------------------------------- - - public string GetRepositoryApiKey(string projectName) - { - // Allow per project overrides via "OctopusRepositoryApiKeyFor[ProjectName]" - return GetProjectSpecificConfigurationValue(BuildContext, projectName, "OctopusRepositoryApiKeyFor", OctopusRepositoryApiKey); - } - - //------------------------------------------------------------- - - public string GetDeploymentTarget(string projectName) - { - // Allow per project overrides via "OctopusDeploymentTargetFor[ProjectName]" - return GetProjectSpecificConfigurationValue(BuildContext, projectName, "OctopusDeploymentTargetFor", OctopusDeploymentTarget); - } -} \ No newline at end of file diff --git a/deployment/cake/tasks.cake b/deployment/cake/tasks.cake index 57e6ee8..ecdfb5b 100644 --- a/deployment/cake/tasks.cake +++ b/deployment/cake/tasks.cake @@ -12,7 +12,6 @@ #l "notifications.cake" #l "generic-tasks.cake" #l "apps-uwp-tasks.cake" -#l "apps-web-tasks.cake" #l "apps-wpf-tasks.cake" #l "codesigning-tasks.cake" #l "components-tasks.cake" @@ -91,7 +90,6 @@ public class BuildContext : BuildContextBase public InstallerIntegration Installer { get; set; } public NotificationsIntegration Notifications { get; set; } public SourceControlIntegration SourceControl { get; set; } - public OctopusDeployIntegration OctopusDeploy { get; set; } // Contexts public GeneralContext General { get; set; } @@ -106,7 +104,6 @@ public class BuildContext : BuildContextBase public ToolsContext Tools { get; set; } public UwpContext Uwp { get; set; } public VsExtensionsContext VsExtensions { get; set; } - public WebContext Web { get; set; } public WpfContext Wpf { get; set; } public List AllProjects { get; private set; } @@ -154,14 +151,12 @@ Setup(setupContext => buildContext.Tools = InitializeToolsContext(buildContext, buildContext); buildContext.Uwp = InitializeUwpContext(buildContext, buildContext); buildContext.VsExtensions = InitializeVsExtensionsContext(buildContext, buildContext); - buildContext.Web = InitializeWebContext(buildContext, buildContext); buildContext.Wpf = InitializeWpfContext(buildContext, buildContext); // Other integrations last buildContext.IssueTracker = new IssueTrackerIntegration(buildContext); buildContext.Installer = new InstallerIntegration(buildContext); buildContext.Notifications = new NotificationsIntegration(buildContext); - buildContext.OctopusDeploy = new OctopusDeployIntegration(buildContext); buildContext.SourceControl = new SourceControlIntegration(buildContext); setupContext.LogSeparator("Validating build context"); @@ -179,7 +174,6 @@ Setup(setupContext => buildContext.Processors.Add(new ToolsProcessor(buildContext)); buildContext.Processors.Add(new UwpProcessor(buildContext)); buildContext.Processors.Add(new VsExtensionsProcessor(buildContext)); - buildContext.Processors.Add(new WebProcessor(buildContext)); buildContext.Processors.Add(new WpfProcessor(buildContext)); // !!! Note: we add test projects *after* preparing all the other processors, see Prepare task !!! @@ -249,7 +243,6 @@ Task("Prepare") buildContext.RegisteredProjects.AddRange(buildContext.Tools.Items); buildContext.RegisteredProjects.AddRange(buildContext.Uwp.Items); buildContext.RegisteredProjects.AddRange(buildContext.VsExtensions.Items); - buildContext.RegisteredProjects.AddRange(buildContext.Web.Items); buildContext.RegisteredProjects.AddRange(buildContext.Wpf.Items); await buildContext.BuildServer.BeforePrepareAsync(); @@ -272,7 +265,6 @@ Task("Prepare") buildContext.AllProjects.AddRange(buildContext.Tools.Items); buildContext.AllProjects.AddRange(buildContext.Uwp.Items); buildContext.AllProjects.AddRange(buildContext.VsExtensions.Items); - buildContext.AllProjects.AddRange(buildContext.Web.Items); buildContext.AllProjects.AddRange(buildContext.Wpf.Items); buildContext.CakeContext.LogSeparator("Final check which test projects should be included (1/2)"); @@ -795,7 +787,6 @@ Task("TestNotifications") await buildContext.Notifications.NotifyAsync("MyProject", "This is a generic test"); await buildContext.Notifications.NotifyAsync("MyProject", "This is a component test", TargetType.Component); await buildContext.Notifications.NotifyAsync("MyProject", "This is a docker image test", TargetType.DockerImage); - await buildContext.Notifications.NotifyAsync("MyProject", "This is a web app test", TargetType.WebApp); await buildContext.Notifications.NotifyAsync("MyProject", "This is a wpf app test", TargetType.WpfApp); await buildContext.Notifications.NotifyErrorAsync("MyProject", "This is an error"); });