diff --git a/.gitignore b/.gitignore index a90dcb2d6a..f8536f39e3 100644 --- a/.gitignore +++ b/.gitignore @@ -201,3 +201,6 @@ source/Calamari.Tests/Some sample text # CodeRush settings .cr/ + +# This is always built on the build server, so we can just use that one. We just need one in the repo as a signal for the existing build system +netcoreshim.zip \ No newline at end of file diff --git a/build/Build.cs b/build/Build.cs index 671960cf22..7be56147e8 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -23,819 +23,511 @@ using static Nuke.Common.Tools.Git.GitTasks; using static Nuke.Common.Tools.NuGet.NuGetTasks; -namespace Calamari.Build; - -partial class Build : NukeBuild +namespace Calamari.Build { - const string RootProjectName = "Calamari"; + partial class Build : NukeBuild + { + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; + [Required] readonly Solution Solution = SolutionModelTasks.ParseSolution(SourceDirectory / "Calamari.sln"); - [Required] readonly Solution Solution = SolutionModelTasks.ParseSolution(SourceDirectory / "Calamari.sln"); + [Parameter] readonly DotNetVerbosity BuildVerbosity = DotNetVerbosity.minimal; - [Parameter] readonly DotNetVerbosity BuildVerbosity = DotNetVerbosity.minimal; + [Parameter] readonly bool SignBinaries; - [Parameter] readonly bool SignBinaries; + // When building locally signing isn't really necessary and it could take + // up to 3-4 minutes to sign all the binaries as we build for many, many + // different runtimes so disabling it locally means quicker turn around + // when doing local development. + bool WillSignBinaries => !IsLocalBuild || SignBinaries; - // When building locally signing isn't really necessary and it could take - // up to 3-4 minutes to sign all the binaries as we build for many, many - // different runtimes so disabling it locally means quicker turn around - // when doing local development. - bool WillSignBinaries => !IsLocalBuild || SignBinaries; + [Parameter] readonly bool AppendTimestamp; - [Parameter] readonly bool AppendTimestamp; + [Parameter("Set Calamari Version on OctopusServer")] readonly bool SetOctopusServerVersion; - [Parameter("Set Calamari Version on OctopusServer")] readonly bool SetOctopusServerVersion; + [Parameter] readonly string? AzureKeyVaultUrl; - [Parameter] readonly string? AzureKeyVaultUrl; + [Parameter] readonly string? AzureKeyVaultAppId; - [Parameter] readonly string? AzureKeyVaultAppId; + [Parameter] [Secret] readonly string? AzureKeyVaultAppSecret; - [Parameter] [Secret] readonly string? AzureKeyVaultAppSecret; + [Parameter] [Secret] readonly string? AzureKeyVaultTenantId; - [Parameter] [Secret] readonly string? AzureKeyVaultTenantId; + [Parameter] readonly string? AzureKeyVaultCertificateName; - [Parameter] readonly string? AzureKeyVaultCertificateName; + [Parameter(Name = "signing_certificate_path")] readonly string SigningCertificatePath = RootDirectory / "certificates" / "OctopusDevelopment.pfx"; - [Parameter(Name = "signing_certificate_path")] readonly string SigningCertificatePath = RootDirectory / "certificates" / "OctopusDevelopment.pfx"; + [Parameter(Name = "signing_certificate_password")] [Secret] readonly string SigningCertificatePassword = "Password01!"; - [Parameter(Name = "signing_certificate_password")] [Secret] readonly string SigningCertificatePassword = "Password01!"; + [Parameter] readonly string? TargetRuntime; - [Parameter] readonly string? TargetFramework; + const string CiBranchNameEnvVariable = "OCTOVERSION_CurrentBranch"; - [Parameter] readonly string? TargetRuntime; + [Parameter($"The name of the current git branch. OctoVersion will use this to calculate the version number. This can be set via the environment variable {CiBranchNameEnvVariable}.", Name = CiBranchNameEnvVariable)] + string? BranchName { get; set; } - const string CiBranchNameEnvVariable = "OCTOVERSION_CurrentBranch"; + //this is instantiated in the constructor + Lazy OctoVersionInfo; - [Parameter($"The name of the current git branch. OctoVersion will use this to calculate the version number. This can be set via the environment variable {CiBranchNameEnvVariable}.", Name = CiBranchNameEnvVariable)] - string? BranchName { get; set; } + static readonly List CalamariProjectsToSkipConsolidation = new() { "Calamari.CloudAccounts", "Calamari.Common", "Calamari.ConsolidateCalamariPackages" }; - //this is instantiated in the constructor - readonly Lazy OctoVersionInfo; + List PackagesToPublish = new(); + List CalamariProjects = new(); - static readonly List CalamariProjectsToSkipConsolidation = new() { "Calamari.CloudAccounts", "Calamari.Common", "Calamari.ConsolidateCalamariPackages" }; + public Build() + { + // Mimic the behaviour of this attribute, but lazily so we don't pay the OctoVersion cost when it isn't needed + OctoVersionInfo = new Lazy(() => + { + var attribute = new OctoVersionAttribute { BranchMember = nameof(BranchName), Framework = "net6.0" }; - CalamariPackageMetadata[] PackagesToPublish = Array.Empty(); - List CalamariProjects = new(); - readonly List ProjectCompressionTasks = new(); + // the Attribute does all the work such as calling TeamCity.Instance?.SetBuildNumber for us + var version = attribute.GetValue(null!, this); - public Build() - { - // Mimic the behaviour of this attribute, but lazily so we don't pay the OctoVersion cost when it isn't needed - OctoVersionInfo = new Lazy(() => - { - var attribute = new OctoVersionAttribute { BranchMember = nameof(BranchName), Framework = "net6.0" }; + return version as OctoVersionInfo; + }, LazyThreadSafetyMode.ExecutionAndPublication); - // the Attribute does all the work such as calling TeamCity.Instance?.SetBuildNumber for us - var version = attribute.GetValue(null!, this); + NugetVersion = new Lazy(GetNugetVersion); - return version as OctoVersionInfo; - }, LazyThreadSafetyMode.ExecutionAndPublication); + // This initialisation is required to ensure the build script can + // perform actions such as GetRuntimeIdentifiers() on projects. + ProjectModelTasks.Initialize(); + } - NugetVersion = new Lazy(GetNugetVersion); + static AbsolutePath SourceDirectory => RootDirectory / "source"; + static AbsolutePath BuildDirectory => RootDirectory / "build"; + static AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; + static AbsolutePath PublishDirectory => RootDirectory / "publish"; + static AbsolutePath LocalPackagesDirectory => RootDirectory / ".." / "LocalPackages"; + static AbsolutePath ConsolidateCalamariPackagesProject => SourceDirectory / "Calamari.ConsolidateCalamariPackages.Tests" / "Calamari.ConsolidateCalamariPackages.Tests.csproj"; + static AbsolutePath ConsolidatedPackageDirectory => ArtifactsDirectory / "consolidated"; - // This initialisation is required to ensure the build script can - // perform actions such as GetRuntimeIdentifiers() on projects. - ProjectModelTasks.Initialize(); - } + Lazy NugetVersion { get; } - static AbsolutePath SourceDirectory => RootDirectory / "source"; - static AbsolutePath BuildDirectory => RootDirectory / "build"; - static AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; - static AbsolutePath PublishDirectory => RootDirectory / "publish"; - static AbsolutePath LocalPackagesDirectory => RootDirectory / ".." / "LocalPackages"; - static AbsolutePath ConsolidateCalamariPackagesProject => SourceDirectory / "Calamari.ConsolidateCalamariPackages.Tests" / "Calamari.ConsolidateCalamariPackages.Tests.csproj"; - static AbsolutePath ConsolidatedPackageDirectory => ArtifactsDirectory / "consolidated"; - static AbsolutePath LegacyCalamariDirectory => PublishDirectory / "Calamari.Legacy"; - - Lazy NugetVersion { get; } - - Target CheckForbiddenWords => - d => - d.Executes(() => - { - Log.Information("Checking codebase for forbidden words"); - - const string arguments = - "grep -i -I -n -f ForbiddenWords.txt -- \"./*\" \":(exclude)ForbiddenWords.txt\""; - var process = - ProcessTasks.StartProcess(GitPath, arguments) - .AssertWaitForExit(); - - if (process.ExitCode == 1) - { - Log.Information("Sanity check passed"); - return; - } - - var filesContainingForbiddenWords = process.Output.Select(o => o.Text).ToArray(); - if (filesContainingForbiddenWords.Any()) - throw new Exception("Found forbidden words in the following files, " - + "please clean them up:\r\n" - + string.Join("\r\n", filesContainingForbiddenWords)); - }); - - Target Clean => - d => - d.Executes(() => - { - SourceDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults").ForEach(d => d.DeleteDirectory()); - ArtifactsDirectory.CreateOrCleanDirectory(); - PublishDirectory.CreateOrCleanDirectory(); - }); - - Target Restore => - d => - d.DependsOn(Clean) - .Executes(() => - { - var localRuntime = FixedRuntimes.Windows; - - if (!OperatingSystem.IsWindows()) - localRuntime = FixedRuntimes.Linux; - - DotNetRestore(s => s.SetProjectFile(Solution) - .SetRuntime(localRuntime) - .SetProperty("DisableImplicitNuGetFallbackFolder", true)); - }); - - Target Compile => - d => - d.DependsOn(CheckForbiddenWords) - .DependsOn(Restore) - .Executes(() => - { - Log.Information("Compiling Calamari v{CalamariVersion}", NugetVersion.Value); - - DotNetBuild(s => s.SetProjectFile(Solution) - .SetConfiguration(Configuration) - .EnableNoRestore() - .SetVersion(NugetVersion.Value) - .SetInformationalVersion(OctoVersionInfo.Value?.InformationalVersion)); - }); - - Target CalamariConsolidationTests => - d => - d.DependsOn(Compile) - .OnlyWhenStatic(() => !IsLocalBuild) - .Executes(() => - { - DotNetTest(s => s - .SetProjectFile(ConsolidateCalamariPackagesProject) - .SetConfiguration(Configuration) - .EnableNoBuild()); - }); - - Target Publish => - d => - d.DependsOn(Compile) - .DependsOn(PublishAzureWebAppNetCoreShim) - .Executes(() => - { - var nugetVersion = NugetVersion.Value; - if (OperatingSystem.IsWindows()) + Target CheckForbiddenWords => + d => + d.Executes(() => { - var outputDirectory = DoPublish(RootProjectName, Frameworks.Net462, nugetVersion); - outputDirectory.Copy(LegacyCalamariDirectory / RootProjectName, ExistsPolicy.DirectoryMerge | ExistsPolicy.FileFail); - DoPublish(RootProjectName, Frameworks.Net462, nugetVersion, FixedRuntimes.Cloud); - } - else - { - Log.Warning("Building Calamari on a non-windows machine will result " - + "in the {DefaultNugetPackageName} and {CloudNugetPackageName} " - + "nuget packages being built as .Net Core 6.0 packages " - + "instead of as .Net Framework. " - + "This can cause compatibility issues when running certain " - + "deployment steps in Octopus Server", - RootProjectName, $"{RootProjectName}.{FixedRuntimes.Cloud}"); - - DoPublish(RootProjectName, Frameworks.Net60, nugetVersion); - - Log.Warning($"Skipping the bundling of {RootProjectName} into the Calamari.Legacy bundle. " - + "This is required for providing .Net Framework executables for legacy Target Operating Systems"); - - DoPublish(RootProjectName, Frameworks.Net60, nugetVersion, FixedRuntimes.Cloud); - } - - foreach (var rid in GetRuntimeIdentifiers(Solution.GetProject(RootProjectName)!)) - DoPublish(RootProjectName, Frameworks.Net60, nugetVersion, rid); - }); - - Target GetCalamariFlavourProjectsToPublish => - d => - d.DependsOn(Compile) - .Executes(() => - { - var flavours = GetCalamariFlavours(); - var migratedCalamariFlavoursTests = flavours.Select(f => $"{f}.Tests"); - var calamariFlavourProjects = Solution.Projects - .Where(project => flavours.Contains(project.Name) - || migratedCalamariFlavoursTests.Contains(project.Name)); - - // Calamari.Scripting is a library that other calamari flavours depend on; not a flavour on its own right. - // Unlike other *Calamari* tests, we would still want to produce Calamari.Scripting.Zip and its tests, like its flavours. - var calamariScripting = "Calamari.Scripting"; - var calamariScriptingProjectAndTest = Solution.Projects.Where(project => project.Name == calamariScripting || project.Name == $"{calamariScripting}.Tests"); - - var calamariProjects = calamariFlavourProjects - .Concat(calamariScriptingProjectAndTest) - .ToList(); - - CalamariProjects = calamariProjects; - - // All cross-platform Target Frameworks contain dots, all NetFx Target Frameworks don't - // eg: net40, net452, net48 vs netcoreapp3.1, net5.0, net6.0 - bool IsCrossPlatform(string targetFramework) => targetFramework.Contains('.'); - - var calamariPackages = - calamariProjects.SelectMany(project => project.GetTargetFrameworks()!, (p, f) => new - { - Project = p, - Framework = f, - CrossPlatform = IsCrossPlatform(f) - }) - .ToList(); + Log.Information("Checking codebase for forbidden words"); - // for NetFx target frameworks, we use "netfx" as the architecture, and ignore defined runtime identifiers - var netFxPackages = - calamariPackages.Where(p => !p.CrossPlatform) - .Select(packageToBuild => new CalamariPackageMetadata( - project: packageToBuild.Project, - framework: packageToBuild.Framework, - architecture: null, - isCrossPlatform: packageToBuild.CrossPlatform - )); - - // for cross-platform frameworks, we combine each runtime identifier with each target framework - var crossPlatformPackages = - calamariPackages.Where(p => p.CrossPlatform) - .Where(p => string.IsNullOrWhiteSpace(TargetFramework) || p.Framework == TargetFramework) - .SelectMany(packageToBuild => GetRuntimeIdentifiers(packageToBuild.Project), - (packageToBuild, runtimeIdentifier) => new CalamariPackageMetadata( - project: packageToBuild.Project, - framework: packageToBuild.Framework, - architecture: runtimeIdentifier, - isCrossPlatform: packageToBuild.CrossPlatform - )) - .Distinct(t => new { t.Project.Name, t.Architecture, t.Framework }); - - PackagesToPublish = crossPlatformPackages.Concat(netFxPackages).ToArray(); - }); - - Target RestoreCalamariProjects => - d => - d.DependsOn(GetCalamariFlavourProjectsToPublish) - .Executes(() => - { - PackagesToPublish - .Select(p => p.Architecture) - .Distinct() - .ForEach(rid => DotNetRestore(s => - s.SetProjectFile(Solution) - .SetProperty("DisableImplicitNuGetFallbackFolder", true) - .SetRuntime(rid))); - }); - - Target BuildCalamariProjects => - d => - d.DependsOn(RestoreCalamariProjects) - .Executes(async () => - { - var globalSemaphore = new SemaphoreSlim(3); - var semaphores = new ConcurrentDictionary(); - - var buildTasks = PackagesToPublish.Select(async calamariPackageMetadata => - { - if (!OperatingSystem.IsWindows() && !calamariPackageMetadata.IsCrossPlatform) - { - Log.Warning("Not Building {Framework}: can only publish netfx on a Windows OS", calamariPackageMetadata.Framework); - return; - } + const string arguments = + "grep -i -I -n -f ForbiddenWords.txt -- \"./*\" \":(exclude)ForbiddenWords.txt\""; + var process = + ProcessTasks.StartProcess(GitPath, arguments) + .AssertWaitForExit(); - var projectName = calamariPackageMetadata.Project.Name; - var projectSemaphore = semaphores.GetOrAdd(projectName, _ => new SemaphoreSlim(1, 1)); + if (process.ExitCode == 1) + { + Log.Information("Sanity check passed"); + return; + } - // for NetFx target frameworks, we use "netfx" as the architecture, and ignore defined runtime identifiers, here we'll just block on all netfx - var architectureSemaphore = semaphores.GetOrAdd(calamariPackageMetadata.Architecture ?? "Unknown Architecture", _ => new SemaphoreSlim(1, 1)); + var filesContainingForbiddenWords = process.Output.Select(o => o.Text).ToArray(); + if (filesContainingForbiddenWords.Any()) + throw new Exception("Found forbidden words in the following files, " + + "please clean them up:\r\n" + + string.Join("\r\n", filesContainingForbiddenWords)); + }); - await globalSemaphore.WaitAsync(); - await projectSemaphore.WaitAsync(); - await architectureSemaphore.WaitAsync(); - try - { - Log.Information("Building {ProjectName} for framework '{Framework}' and arch '{Architecture}'", calamariPackageMetadata.Project.Name, calamariPackageMetadata.Framework, calamariPackageMetadata.Architecture); - - await Task.Run(() => - DotNetBuild(s => - s.SetProjectFile(calamariPackageMetadata.Project) - .SetConfiguration(Configuration) - .SetFramework(calamariPackageMetadata.Framework) - .EnableNoRestore() - .SetRuntime(calamariPackageMetadata.Architecture) - .EnableSelfContained())); - } - finally - { - projectSemaphore.Release(); - architectureSemaphore.Release(); - globalSemaphore.Release(); - } - }); - - await Task.WhenAll(buildTasks); - }); - - Target PublishCalamariProjects => - d => - d.DependsOn(BuildCalamariProjects) - .Executes(async () => - { - var semaphore = new SemaphoreSlim(4); - var outputPaths = new ConcurrentBag(); - - var publishTasks = PackagesToPublish.Select(async package => - { - await semaphore.WaitAsync(); - try - { - var outputPath = await PublishPackageAsync(package); - outputPaths.Add(outputPath); - } - finally - { - semaphore.Release(); - } - }); + Target Clean => + d => + d.Executes(() => + { + IEnumerable dirs = SourceDirectory.GlobDirectories("**/bin", "**/obj", "**/TestResults"); - await Task.WhenAll(publishTasks); + if (IsLocalBuild) + { + //Don't clean the consolidate files locally (it makes running nuke hard) + dirs = dirs.WhereNot(p => p.ContainsDirectory("*Calamari.ConsolidateCalamariPackages*")); + } - // Sign and compress tasks - var signTasks = outputPaths - .Where(output => output != null && !output.ToString().Contains("Tests")) - .Select(output => Task.Run(() => SignDirectory(output!))) - .ToList(); + dirs.ForEach(d => d.DeleteDirectory()); + ArtifactsDirectory.CreateOrCleanDirectory(); + PublishDirectory.CreateOrCleanDirectory(); + }); - await Task.WhenAll(signTasks); - StageLegacyCalamariAssemblies(PackagesToPublish); - CalamariProjects.ForEach(CompressCalamariProject); - await Task.WhenAll(ProjectCompressionTasks); - }); + Target RestoreSolution => + d => + d.DependsOn(Clean) + .DependsOn(CheckForbiddenWords) + .Executes(() => + { + var allRuntimeIds = ListAllRuntimeIdentifiersInSolution(); + //we restore for all individual runtimes + foreach (var runtimeId in allRuntimeIds) + { + DotNetRestore(s => s.SetProjectFile(Solution).SetRuntime(runtimeId)); + } + }); - async Task PublishPackageAsync(CalamariPackageMetadata calamariPackageMetadata) - { - if (!OperatingSystem.IsWindows() && !calamariPackageMetadata.IsCrossPlatform) - { - Log.Warning("Not publishing {Framework}: can only publish netfx on a Windows OS", calamariPackageMetadata.Framework); - return null; - } + Target GetCalamariFlavourProjectsToPublish => + d => + d.DependsOn(RestoreSolution) + .Executes(() => + { + var projectNames = GetCalamariFlavours(); + + // Calamari.Scripting is a library that other calamari flavours depend on; not a flavour on its own right. + // Unlike other *Calamari* tests, we would still want to produce Calamari.Scripting.Zip and its tests, like its flavours. + //We put this at the front of the list so they build in the correct order? + projectNames.Insert(0, "Calamari.Scripting"); + + //its assumed each project has a corresponding test project + var testProjectNames = projectNames.Select(f => $"{f}.Tests"); + var allProjectNames = projectNames.Concat(testProjectNames).ToHashSet(); + + var calamariProjects = Solution.Projects + .Where(project => allProjectNames.Contains(project.Name)) + .ToList(); + + CalamariProjects = calamariProjects; + + //all packages are cross-platform + var packages = calamariProjects + .SelectMany(project => GetRuntimeIdentifiers(project) + .Select(rid => + { + //we are making the bold assumption all projects only have a single target framework + var framework = project.GetTargetFrameworks()?.Single() ?? Frameworks.Net60; + return new CalamariPackageMetadata(project, framework, rid); + })) + .ToList(); + + PackagesToPublish = packages; + + Log.Information("Packages to publish:"); + foreach (var calamariPackageMetadata in packages) + { + Log.Information("Project: {Project}, Framework: {Framework}, Arch: {Architecture}", calamariPackageMetadata.Project.Name, calamariPackageMetadata.Framework, calamariPackageMetadata.Architecture); + } + }); - Log.Information("Publishing {ProjectName} for framework '{Framework}' and arch '{Architecture}'", calamariPackageMetadata.Project.Name, calamariPackageMetadata.Framework, calamariPackageMetadata.Architecture); + Target BuildCalamariProjects => + d => + d.DependsOn(GetCalamariFlavourProjectsToPublish) + .DependsOn(PublishAzureWebAppNetCoreShim) + .Executes(async () => + { + var globalSemaphore = new SemaphoreSlim(3); + var semaphores = new ConcurrentDictionary(); - var project = calamariPackageMetadata.Project; - var outputDirectory = PublishDirectory / project.Name / (calamariPackageMetadata.IsCrossPlatform ? calamariPackageMetadata.Architecture : "netfx"); + var buildTasks = PackagesToPublish.Select(async calamariPackageMetadata => + { + var projectName = calamariPackageMetadata.Project.Name; + var projectSemaphore = semaphores.GetOrAdd(projectName, _ => new SemaphoreSlim(1, 1)); + var architectureSemaphore = semaphores.GetOrAdd(calamariPackageMetadata.Architecture, _ => new SemaphoreSlim(1, 1)); + + await globalSemaphore.WaitAsync(); + await projectSemaphore.WaitAsync(); + await architectureSemaphore.WaitAsync(); + try + { + Log.Information($"Building {calamariPackageMetadata.Project.Name} for framework '{calamariPackageMetadata.Framework}' and arch '{calamariPackageMetadata.Architecture}'"); + + await Task.Run(() => DotNetBuild(s => + s.SetProjectFile(calamariPackageMetadata.Project) + .SetConfiguration(Configuration) + .SetFramework(calamariPackageMetadata.Framework) + .SetRuntime(calamariPackageMetadata.Architecture) + .EnableSelfContained() + .SetVerbosity(projectName == "Calamari.Tests" ? DotNetVerbosity.detailed : DotNetVerbosity.minimal))); + } + finally + { + projectSemaphore.Release(); + architectureSemaphore.Release(); + globalSemaphore.Release(); + } + }); + + await Task.WhenAll(buildTasks); + }); + + Target PublishCalamariProjects => + d => + d.DependsOn(BuildCalamariProjects) + .Executes(async () => + { + var semaphore = new SemaphoreSlim(4); + var outputPaths = new ConcurrentBag(); - await Task.Run(() => - DotNetPublish(s => - s.SetConfiguration(Configuration) - .SetProject(project) - .SetFramework(calamariPackageMetadata.Framework) - .SetRuntime(calamariPackageMetadata.Architecture) - .EnableNoBuild() - .EnableNoRestore() - .EnableSelfContained() - .SetOutput(outputDirectory))); + Log.Information("Publishing projects..."); + var publishTasks = PackagesToPublish.Select(async package => + { + await semaphore.WaitAsync(); + try + { + var outputPath = await PublishPackageAsync(package); + outputPaths.Add(outputPath); + } + finally + { + semaphore.Release(); + } + }); + + await Task.WhenAll(publishTasks); + + // Sign and compress tasks + Log.Information("Signing published binaries..."); + var signTasks = outputPaths + .Where(output => output != null && !output.ToString().Contains("Tests")) + .Select(output => Task.Run(() => SignDirectory(output!))) + .ToList(); - File.Copy(RootDirectory / "global.json", outputDirectory / "global.json"); + await Task.WhenAll(signTasks); - return outputDirectory; - } + Log.Information("Compressing published projects..."); + var compressTasks = CalamariProjects.Select(async proj => await CompressCalamariProject(proj)); + await Task.WhenAll(compressTasks); + }); - static void StageLegacyCalamariAssemblies(CalamariPackageMetadata[] packagesToPublish) - { - if (!OperatingSystem.IsWindows()) + async Task PublishPackageAsync(CalamariPackageMetadata calamariPackageMetadata) { - Log.Warning($"Skipping the bundling of Calamari projects into the Calamari.Legacy bundle - " - + "this is required for providing .Net Framework executables for legacy Target Operating Systems"); - return; - } + Log.Information($"Publishing {calamariPackageMetadata.Project.Name} for framework '{calamariPackageMetadata.Framework}' and arch '{calamariPackageMetadata.Architecture}'"); - packagesToPublish - //We only need to bundle executable (not tests or libraries) full framework projects - .Where(d => d.Framework == Frameworks.Net462 && d.Project.GetOutputType() == "Exe") - .ForEach(calamariPackageMetadata => - { - Log.Information("Copying {ProjectName} for legacy Calamari '{Framework}' and arch '{Architecture}'", - calamariPackageMetadata.Project.Name, calamariPackageMetadata.Framework, calamariPackageMetadata.Architecture); - var project = calamariPackageMetadata.Project; - var publishedPath = PublishDirectory / project.Name / "netfx"; - publishedPath.Copy(LegacyCalamariDirectory / project.Name, ExistsPolicy.DirectoryMerge | ExistsPolicy.FileFail); - }); - } - - void CompressCalamariProject(Project project) - { - Log.Verbose("Compressing Calamari flavour {PublishDirectory}/{ProjectName}", PublishDirectory, project.Name); - var compressionSource = PublishDirectory / project.Name; - if (!Directory.Exists(compressionSource)) - { - Log.Verbose("Skipping compression for {ProjectName} since nothing was built", project.Name); - return; - } + var project = calamariPackageMetadata.Project; + var outputDirectory = PublishDirectory / project.Name / calamariPackageMetadata.Architecture; - var compressionTask = Task.Run(() => compressionSource.CompressTo($"{ArtifactsDirectory / project.Name}.zip")); - ProjectCompressionTasks.Add(compressionTask); - } + await Task.Run(() => + DotNetPublish(s => + s.SetConfiguration(Configuration) + .SetProject(project) + .SetFramework(calamariPackageMetadata.Framework) + .SetRuntime(calamariPackageMetadata.Architecture) + .EnableNoBuild() + .EnableNoRestore() + .EnableSelfContained() + .SetOutput(outputDirectory))); - Target PublishAzureWebAppNetCoreShim => - _ => _.DependsOn(Restore) - .Executes(() => - { - if (!OperatingSystem.IsWindows()) - { - Log.Warning("Unable to build Calamari.AzureWebApp.NetCoreShim as it's a Full Framework application and can only be compiled on Windows"); - return; - } + File.Copy(RootDirectory / "global.json", outputDirectory / "global.json"); - var project = Solution.GetProject("Calamari.AzureWebApp.NetCoreShim") ?? throw new Exception("Could not find Calamari.AzureWebApp.NetCoreShim project"); + return outputDirectory; + } - var outputPath = PublishDirectory / project.Name; + async Task CompressCalamariProject(Project project) + { + Log.Information($"Compressing Calamari flavour {PublishDirectory}/{project.Name}"); + var compressionSource = PublishDirectory / project.Name; + if (!Directory.Exists(compressionSource)) + { + Log.Information($"Skipping compression for {project.Name} since nothing was built"); + return; + } + + await Task.Run(() => compressionSource.CompressTo($"{ArtifactsDirectory / project.Name}.zip")); + } - DotNetPublish(s => s - .SetConfiguration(Configuration) - .SetProject(project.Path) - .SetFramework(Frameworks.Net462) - .EnableNoRestore() - .SetVersion(NugetVersion.Value) - .SetInformationalVersion(OctoVersionInfo.Value?.InformationalVersion) - .SetOutput(outputPath)); - - var archivePath = SourceDirectory / "Calamari.AzureWebApp" / "netcoreshim" / "netcoreshim.zip"; - archivePath.DeleteFile(); - - outputPath.CompressTo(archivePath); - }); - - Target PackLegacyCalamari => - d => - d.DependsOn(Publish) - .DependsOn(PublishCalamariProjects) - .Executes(() => - { - if (!OperatingSystem.IsWindows()) - { - return; - } - - Log.Verbose($"Compressing Calamari.Legacy"); - LegacyCalamariDirectory.ZipTo(ArtifactsDirectory / $"Calamari.Legacy.{NugetVersion.Value}.zip"); - }); - - Target PackBinaries => - d => - d.DependsOn(Publish) - .DependsOn(PublishCalamariProjects) - .Executes(async () => - { - var nugetVersion = NugetVersion.Value; - var packageActions = new List + Target PublishAzureWebAppNetCoreShim => + _ => _.Executes(() => + { + if (!OperatingSystem.IsWindows()) + { + Log.Warning("Unable to build Calamari.AzureWebApp.NetCoreShim as it's a Full Framework application and can only be compiled on Windows"); + return; + } + + var project = Solution.GetProject("Calamari.AzureWebApp.NetCoreShim"); + if (project is null) + { + Log.Error("Failed to find Calamari.AzureWebApp.NetCoreShim project"); + return; + } + + var outputPath = PublishDirectory / project.Name; + + //as this is the only Net 4.6.2 application left, we do a build and restore here + DotNetPublish(s => s + .SetConfiguration(Configuration) + .SetProject(project.Path) + .SetFramework("net462") + .SetVersion(NugetVersion.Value) + .SetInformationalVersion(OctoVersionInfo.Value?.InformationalVersion) + .SetOutput(outputPath)); + + var archivePath = SourceDirectory / "Calamari.AzureWebApp" / "netcoreshim" / "netcoreshim.zip"; + archivePath.DeleteFile(); + + outputPath.CompressTo(archivePath); + }); + + Target CopyToLocalPackages => + d => + d.Requires(() => IsLocalBuild) + .DependsOn(PublishCalamariProjects) + .Executes(() => { - () => DoPackage(RootProjectName, - OperatingSystem.IsWindows() ? Frameworks.Net462 : Frameworks.Net60, - nugetVersion), - () => DoPackage(RootProjectName, - OperatingSystem.IsWindows() ? Frameworks.Net462 : Frameworks.Net60, - nugetVersion, - FixedRuntimes.Cloud), - }; - - // Create the self-contained Calamari packages for each runtime ID defined in Calamari.csproj - // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var rid in GetRuntimeIdentifiers(Solution.GetProject(RootProjectName)!)) - packageActions.Add(() => DoPackage(RootProjectName, - Frameworks.Net60, - nugetVersion, - rid)); - - var dotNetCorePackSettings = new DotNetPackSettings().SetConfiguration(Configuration) - .SetOutputDirectory(ArtifactsDirectory) - .EnableNoBuild() - .EnableIncludeSource() - .SetVersion(nugetVersion) - .EnableNoRestore(); - - var commonProjects = Directory.GetFiles(SourceDirectory, "*.Common.csproj", - new EnumerationOptions { RecurseSubdirectories = true }); - - // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var project in commonProjects) - packageActions.Add(() => SignAndPack(project.ToString(), dotNetCorePackSettings)); - - // Pack the Consolidation Libraries - var consolidateCalamariPackagesProjectPrefix = "Calamari.ConsolidateCalamariPackages"; - Solution.Projects.Where(project => project.Name.StartsWith(consolidateCalamariPackagesProjectPrefix)).ForEach(p => packageActions.Add(() => SignAndPack(p, dotNetCorePackSettings))); - - var sourceProjectPath = - SourceDirectory / "Calamari.CloudAccounts" / "Calamari.CloudAccounts.csproj"; - packageActions.Add(() => SignAndPack(sourceProjectPath, - dotNetCorePackSettings)); - - await RunPackActions(packageActions); - }); - - Target PackTests => - d => - d.DependsOn(Publish) - .DependsOn(PublishCalamariProjects) - .Executes(async () => - { - var nugetVersion = NugetVersion.Value; - var defaultTarget = OperatingSystem.IsWindows() ? Frameworks.Net462 : Frameworks.Net60; - AbsolutePath binFolder = SourceDirectory / "Calamari.Tests" / "bin" / Configuration / defaultTarget; - Directory.Exists(binFolder); - var actions = new List + Directory.CreateDirectory(LocalPackagesDirectory); + var calamariNupkgs = Directory.GetFiles(ArtifactsDirectory, "Calamari.*.nupkg"); + var octopusCalamariNpkgs = Directory.GetFiles(ArtifactsDirectory, "Octopus.Calamari.*.nupkg"); + + foreach (AbsolutePath file in calamariNupkgs.Concat(octopusCalamariNpkgs).WhereNotNull()) + { + file.Copy(LocalPackagesDirectory / Path.GetFileName(file), ExistsPolicy.FileOverwrite); + } + }); + + // Target CalamariConsolidationTests => + // d => + // d.DependsOn(PublishCalamariProjects) + // .OnlyWhenStatic(() => !IsLocalBuild) + // .Executes(() => + // { + // DotNetTest(s => s + // .SetProjectFile(ConsolidateCalamariPackagesProject) + // .SetConfiguration(Configuration)); + // }); + + Target PackageConsolidatedCalamariZip => + d => + d.DependsOn(PublishCalamariProjects) + .Executes(() => { - () => binFolder.CompressTo( ArtifactsDirectory / "Binaries.zip") - }; + var artifacts = Directory.GetFiles(ArtifactsDirectory, "*.nupkg") + .Where(a => !CalamariProjectsToSkipConsolidation.Any(a.Contains)); + var packageReferences = new List(); + foreach (var artifact in artifacts) + { + using var zip = ZipFile.OpenRead(artifact); + var nuspecFileStream = zip.Entries.First(e => e.Name.EndsWith(".nuspec")).Open(); + var nuspecReader = new NuspecReader(nuspecFileStream); + var metadata = nuspecReader.GetMetadata().ToList(); + packageReferences.Add(new BuildPackageReference + { + Name = metadata.Where(kvp => kvp.Key == "id").Select(i => i.Value).First(), + Version = metadata.Where(kvp => kvp.Key == "version").Select(i => i.Value).First(), + PackagePath = artifact + }); + } - // Create a Zip for each runtime for testing - // ReSharper disable once LoopCanBeConvertedToQuery - actions.Add(() => + foreach (var flavour in GetCalamariFlavours()) + { + if (Solution.GetProject(flavour) != null) + { + packageReferences.Add(new BuildPackageReference { - //run each build in sequence as it's the same project and we get issues - foreach (var rid in GetRuntimeIdentifiers(Solution.GetProject("Calamari.Tests")!)) - { - var publishedLocation = DoPublish("Calamari.Tests", Frameworks.Net60, nugetVersion, rid); - var zipName = $"Calamari.Tests.{rid}.{nugetVersion}.zip"; - File.Copy(RootDirectory / "global.json", publishedLocation / "global.json"); - publishedLocation.CompressTo(ArtifactsDirectory / zipName); - } + Name = flavour, + Version = NugetVersion.Value, + PackagePath = ArtifactsDirectory / $"{flavour}.zip" }); + } + } - //I don't think this is _actually_ necessary to build... - actions.Add(() => - { - var testingProjectPath = SourceDirectory / "Calamari.Testing" / "Calamari.Testing.csproj"; - DotNetPack(new DotNetPackSettings().SetConfiguration(Configuration) - .SetProject(testingProjectPath) - .SetOutputDirectory(ArtifactsDirectory) - .EnableNoBuild() - .EnableIncludeSource() - .SetVersion(nugetVersion) - .EnableNoRestore()); - }); + Directory.CreateDirectory(ConsolidatedPackageDirectory); + var (result, packageFilename) = new Consolidate(Log.Logger).Execute(ConsolidatedPackageDirectory, packageReferences); - await RunPackActions(actions); - }); - - Target Pack => - d => - d.DependsOn(PackTests) - .DependsOn(PackBinaries) - .DependsOn(PackLegacyCalamari); - - Target CopyToLocalPackages => - d => - d.Requires(() => IsLocalBuild) - .DependsOn(PackBinaries) - .Executes(() => - { - Directory.CreateDirectory(LocalPackagesDirectory); - var calamariNupkgs = Directory.GetFiles(ArtifactsDirectory, "Calamari.*.nupkg"); - var octopusCalamariNpkgs = Directory.GetFiles(ArtifactsDirectory, "Octopus.Calamari.*.nupkg"); - - foreach (AbsolutePath file in calamariNupkgs.Concat(octopusCalamariNpkgs).Where(f => f != null)) - { - file.Copy(LocalPackagesDirectory / Path.GetFileName(file), ExistsPolicy.FileOverwrite); - } - }); - - Target PackageConsolidatedCalamariZip => - d => - d.DependsOn(CalamariConsolidationTests) - .DependsOn(PackBinaries) - .Executes(() => - { - var artifacts = Directory.GetFiles(ArtifactsDirectory, "*.nupkg") - .Where(a => !CalamariProjectsToSkipConsolidation.Any(a.Contains)); - var packageReferences = new List(); - foreach (var artifact in artifacts) - { - using var zip = ZipFile.OpenRead(artifact); - var nuspecFileStream = zip.Entries.First(e => e.Name.EndsWith(".nuspec")).Open(); - var nuspecReader = new NuspecReader(nuspecFileStream); - var metadata = nuspecReader.GetMetadata().ToList(); - packageReferences.Add(new BuildPackageReference - { - Name = metadata.Where(kvp => kvp.Key == "id").Select(i => i.Value).First(), - Version = metadata.Where(kvp => kvp.Key == "version").Select(i => i.Value).First(), - PackagePath = artifact - }); - } + if (!result) + throw new Exception("Failed to consolidate calamari Packages"); - foreach (var flavour in GetCalamariFlavours()) + Log.Information($"Created consolidated package zip: {packageFilename}"); + }); + + Target PackCalamariConsolidatedNugetPackage => + d => + d.DependsOn(PackageConsolidatedCalamariZip) + .Executes(() => + { + NuGetPack(s => s.SetTargetPath(BuildDirectory / "Calamari.Consolidated.nuspec") + .SetBasePath(BuildDirectory) + .SetVersion(NugetVersion.Value) + .SetOutputDirectory(ArtifactsDirectory)); + }); + + Target UpdateCalamariVersionOnOctopusServer => + d => + d.OnlyWhenStatic(() => SetOctopusServerVersion) + .Requires(() => IsLocalBuild) + .DependsOn(CopyToLocalPackages) + .Executes(() => { - if (Solution.GetProject(flavour) != null) + var serverProjectFile = RootDirectory / ".." / "OctopusDeploy" / "source" / "Octopus.Server" / "Octopus.Server.csproj"; + if (File.Exists(serverProjectFile)) { - packageReferences.Add(new BuildPackageReference - { - Name = flavour, - Version = NugetVersion.Value, - PackagePath = ArtifactsDirectory / $"{flavour}.zip" - }); + Log.Information("Setting Calamari version in Octopus Server " + + "project {ServerProjectFile} to {NugetVersion}", + serverProjectFile, NugetVersion.Value); + SetOctopusServerCalamariVersion(serverProjectFile); } - } - - Directory.CreateDirectory(ConsolidatedPackageDirectory); - var (result, packageFilename) = new Consolidate(Log.Logger).Execute(ConsolidatedPackageDirectory, packageReferences); - - if (!result) - throw new Exception("Failed to consolidate calamari Packages"); - - Log.Information("Created consolidated package zip: {PackageFilename}", packageFilename); - }); - - Target PackCalamariConsolidatedNugetPackage => - d => - d.DependsOn(PackageConsolidatedCalamariZip) - .Executes(() => - { - NuGetPack(s => s.SetTargetPath(BuildDirectory / "Calamari.Consolidated.nuspec") - .SetBasePath(BuildDirectory) - .SetVersion(NugetVersion.Value) - .SetOutputDirectory(ArtifactsDirectory)); - }); - - Target UpdateCalamariVersionOnOctopusServer => - d => - d.OnlyWhenStatic(() => SetOctopusServerVersion) - .Requires(() => IsLocalBuild) - .DependsOn(CopyToLocalPackages) - .Executes(() => - { - var serverProjectFile = RootDirectory / ".." / "OctopusDeploy" / "source" / "Octopus.Server" / "Octopus.Server.csproj"; - if (File.Exists(serverProjectFile)) - { - Log.Information("Setting Calamari version in Octopus Server " - + "project {ServerProjectFile} to {NugetVersion}", + else + { + Log.Warning("Could not set Calamari version in Octopus Server project " + + "{ServerProjectFile} to {NugetVersion} as could not find " + + "project file", serverProjectFile, NugetVersion.Value); - SetOctopusServerCalamariVersion(serverProjectFile); - } - else - { - Log.Warning("Could not set Calamari version in Octopus Server project " - + "{ServerProjectFile} to {NugetVersion} as could not find " - + "project file", - serverProjectFile, NugetVersion.Value); - } - }); - - Target SetTeamCityVersion => d => d.Executes(() => TeamCity.Instance?.SetBuildNumber(NugetVersion.Value)); - - Target BuildLocal => d => - d.DependsOn(PackCalamariConsolidatedNugetPackage) - .DependsOn(UpdateCalamariVersionOnOctopusServer); + } + }); - Target BuildCi => d => - d.DependsOn(SetTeamCityVersion) - .DependsOn(Pack) - .DependsOn(PackCalamariConsolidatedNugetPackage); + Target SetTeamCityVersion => d => d.Executes(() => TeamCity.Instance?.SetBuildNumber(NugetVersion.Value)); - public static int Main() => Execute(x => IsServerBuild ? x.BuildCi : x.BuildLocal); + Target BuildLocal => d => + d.DependsOn(PackCalamariConsolidatedNugetPackage) + .DependsOn(UpdateCalamariVersionOnOctopusServer); - async Task RunPackActions(List actions) - { - var tasks = actions.Select(Task.Run).ToList(); - await Task.WhenAll(tasks); - } + Target BuildCi => d => + d.DependsOn(SetTeamCityVersion) + .DependsOn(PackCalamariConsolidatedNugetPackage); - AbsolutePath DoPublish(string project, string framework, string version, string? runtimeId = null) - { - var publishedTo = PublishDirectory / project / framework; + public static int Main() => Execute(x => IsServerBuild ? x.BuildCi : x.BuildLocal); - if (!runtimeId.IsNullOrEmpty()) + void SignDirectory(string directory) { - publishedTo /= runtimeId; - runtimeId = runtimeId != "portable" && runtimeId != "Cloud" ? runtimeId : null; + if (!WillSignBinaries) + return; + + Log.Information("Signing directory: {Directory} and sub-directories", directory); + var binariesFolders = Directory.GetDirectories(directory, "*", new EnumerationOptions { RecurseSubdirectories = true }); + foreach (var subDirectory in binariesFolders.Append(directory)) + { + Signing.SignAndTimestampBinaries(subDirectory, AzureKeyVaultUrl, AzureKeyVaultAppId, + AzureKeyVaultAppSecret, AzureKeyVaultTenantId, AzureKeyVaultCertificateName, + SigningCertificatePath, SigningCertificatePassword); + } } - DotNetPublish(s => - s.SetProject(Solution.GetProject(project)) - .SetConfiguration(Configuration) - .SetOutput(publishedTo) - .SetFramework(framework) - .SetVersion(NugetVersion.Value) - .SetVerbosity(BuildVerbosity) - .SetRuntime(runtimeId) - .SetVersion(version) - .EnableSelfContained() - ); - - if (WillSignBinaries) + // Sets the Octopus.Server.csproj Calamari.Consolidated package version + void SetOctopusServerCalamariVersion(string projectFile) { - Signing.SignAndTimestampBinaries(publishedTo, AzureKeyVaultUrl, AzureKeyVaultAppId, - AzureKeyVaultAppSecret, AzureKeyVaultTenantId, AzureKeyVaultCertificateName, - SigningCertificatePath, SigningCertificatePassword); + var text = File.ReadAllText(projectFile); + text = Regex.Replace(text, @"([\S])+", + $"{NugetVersion.Value}"); + File.WriteAllText(projectFile, text); } - return publishedTo; - } - - void SignProject(string project) - { - if (!WillSignBinaries) - return; - var binDirectory = $"{Path.GetDirectoryName(project)}/bin/{Configuration}/"; - SignDirectory(binDirectory); - } - - void SignDirectory(string directory) - { - if (!WillSignBinaries) - return; - - Log.Information("Signing directory: {Directory} and sub-directories", directory); - var binariesFolders = Directory.GetDirectories(directory, "*", new EnumerationOptions { RecurseSubdirectories = true }); - foreach (var subDirectory in binariesFolders.Append(directory)) + string GetNugetVersion() { - Signing.SignAndTimestampBinaries(subDirectory, AzureKeyVaultUrl, AzureKeyVaultAppId, - AzureKeyVaultAppSecret, AzureKeyVaultTenantId, AzureKeyVaultCertificateName, - SigningCertificatePath, SigningCertificatePassword); + return AppendTimestamp + ? $"{OctoVersionInfo.Value?.NuGetVersion}-{DateTime.Now:yyyyMMddHHmmss}" + : OctoVersionInfo.Value?.NuGetVersion + ?? throw new InvalidOperationException("Unable to retrieve valid Nuget Version"); } - } - - void SignAndPack(string project, DotNetPackSettings dotNetCorePackSettings) - { - Log.Information("SignAndPack project: {Project}", project); - SignProject(project); - DotNetPack(dotNetCorePackSettings.SetProject(project)); - } - void DoPackage(string project, string framework, string version, string? runtimeId = null) - { - var publishedTo = PublishDirectory / project / framework; - var projectDir = SourceDirectory / project; - var packageId = $"{project}"; - var nugetPackProperties = new Dictionary(); - - if (!runtimeId.IsNullOrEmpty()) + IReadOnlyCollection GetRuntimeIdentifiers(Project? project) { - publishedTo /= runtimeId; - packageId = $"{project}.{runtimeId}"; - nugetPackProperties.Add("runtimeId", runtimeId!); - } + if (project is null) + return Array.Empty(); - if (WillSignBinaries) - Signing.SignAndTimestampBinaries(publishedTo, AzureKeyVaultUrl, AzureKeyVaultAppId, - AzureKeyVaultAppSecret, AzureKeyVaultTenantId, AzureKeyVaultCertificateName, - SigningCertificatePath, SigningCertificatePassword); - - AbsolutePath nuspecSrc = $"{projectDir}/{project}.nuspec"; - AbsolutePath nuspecDest = $"{publishedTo}/{packageId}.nuspec"; - nuspecSrc.Copy(nuspecDest, ExistsPolicy.FileOverwrite); - var text = File.ReadAllText(nuspecDest); - text = text.Replace("$id$", packageId) - .Replace("$version$", version); - File.WriteAllText(nuspecDest, text); - - NuGetPack(s => - s.SetBasePath(publishedTo) - .SetOutputDirectory(ArtifactsDirectory) - .SetTargetPath(nuspecDest) - .SetVersion(NugetVersion.Value) - .SetVerbosity(NuGetVerbosity.Normal) - .SetProperties(nugetPackProperties)); - } + var runtimes = project.GetRuntimeIdentifiers(); - // Sets the Octopus.Server.csproj Calamari.Consolidated package version - void SetOctopusServerCalamariVersion(string projectFile) - { - var text = File.ReadAllText(projectFile); - text = Regex.Replace(text, @"([\S])+", - $"{NugetVersion.Value}"); - File.WriteAllText(projectFile, text); - } + if (!string.IsNullOrWhiteSpace(TargetRuntime)) + runtimes = runtimes?.Where(x => x == TargetRuntime).ToList().AsReadOnly(); - string GetNugetVersion() - { - return AppendTimestamp - ? $"{OctoVersionInfo.Value?.NuGetVersion}-{DateTime.Now:yyyyMMddHHmmss}" - : OctoVersionInfo.Value?.NuGetVersion - ?? throw new InvalidOperationException("Unable to retrieve valid Nuget Version"); - } + return runtimes ?? Array.Empty(); + } - IReadOnlyCollection GetRuntimeIdentifiers(Project? project) - { - if (project is null) - return Array.Empty(); + //All libraries/flavours now support .NET Core + static List GetCalamariFlavours() => CalamariPackages.Flavours; - var runtimes = project.GetRuntimeIdentifiers(); + HashSet ListAllRuntimeIdentifiersInSolution() + { + var allRuntimes = Solution.AllProjects + .SelectMany(p => p.GetRuntimeIdentifiers() ?? Array.Empty()) + .Distinct() + .ToHashSet(); - if (!string.IsNullOrWhiteSpace(TargetRuntime)) - runtimes = runtimes?.Where(x => x == TargetRuntime).ToList().AsReadOnly(); + if (!string.IsNullOrWhiteSpace(TargetRuntime)) + allRuntimes = allRuntimes.Where(x => x == TargetRuntime).ToHashSet(); - return runtimes ?? Array.Empty(); + return allRuntimes; + } } - - //All libraries/flavours now support .NET Core - static List GetCalamariFlavours() => CalamariPackages.Flavours; -} +} \ No newline at end of file diff --git a/build/Build.sbom.cs b/build/Build.sbom.cs index 68cad71235..b7a2aa73af 100644 --- a/build/Build.sbom.cs +++ b/build/Build.sbom.cs @@ -32,7 +32,7 @@ partial class Build .Requires(() => DependencyTrackUrl) .Requires(() => DependencyTrackApiKey) .Requires(() => InternalDockerRegistry) - .DependsOn(Publish) + .DependsOn(PublishCalamariProjects) .Executes(async () => { ArgumentNullException.ThrowIfNull(Solution, nameof(Solution)); diff --git a/build/CalamariPackageMetadata.cs b/build/CalamariPackageMetadata.cs index 1af761088d..72439274e7 100644 --- a/build/CalamariPackageMetadata.cs +++ b/build/CalamariPackageMetadata.cs @@ -4,17 +4,14 @@ namespace Calamari.Build; public class CalamariPackageMetadata { - public CalamariPackageMetadata(Project project, string framework, string? architecture, bool isCrossPlatform) + public CalamariPackageMetadata(Project project, string framework, string architecture) { Project = project; Framework = framework; Architecture = architecture; - IsCrossPlatform = isCrossPlatform; } public Project Project { get; } public string Framework { get; } - public string? Architecture { get; } - public bool IsCrossPlatform { get; } - + public string Architecture { get; } } diff --git a/build/Frameworks.cs b/build/Frameworks.cs index 3bc89bbc49..049cad7d4d 100644 --- a/build/Frameworks.cs +++ b/build/Frameworks.cs @@ -4,7 +4,7 @@ namespace Calamari.Build { public static class Frameworks { - public const string Net462 = "net462"; public const string Net60 = "net6.0"; + public const string Net60Windows = "net6.0-windows"; } } \ No newline at end of file diff --git a/source/Calamari.Aws/Calamari.Aws.csproj b/source/Calamari.Aws/Calamari.Aws.csproj index a60f95341f..6b5a9a8cf7 100644 --- a/source/Calamari.Aws/Calamari.Aws.csproj +++ b/source/Calamari.Aws/Calamari.Aws.csproj @@ -1,7 +1,6 @@  1.0.0.0 - Exe anycpu Calamari.Aws Library @@ -19,7 +18,8 @@ Calamari.Aws.exe.manifest - net462;netstandard2.1 + net6.0 + 10 true diff --git a/source/Calamari.Azure/Calamari.Azure.csproj b/source/Calamari.Azure/Calamari.Azure.csproj index 3e86f265a5..c51a6f4779 100644 --- a/source/Calamari.Azure/Calamari.Azure.csproj +++ b/source/Calamari.Azure/Calamari.Azure.csproj @@ -6,8 +6,9 @@ Octopus Deploy Octopus Deploy Pty Ltd win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 + 10 + net6.0 8.0 - net462;net6.0 true diff --git a/source/Calamari.AzureAppService.Tests/Calamari.AzureAppService.Tests.csproj b/source/Calamari.AzureAppService.Tests/Calamari.AzureAppService.Tests.csproj index 936f694428..3fcdaaee93 100644 --- a/source/Calamari.AzureAppService.Tests/Calamari.AzureAppService.Tests.csproj +++ b/source/Calamari.AzureAppService.Tests/Calamari.AzureAppService.Tests.csproj @@ -1,41 +1,40 @@ + + Calamari.AzureAppService.Tests + Calamari.AzureAppService.Tests + false + win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 + 10 + net6.0 + true + - - Calamari.AzureAppService.Tests - Calamari.AzureAppService.Tests - false - win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - 8.0 - net462;net6.0 - true - + + + + + + + + + + + - - - - - - - - - - - + + + + - - - - - - - - Always - - - Always - - - Always - - + + + Always + + + Always + + + Always + + diff --git a/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj b/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj index 9c9f17bb63..cb94cf9ecd 100644 --- a/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj +++ b/source/Calamari.AzureAppService/Calamari.AzureAppService.csproj @@ -1,35 +1,34 @@  - - Calamari.AzureAppService - Calamari.AzureAppService - true - true - Exe - win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - 8.0 - NU5104 - net462;net6.0 - true - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - - - - - - + + Calamari.AzureAppService + Calamari.AzureAppService + true + true + Exe + win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 + 10 + NU5104 + net6.0 + true + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + + diff --git a/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj b/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj index 4b65a971d3..faa213ece0 100644 --- a/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj +++ b/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj @@ -1,52 +1,52 @@ - - Calamari.AzureResourceGroup.Tests - Calamari.AzureResourceGroup.Tests - false - win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - net462;net6.0 - true - - - - - - - - - - + + Calamari.AzureResourceGroup.Tests + Calamari.AzureResourceGroup.Tests + false + win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 + net6.0 + 10 + true + - - false - Octopus.Dependencies.AzureCLI.nupkg - true - true - true - contentFiles/any/any/Octopus.Dependencies.AzureCLI.nupkg - PreserveNewest - + + + + + - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - + + + + false + Octopus.Dependencies.AzureCLI.nupkg + true + true + true + contentFiles/any/any/Octopus.Dependencies.AzureCLI.nupkg + PreserveNewest + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + \ No newline at end of file diff --git a/source/Calamari.AzureResourceGroup/Calamari.AzureResourceGroup.csproj b/source/Calamari.AzureResourceGroup/Calamari.AzureResourceGroup.csproj index 5c2979832b..bbc55bbc19 100644 --- a/source/Calamari.AzureResourceGroup/Calamari.AzureResourceGroup.csproj +++ b/source/Calamari.AzureResourceGroup/Calamari.AzureResourceGroup.csproj @@ -2,20 +2,20 @@ Calamari.AzureResourceGroup Calamari.AzureResourceGroup - 8 + 10 enable Exe false false win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - net462;net6.0 + net6.0 - + - - + + all runtime; build; native; contentfiles; analyzers diff --git a/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs b/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs index d762cf6c21..c3c1c97e1d 100644 --- a/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs +++ b/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs @@ -20,13 +20,7 @@ class AzurePowerShellCommandFixture string? subscriptionId; static IDeploymentTool AzureCLI = new InPathDeploymentTool("Octopus.Dependencies.AzureCLI", "AzureCLI\\wbin"); - static IDeploymentTool AzureCmdlets = new BoostrapperModuleDeploymentTool("Octopus.Dependencies.AzureCmdlets", - new[] - { - "Powershell\\Azure.Storage\\4.6.1", - "Powershell\\Azure\\5.3.0", - "Powershell", - }); + static readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource(); readonly CancellationToken cancellationToken = CancellationTokenSource.Token; @@ -114,7 +108,6 @@ void AddDefaults(CommandTestBuilderContext context) context.Variables.Add(SpecialVariables.Action.Azure.ClientId, clientId); context.Variables.Add(SpecialVariables.Action.Azure.Password, clientSecret); context.WithTool(AzureCLI); - context.WithTool(AzureCmdlets); } } } \ No newline at end of file diff --git a/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj b/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj index ba5f0b2704..94be60fb08 100644 --- a/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj +++ b/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj @@ -3,11 +3,11 @@ Calamari.AzureScripting.Tests Calamari.AzureScripting.Tests - 8 + 10 enable win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 false - net462;net6.0 + net6.0 true @@ -19,10 +19,10 @@ - + - + @@ -35,22 +35,10 @@ contentFiles/any/any/Octopus.Dependencies.AzureCLI.nupkg PreserveNewest - - false - Octopus.Dependencies.AzureCmdlets.nupkg - true - true - true - contentFiles/any/any/Octopus.Dependencies.AzureCmdlets.nupkg - PreserveNewest - - - - - - + + diff --git a/source/Calamari.AzureScripting/Calamari.AzureScripting.csproj b/source/Calamari.AzureScripting/Calamari.AzureScripting.csproj index 8d16037809..0654f9b03b 100644 --- a/source/Calamari.AzureScripting/Calamari.AzureScripting.csproj +++ b/source/Calamari.AzureScripting/Calamari.AzureScripting.csproj @@ -2,14 +2,14 @@ Calamari.AzureScripting Calamari.AzureScripting - 8 + 10 enable Exe true win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 true false - net462;net6.0 + net6.0 true @@ -17,17 +17,14 @@ - + + - - - - - - + + diff --git a/source/Calamari.AzureServiceFabric.Tests/Calamari.AzureServiceFabric.Tests.csproj b/source/Calamari.AzureServiceFabric.Tests/Calamari.AzureServiceFabric.Tests.csproj index 1591766149..884aae9c5e 100644 --- a/source/Calamari.AzureServiceFabric.Tests/Calamari.AzureServiceFabric.Tests.csproj +++ b/source/Calamari.AzureServiceFabric.Tests/Calamari.AzureServiceFabric.Tests.csproj @@ -4,9 +4,9 @@ Calamari.AzureServiceFabric.Tests Calamari.AzureServiceFabric.Tests false - net462;net6.0-windows + net6.0-windows win-x64 - 8.0 + 10 true @@ -19,12 +19,12 @@ - - + + - - Always - + + Always + diff --git a/source/Calamari.AzureServiceFabric/Calamari.AzureServiceFabric.csproj b/source/Calamari.AzureServiceFabric/Calamari.AzureServiceFabric.csproj index cae6d5e717..ef001c60ec 100644 --- a/source/Calamari.AzureServiceFabric/Calamari.AzureServiceFabric.csproj +++ b/source/Calamari.AzureServiceFabric/Calamari.AzureServiceFabric.csproj @@ -1,36 +1,35 @@  - - Calamari.AzureServiceFabric - Calamari.AzureServiceFabric - true - false - Exe - net462;net6.0-windows - win-x64 - 8.0 - true - + + Calamari.AzureServiceFabric + Calamari.AzureServiceFabric + true + false + Exe + net6.0-windows + win-x64 + 10 + true + + + - - - - - - + + + - - - + + + - - - + + + diff --git a/source/Calamari.AzureWebApp.Tests/Calamari.AzureWebApp.Tests.csproj b/source/Calamari.AzureWebApp.Tests/Calamari.AzureWebApp.Tests.csproj index 18af1fef94..0ce9df0ce3 100644 --- a/source/Calamari.AzureWebApp.Tests/Calamari.AzureWebApp.Tests.csproj +++ b/source/Calamari.AzureWebApp.Tests/Calamari.AzureWebApp.Tests.csproj @@ -1,41 +1,40 @@ - - Calamari.AzureWebApp.Tests - Calamari.AzureWebApp.Tests - net462;net6.0 - win-x64 - 8.0 - false - true - - - - - - - - - - - - - - PreserveNewest - - - - - + + Calamari.AzureWebApp.Tests + Calamari.AzureWebApp.Tests + net6.0 + win-x64 + 10 + false + true + + + + + + + - + + - + + + PreserveNewest + + + + + + + + - - - + + + - - - + + + diff --git a/source/Calamari.AzureWebApp/Calamari.AzureWebApp.csproj b/source/Calamari.AzureWebApp/Calamari.AzureWebApp.csproj index 9e441099fc..bf6e525c1e 100644 --- a/source/Calamari.AzureWebApp/Calamari.AzureWebApp.csproj +++ b/source/Calamari.AzureWebApp/Calamari.AzureWebApp.csproj @@ -1,67 +1,63 @@ - - Calamari.AzureWebApp - Calamari.AzureWebApp - true - false - Exe - net462;net6.0 - win-x64 - 8.0 - true - + + Calamari.AzureWebApp + Calamari.AzureWebApp + true + false + Exe + net6.0 + win-x64 + 10 + true + - - - - - - - + + + + + + + - - - - - + + + + + - - - + + + netcoreshim + true + false + contentFiles/any/any/netcoreshim/ + true + false + PreserveNewest + + - - - netcoreshim - true - false - contentFiles/any/any/netcoreshim/ - true - false - PreserveNewest - - - - - - - - - - + + + - - - + + + - - + - - - - - - - + + + + + + + + + + + + diff --git a/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj b/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj index 0112bae668..a8f1ee4902 100644 --- a/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj +++ b/source/Calamari.CloudAccounts/Calamari.CloudAccounts.csproj @@ -2,14 +2,10 @@ Calamari.CloudAccounts - net462;netstandard2.1 + netstandard2.1 + 8 - - - - - - + diff --git a/source/Calamari.Common/Calamari.Common.csproj b/source/Calamari.Common/Calamari.Common.csproj index b5a99448fa..e8da8d0fa6 100644 --- a/source/Calamari.Common/Calamari.Common.csproj +++ b/source/Calamari.Common/Calamari.Common.csproj @@ -1,42 +1,21 @@  - net462;netstandard2.1 8 enable anycpu + netstandard2.1 false - - $(DefineConstants);USE_ALPHAFS_FOR_LONG_FILE_PATH_SUPPORT;HAS_SSL3 - - + $(DefineConstants);USE_NUGET_V3_LIBS;WORKAROUND_FOR_EMPTY_STRING_BUG;HAS_NULLABLE_REF_TYPES - - - CS8600;CS8601;CS8602;CS8603;CS8604;NU5104 - - - + - - - - - - - - - - - - - diff --git a/source/Calamari.ConsolidateCalamariPackages.Api/Calamari.ConsolidateCalamariPackages.Api.csproj b/source/Calamari.ConsolidateCalamariPackages.Api/Calamari.ConsolidateCalamariPackages.Api.csproj index 86198e9f76..450dff23c9 100644 --- a/source/Calamari.ConsolidateCalamariPackages.Api/Calamari.ConsolidateCalamariPackages.Api.csproj +++ b/source/Calamari.ConsolidateCalamariPackages.Api/Calamari.ConsolidateCalamariPackages.Api.csproj @@ -6,7 +6,7 @@ net6.0 enable enable - default + 10 Octopus Deploy Octopus Deploy Pty Ltd diff --git a/source/Calamari.ConsolidateCalamariPackages.Tests/Calamari.ConsolidateCalamariPackages.Tests.csproj b/source/Calamari.ConsolidateCalamariPackages.Tests/Calamari.ConsolidateCalamariPackages.Tests.csproj index c411b584ef..a0fb5973d4 100644 --- a/source/Calamari.ConsolidateCalamariPackages.Tests/Calamari.ConsolidateCalamariPackages.Tests.csproj +++ b/source/Calamari.ConsolidateCalamariPackages.Tests/Calamari.ConsolidateCalamariPackages.Tests.csproj @@ -3,6 +3,7 @@ net6.0 false + 10 true @@ -35,12 +36,12 @@ - - - - - - + + + + + + diff --git a/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj b/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj index 8acc6b19cd..88ebbf2ca6 100644 --- a/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj +++ b/source/Calamari.ConsolidateCalamariPackages/Calamari.ConsolidateCalamariPackages.csproj @@ -4,7 +4,7 @@ Octopus.Calamari.ConsolidatedPackage Octopus.Calamari.ConsolidatedPackage net6.0 - default + 10 true true Octopus Deploy diff --git a/source/Calamari.ConsolidateCalamariPackages/CalamariPackages.cs b/source/Calamari.ConsolidateCalamariPackages/CalamariPackages.cs index a7f341e8df..2c54f4f572 100644 --- a/source/Calamari.ConsolidateCalamariPackages/CalamariPackages.cs +++ b/source/Calamari.ConsolidateCalamariPackages/CalamariPackages.cs @@ -10,6 +10,7 @@ public static class CalamariPackages static readonly List CrossPlatformFlavours = new() { + "Calamari", "Calamari.AzureServiceFabric", "Calamari.AzureAppService", "Calamari.AzureResourceGroup", diff --git a/source/Calamari.GoogleCloudAccounts/Calamari.GoogleCloudAccounts.csproj b/source/Calamari.GoogleCloudAccounts/Calamari.GoogleCloudAccounts.csproj index 1126f5d78a..8be3f2669c 100644 --- a/source/Calamari.GoogleCloudAccounts/Calamari.GoogleCloudAccounts.csproj +++ b/source/Calamari.GoogleCloudAccounts/Calamari.GoogleCloudAccounts.csproj @@ -2,18 +2,12 @@ Calamari.GoogleCloudAccounts - net462;netstandard2.1 - latest + 8 + netstandard2.1 CS8632 true - - - - - - diff --git a/source/Calamari.GoogleCloudScripting.Tests/Calamari.GoogleCloudScripting.Tests.csproj b/source/Calamari.GoogleCloudScripting.Tests/Calamari.GoogleCloudScripting.Tests.csproj index 3c9d3f1438..3cca5d9630 100644 --- a/source/Calamari.GoogleCloudScripting.Tests/Calamari.GoogleCloudScripting.Tests.csproj +++ b/source/Calamari.GoogleCloudScripting.Tests/Calamari.GoogleCloudScripting.Tests.csproj @@ -3,10 +3,10 @@ Calamari.GoogleCloudScripting.Tests win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - 8 + 10 false enable - net462;net6.0 + net6.0 true diff --git a/source/Calamari.GoogleCloudScripting/Calamari.GoogleCloudScripting.csproj b/source/Calamari.GoogleCloudScripting/Calamari.GoogleCloudScripting.csproj index 49f6d3d805..97c79bf841 100644 --- a/source/Calamari.GoogleCloudScripting/Calamari.GoogleCloudScripting.csproj +++ b/source/Calamari.GoogleCloudScripting/Calamari.GoogleCloudScripting.csproj @@ -4,17 +4,17 @@ Calamari.GoogleCloudScripting Exe win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - 8 + 10 false false - net462;net6.0 + net6.0 CS8632 true - - + + diff --git a/source/Calamari.Scripting/Calamari.Scripting.csproj b/source/Calamari.Scripting/Calamari.Scripting.csproj index 4b4a34699b..5529aa4d07 100644 --- a/source/Calamari.Scripting/Calamari.Scripting.csproj +++ b/source/Calamari.Scripting/Calamari.Scripting.csproj @@ -7,23 +7,18 @@ enable win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 true - 9 - net462;net6.0 + 10 + net6.0 true - all runtime; build; native; contentfiles; analyzers - - - - CS8600;CS8601;CS8602;CS8603;CS8604 - - + + $(DefineConstants);HAS_NULLABLE_REF_TYPES @@ -37,15 +32,6 @@ false PreserveNewest - - scriptcs - false - true - contentFiles/any/any/scriptcs/ - true - false - PreserveNewest - diff --git a/source/Calamari.Shared/Calamari.Shared.csproj b/source/Calamari.Shared/Calamari.Shared.csproj index 9bb358ba0d..c45e29705e 100644 --- a/source/Calamari.Shared/Calamari.Shared.csproj +++ b/source/Calamari.Shared/Calamari.Shared.csproj @@ -23,18 +23,11 @@ Calamari 8 enable - net462;netstandard2.1 + netstandard2.1 - - $(DefineConstants);NETFX;USE_NUGET_V2_LIBS;USE_OCTODIFF_EXE; - anycpu - - + $(DefineConstants);USE_NUGET_V3_LIBS - - CS8600;CS8601;CS8602;CS8603;CS8604;DE0003;DE0004 - @@ -57,8 +50,6 @@ - - @@ -69,29 +60,6 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj b/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj index 59bf847e79..88aebe7c8b 100644 --- a/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj +++ b/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj @@ -5,8 +5,8 @@ Calamari.Terraform.Tests win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 false - 9 - net462;net6.0 + 10 + net6.0 CS8632 true @@ -23,8 +23,8 @@ - - + + diff --git a/source/Calamari.Terraform/Calamari.Terraform.csproj b/source/Calamari.Terraform/Calamari.Terraform.csproj index 78809089b8..9e06c97048 100644 --- a/source/Calamari.Terraform/Calamari.Terraform.csproj +++ b/source/Calamari.Terraform/Calamari.Terraform.csproj @@ -1,26 +1,26 @@  - - Calamari.Terraform - Calamari.Terraform - true - false - Exe - 9 - win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - net462;net6.0 - true - - - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - + + Calamari.Terraform + Calamari.Terraform + true + false + Exe + 10 + win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 + net6.0 + true + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + diff --git a/source/Calamari.Testing/Calamari.Testing.csproj b/source/Calamari.Testing/Calamari.Testing.csproj index ef08de8020..eb1fba0d7b 100644 --- a/source/Calamari.Testing/Calamari.Testing.csproj +++ b/source/Calamari.Testing/Calamari.Testing.csproj @@ -4,18 +4,15 @@ enable https://github.com/OctopusDeploy/Calamari/ Apache-2.0 - default - net462;netstandard2.1 + 10 + net6.0 true - - $(DefineConstants);NETCORE - - + @@ -26,9 +23,4 @@ - - - - - diff --git a/source/Calamari.Testing/CommandTestBuilder.cs b/source/Calamari.Testing/CommandTestBuilder.cs index 53f2fe2547..bf8e03fd3a 100644 --- a/source/Calamari.Testing/CommandTestBuilder.cs +++ b/source/Calamari.Testing/CommandTestBuilder.cs @@ -1,8 +1,6 @@ -#if NETSTANDARD + using NuGet.Packaging; using NuGet.Versioning; -#else -#endif using System; using System.Collections.Generic; using System.IO; @@ -20,7 +18,6 @@ using Calamari.Testing.Helpers; using Calamari.Testing.LogParser; using FluentAssertions; -using NuGet; using Octopus.CoreUtilities; using KnownVariables = Calamari.Common.Plumbing.Variables.KnownVariables; using OSPlatform = System.Runtime.InteropServices.OSPlatform; @@ -39,7 +36,7 @@ public static CommandTestBuilder CreateAsync() where TCalamari : CalamariFlavourProgramAsync where TCommand : PipelineCommand { - return new CommandTestBuilder(typeof(TCommand).GetCustomAttribute().Name); + return new CommandTestBuilder(typeof(TCommand).GetCustomAttribute()!.Name); } public static CommandTestBuilder Create(string command) @@ -52,7 +49,7 @@ public static CommandTestBuilder Create() where TCalamari : CalamariFlavourProgram where TCommand : ICommand { - return new CommandTestBuilder(typeof(TCommand).GetCustomAttribute().Name); + return new CommandTestBuilder(typeof(TCommand).GetCustomAttribute()!.Name); } public static CommandTestBuilderContext WithFilesToCopy(this CommandTestBuilderContext context, string path) @@ -94,13 +91,8 @@ static string CreateNugetPackage(string packageId, string packageVersion, string { var metadata = new ManifestMetadata { -#if NETSTANDARD Authors = new [] {"octopus@e2eTests"}, Version = new NuGetVersion(packageVersion), -#else - Authors = "octopus@e2eTests", - Version = packageVersion, -#endif Id = packageId, Description = nameof(CommandTestBuilder) }; diff --git a/source/Calamari.Testing/EnvironmentVariables.cs b/source/Calamari.Testing/EnvironmentVariables.cs index 3c13dee6c8..31b050a874 100644 --- a/source/Calamari.Testing/EnvironmentVariables.cs +++ b/source/Calamari.Testing/EnvironmentVariables.cs @@ -175,7 +175,7 @@ public EnvironmentVariableAttribute(string name, string? secretReference = null, public static EnvironmentVariableAttribute? Get(object enm) { - var mi = enm?.GetType().GetMember(enm.ToString()); + var mi = enm.GetType().GetMember(enm.ToString()!); if (mi == null || mi.Length <= 0) { return null; diff --git a/source/Calamari.Testing/Helpers/CaptureCommandInvocationOutputSink.cs b/source/Calamari.Testing/Helpers/CaptureCommandInvocationOutputSink.cs index 6fc1031458..398cab6e69 100644 --- a/source/Calamari.Testing/Helpers/CaptureCommandInvocationOutputSink.cs +++ b/source/Calamari.Testing/Helpers/CaptureCommandInvocationOutputSink.cs @@ -92,7 +92,7 @@ void ParseServiceMessage(ServiceMessage message) var pdvRemotePath = message.GetValue(ServiceMessageNames.PackageDeltaVerification.RemotePathAttribute); DeltaError = message.GetValue(ServiceMessageNames.PackageDeltaVerification.Error); - if (pdvRemotePath != null && pdvHash != null) + if (pdvRemotePath != null && pdvHash != null && pdvSize != null) { DeltaVerification = new DeltaPackage(pdvRemotePath, pdvHash, long.Parse(pdvSize)); } diff --git a/source/Calamari.Testing/Helpers/TaskExtensionMethods.cs b/source/Calamari.Testing/Helpers/TaskExtensionMethods.cs index a7c4c365cd..6750daf55b 100644 --- a/source/Calamari.Testing/Helpers/TaskExtensionMethods.cs +++ b/source/Calamari.Testing/Helpers/TaskExtensionMethods.cs @@ -13,7 +13,7 @@ public static async Task WithCancellationToken(this Task task, CancellationToken var doerTask = task; var thrower = new TaskCompletionSource(); - using (cancellationToken.Register(tcs => ((TaskCompletionSource)tcs).SetResult(new object()), thrower)) + using (cancellationToken.Register(tcs => ((TaskCompletionSource?)tcs)?.SetResult(new object()), thrower)) { var throwerTask = thrower.Task; diff --git a/source/Calamari.Testing/Helpers/TestEnvironment.cs b/source/Calamari.Testing/Helpers/TestEnvironment.cs index a1bb3fa75d..39d537f038 100644 --- a/source/Calamari.Testing/Helpers/TestEnvironment.cs +++ b/source/Calamari.Testing/Helpers/TestEnvironment.cs @@ -6,7 +6,7 @@ namespace Calamari.Testing.Helpers public static class TestEnvironment { public static readonly string AssemblyLocalPath = typeof(TestEnvironment).Assembly.FullLocalPath(); - public static readonly string CurrentWorkingDirectory = Path.GetDirectoryName(AssemblyLocalPath); + public static readonly string CurrentWorkingDirectory = Path.GetDirectoryName(AssemblyLocalPath)!; public static readonly bool IsCI = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEAMCITY_VERSION")); @@ -18,7 +18,7 @@ public static string GetTestPath(params string[] paths) public static string ConstructRootedPath(params string[] paths) { - return Path.Combine(Path.GetPathRoot(CurrentWorkingDirectory), Path.Combine(paths)); + return Path.Combine(Path.GetPathRoot(CurrentWorkingDirectory)!, Path.Combine(paths)); } } } diff --git a/source/Calamari.Testing/LogParser/ScriptOutputFilter.cs b/source/Calamari.Testing/LogParser/ScriptOutputFilter.cs index 6924331b4d..c0d584ae56 100644 --- a/source/Calamari.Testing/LogParser/ScriptOutputFilter.cs +++ b/source/Calamari.Testing/LogParser/ScriptOutputFilter.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using Calamari.Common.Plumbing.ServiceMessages; +using Octopus.CoreUtilities.Extensions; namespace Calamari.Testing.LogParser { @@ -47,7 +48,7 @@ public bool ContainsKey(string name) public bool TryGetValue(string name, out TestOutputVariable value) { - return items.TryGetValue(name, out value); + return items.TryGetValue(name, out value!); } public TestOutputVariable this[string name] @@ -132,9 +133,9 @@ bool IsGuid(string propertyName) public string[] GetStrings(params string[] propertyNames) { var values = Properties.Where(x => propertyNames.Contains(x.Key)) - .Select(x => x.Value) - .ToList(); - if (!values.Any()) + .Select(x => x.Value) + .ToList(); + if (!Enumerable.Any(values)) { return new string[0]; } @@ -142,8 +143,9 @@ public string[] GetStrings(params string[] propertyNames) var allValues = new List(); foreach (var v in values.Where(v => !string.IsNullOrWhiteSpace(v))) { - allValues.AddRange(v.Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim())); + allValues.AddRange(v.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim())); } + return allValues.ToArray(); } } @@ -154,8 +156,8 @@ public class ScriptOutputFilter readonly ServiceMessageParser parser; readonly Action nullTarget = s => - { - }; + { + }; readonly TestOutputVariableCollection testOutputVariables = new TestOutputVariableCollection(); readonly List artifacts = new List(); @@ -204,7 +206,6 @@ public ScriptOutputFilter(CalamariInMemoryTaskLog log) public string? ResultMessage { get; private set; } - public void Write(IEnumerable output) { foreach (var line in output) @@ -291,7 +292,7 @@ void ServiceMessage(ServiceMessage serviceMessage) if (name != null) { - artifacts.Add(new CollectedArtifact(name, path) {Length = length}); + artifacts.Add(new CollectedArtifact(name, path) { Length = length }); } break; @@ -313,8 +314,14 @@ void ServiceMessage(ServiceMessage serviceMessage) var fileExtension = serviceMessage.GetValue(ScriptServiceMessageNames.FoundPackage.FileExtensionAttribute); if (id != null && version != null) { - foundPackages.Add(new FoundPackage(id, version, versionFormat, remotePath, hash, fileExtension)); + foundPackages.Add(new FoundPackage(id, + version, + versionFormat, + remotePath, + hash, + fileExtension)); } + break; case ScriptServiceMessageNames.PackageDeltaVerification.Name: @@ -322,10 +329,11 @@ void ServiceMessage(ServiceMessage serviceMessage) var deltaVerificationHash = serviceMessage.GetValue(ScriptServiceMessageNames.PackageDeltaVerification.HashAttribute); var deltaVerificationSize = serviceMessage.GetValue(ScriptServiceMessageNames.PackageDeltaVerification.SizeAttribute); DeltaPackageError = serviceMessage.GetValue(ScriptServiceMessageNames.PackageDeltaVerification.Error); - if (deltaVerificationRemotePath != null && deltaVerificationHash != null) + if (deltaVerificationRemotePath != null && deltaVerificationHash != null && deltaVerificationSize != null) { DeltaPackageVerifcation = new DeltaPackage(deltaVerificationRemotePath, deltaVerificationHash, long.Parse(deltaVerificationSize)); } + break; case ScriptServiceMessageNames.StdOutBehaviour.Default: @@ -355,6 +363,7 @@ void ServiceMessage(ServiceMessage serviceMessage) { actions.Add(new TestScriptOutputAction(serviceMessage.Name, serviceMessage.Properties)); } + break; } } @@ -366,19 +375,20 @@ public void Finish() void PopulateSupportedScriptActionNames() { - if (supportedScriptActionNames.Any()) + if (Enumerable.Any(supportedScriptActionNames)) return; var actionNames = GetAllFieldValues( - typeof(ScriptServiceMessageNames.ScriptOutputActions), - x => Attribute.IsDefined(x, typeof(ServiceMessageNameAttribute))) - .Select(x => x.ToString()); + typeof(ScriptServiceMessageNames.ScriptOutputActions), + x => Attribute.IsDefined(x, typeof(ServiceMessageNameAttribute))) + .Select(x => x?.ToString()) + .WhereNotNull(); supportedScriptActionNames.AddRange(actionNames); } - static IEnumerable GetAllFieldValues(Type t, Func filter) + static IEnumerable GetAllFieldValues(Type t, Func filter) { - var values = new List(); + var values = new List(); var fields = t.GetFields(); values.AddRange(fields.Where(filter).Select(x => x.GetValue(null))); diff --git a/source/Calamari.Testing/Requirements/RequiresAdminAttribute.cs b/source/Calamari.Testing/Requirements/RequiresAdminAttribute.cs index 0e63d26e06..2779bcdd64 100644 --- a/source/Calamari.Testing/Requirements/RequiresAdminAttribute.cs +++ b/source/Calamari.Testing/Requirements/RequiresAdminAttribute.cs @@ -9,7 +9,9 @@ public class RequiresAdminAttribute : TestAttribute, ITestAction { public void BeforeTest(ITest testDetails) { +#pragma warning disable CA1416 var isAdmin = (new WindowsPrincipal(WindowsIdentity.GetCurrent())).IsInRole(WindowsBuiltInRole.Administrator); +#pragma warning restore CA1416 if (!isAdmin) { Assert.Ignore("Requires Admin Rights"); diff --git a/source/Calamari.Testing/Requirements/RequiresDotNet45Attribute.cs b/source/Calamari.Testing/Requirements/RequiresDotNet45Attribute.cs deleted file mode 100644 index e01caa7914..0000000000 --- a/source/Calamari.Testing/Requirements/RequiresDotNet45Attribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Calamari.Common.Plumbing.Extensions; -using NUnit.Framework; -using NUnit.Framework.Interfaces; - -namespace Calamari.Testing.Requirements -{ - public class RequiresDotNet45Attribute : TestAttribute, ITestAction - { - public void BeforeTest(ITest testDetails) - { - if (!ScriptingEnvironment.IsNet45OrNewer()) - { - Assert.Ignore("Requires .NET 4.5"); - } - } - - public void AfterTest(ITest testDetails) - { - } - - public ActionTargets Targets { get; set; } - } -} \ No newline at end of file diff --git a/source/Calamari.Testing/Requirements/RequiresDotNetCoreAttribute.cs b/source/Calamari.Testing/Requirements/RequiresDotNetCoreAttribute.cs deleted file mode 100644 index 09e5c05c61..0000000000 --- a/source/Calamari.Testing/Requirements/RequiresDotNetCoreAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Interfaces; -using NUnit.Framework.Internal; - -namespace Calamari.Testing.Requirements -{ - public class RequiresDotNetCoreAttribute: NUnitAttribute, IApplyToTest - { - static bool IsNetCore() - { - #if NETCORE - return true; - #else - return false; - #endif - } - - public void ApplyToTest(Test test) - { - if (!IsNetCore()) - { - test.RunState = RunState.Skipped; - test.Properties.Set(PropertyNames.SkipReason, "Requires dotnet core"); - } - } - } -} \ No newline at end of file diff --git a/source/Calamari.Testing/TestHttpClientFactory.cs b/source/Calamari.Testing/TestHttpClientFactory.cs index 9a80a65f7c..308e57d863 100644 --- a/source/Calamari.Testing/TestHttpClientFactory.cs +++ b/source/Calamari.Testing/TestHttpClientFactory.cs @@ -1,7 +1,6 @@ using System; using System.Net.Http; -#if NETSTANDARD || NETCORE namespace Calamari.Testing; public sealed class TestHttpClientFactory : IHttpClientFactory, IDisposable @@ -17,6 +16,4 @@ public void Dispose() lazyHandler.Value.Dispose(); } } -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/source/Calamari.Tests/Calamari.Tests.csproj b/source/Calamari.Tests/Calamari.Tests.csproj index 884ba777ce..6be51d229d 100644 --- a/source/Calamari.Tests/Calamari.Tests.csproj +++ b/source/Calamari.Tests/Calamari.Tests.csproj @@ -10,22 +10,17 @@ win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 - net462;net6.0 - 8 + 10 + net6.0 true - + $(DefineConstants);NETCORE;AZURE_CORE;JAVA_SUPPORT - - $(DefineConstants);NETFX;IIS_SUPPORT;USE_NUGET_V2_LIBS;USE_OCTODIFF_EXE; - - - @@ -34,31 +29,12 @@ - - - - - - - - - - - - - - - - - - - - - + + @@ -262,40 +238,28 @@ + - - - - - - - - - - - @(ScriptCSRef->'%(ResolvedPath)')/tools/*.* - @(ScriptCSRef->'%(ResolvedPath)')/tools/*.exe - @(NuGetCommandLineRef->'%(ResolvedPath)')/tools/*.* - + + + + + + + + - - - - - + - - - - - - + + + + + + + + + diff --git a/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptFixture.cs b/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptFixture.cs index f2e6220b9b..9fc500bf9b 100644 --- a/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptFixture.cs +++ b/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptFixture.cs @@ -5,7 +5,6 @@ using Calamari.Common.Plumbing.Variables; using Calamari.Deployment; using Calamari.Testing.Helpers; -using Calamari.Testing.Requirements; using Calamari.Tests.Helpers; using FluentAssertions; using NUnit.Framework; @@ -14,11 +13,10 @@ namespace Calamari.Tests.Fixtures.DotnetScript { [TestFixture] [Category(TestCategory.ScriptingSupport.DotnetScript)] - [RequiresDotNetCore] public class DotnetScriptFixture : CalamariFixture { static readonly Dictionary RunWithDotnetScriptVariable = new Dictionary() { { ScriptVariables.UseDotnetScript, bool.TrueString } }; - + [Test] public void ShouldPrintEncodedVariable() { diff --git a/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptProxyFixture.cs b/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptProxyFixture.cs index ddae1e74d8..8e1ef942ae 100644 --- a/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptProxyFixture.cs +++ b/source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptProxyFixture.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Calamari.Common.Plumbing.Variables; using Calamari.Testing.Helpers; -using Calamari.Testing.Requirements; using Calamari.Tests.Fixtures.Integration.Proxies; using NUnit.Framework; @@ -10,7 +9,6 @@ namespace Calamari.Tests.Fixtures.DotnetScript { [TestFixture] [Category(TestCategory.ScriptingSupport.DotnetScript)] - [RequiresDotNetCore] public class DotnetScriptProxyFixture : WindowsScriptProxyFixtureBase { protected override CalamariResult RunScript() diff --git a/source/Calamari.Tests/Fixtures/Integration/Scripting/CSharpScriptEngineFixture.cs b/source/Calamari.Tests/Fixtures/Integration/Scripting/CSharpScriptEngineFixture.cs index 9b26b92b7a..585e73a7d4 100644 --- a/source/Calamari.Tests/Fixtures/Integration/Scripting/CSharpScriptEngineFixture.cs +++ b/source/Calamari.Tests/Fixtures/Integration/Scripting/CSharpScriptEngineFixture.cs @@ -6,7 +6,6 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Common.Plumbing.Variables; using Calamari.Testing.Helpers; -using Calamari.Testing.Requirements; using NSubstitute; using NUnit.Framework; @@ -16,7 +15,7 @@ namespace Calamari.Tests.Fixtures.Integration.Scripting public class CSharpScriptEngineFixture : ScriptEngineFixtureBase { [Category(TestCategory.ScriptingSupport.DotnetScript)] - [Test, RequiresDotNetCore] + [Test] public void DotnetScript_CSharpDecryptsVariables() { using (var scriptFile = new TemporaryFile(Path.ChangeExtension(Path.GetTempFileName(), "cs"))) @@ -29,17 +28,5 @@ public void DotnetScript_CSharpDecryptsVariables() result.AssertOutput("KingKong"); } } - - [Category(TestCategory.ScriptingSupport.ScriptCS)] - [Test, RequiresDotNet45] - public void ScriptCS_CSharpDecryptsVariables() - { - using (var scriptFile = new TemporaryFile(Path.ChangeExtension(Path.GetTempFileName(), "cs"))) - { - File.WriteAllText(scriptFile.FilePath, "System.Console.WriteLine(Octopus.Parameters[\"mysecrect\"]);"); - var result = ExecuteScript(new ScriptCSScriptExecutor(Substitute.For()), scriptFile.FilePath, GetVariables()); - result.AssertOutput("KingKong"); - } - } } } diff --git a/source/Calamari.Tests/Fixtures/Manifest/ExecuteManifestCommandFixture.cs b/source/Calamari.Tests/Fixtures/Manifest/ExecuteManifestCommandFixture.cs index c73fc130c8..979134dc4c 100644 --- a/source/Calamari.Tests/Fixtures/Manifest/ExecuteManifestCommandFixture.cs +++ b/source/Calamari.Tests/Fixtures/Manifest/ExecuteManifestCommandFixture.cs @@ -8,7 +8,6 @@ using Calamari.LaunchTools; using Calamari.Testing; using Calamari.Testing.Helpers; -using Calamari.Testing.Requirements; using Calamari.Tests.Helpers; using NUnit.Framework; using Octostache; @@ -16,7 +15,6 @@ namespace Calamari.Tests.Fixtures.Manifest { [TestFixture] - [RequiresDotNetCore] public class ExecuteManifestCommandFixture : CalamariFixture { [Test] diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/ScriptCSFixture.cs b/source/Calamari.Tests/Fixtures/ScriptCS/ScriptCSFixture.cs deleted file mode 100644 index c2fa046dc8..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/ScriptCSFixture.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using Calamari.Common.Features.Scripting.DotnetScript; -using Calamari.Deployment; -using Calamari.Testing.Helpers; -using Calamari.Testing.Requirements; -using Calamari.Tests.Helpers; -using FluentAssertions; -using NUnit.Framework; - -namespace Calamari.Tests.Fixtures.ScriptCS -{ - [TestFixture] - [Category(TestCategory.ScriptingSupport.ScriptCS)] - public class ScriptCSFixture : CalamariFixture - { - [Test, RequiresDotNet45] - public void ShouldPrintEncodedVariable() - { - var (output, _) = RunScript("PrintEncodedVariable.csx"); - - output.AssertSuccess(); - output.AssertOutput("##octopus[setVariable name='RG9ua2V5' value='S29uZw==']"); - } - - [Test, RequiresDotNet45] - public void ShouldPrintSensitiveVariable() - { - var (output, _) = RunScript("PrintSensitiveVariable.csx"); - - output.AssertSuccess(); - output.AssertOutput("##octopus[setVariable name='UGFzc3dvcmQ=' value='Y29ycmVjdCBob3JzZSBiYXR0ZXJ5IHN0YXBsZQ==' sensitive='VHJ1ZQ==']"); - } - - [Test, RequiresDotNet45] - public void ShouldCreateArtifact() - { - var (output, _) = RunScript("CreateArtifact.csx"); - - output.AssertSuccess(); - output.AssertOutput("##octopus[createArtifact"); - output.AssertOutput("name='bXlGaWxlLnR4dA==' length='MTAw']"); - } - - [Test, RequiresDotNet45] - public void ShouldUpdateProgress() - { - var (output, _) = RunScript("UpdateProgress.csx"); - - output.AssertSuccess(); - output.AssertOutput("##octopus[progress percentage='NTA=' message='SGFsZiBXYXk=']"); - } - - [Test, RequiresDotNet45] - public void ShouldCallHello() - { - var (output, _) = RunScript("Hello.csx", new Dictionary() - { - ["Name"] = "Paul", - ["Variable2"] = "DEF", - ["Variable3"] = "GHI", - ["Foo_bar"] = "Hello", - ["Host"] = "Never", - }); - - output.AssertSuccess(); - output.AssertOutput("Hello Paul"); - output.AssertOutput("This is ScriptCS"); - output.AssertProcessNameAndId("scriptcs"); - } - - [Test, RequiresDotNet45] - public void ShouldCallHelloWithSensitiveVariable() - { - var (output, _) = RunScript("Hello.csx", new Dictionary() - { ["Name"] = "NameToEncrypt" }, sensitiveVariablesPassword: "5XETGOgqYR2bRhlfhDruEg=="); - - output.AssertSuccess(); - output.AssertOutput("Hello NameToEncrypt"); - } - - [Test, RequiresDotNet45] - public void ShouldConsumeParametersWithQuotes() - { - var (output, _) = RunScript("Parameters.csx", new Dictionary() - { [SpecialVariables.Action.Script.ScriptParameters] = "-- \"Para meter0\" Parameter1" }); - - output.AssertSuccess(); - output.AssertOutput("Parameters Para meter0Parameter1"); - } - - [Test, RequiresDotNet45] - public void ShouldConsumeParametersWithoutParametersPrefix() - { - var (output, _) = RunScript("Parameters.csx", new Dictionary() - { [SpecialVariables.Action.Script.ScriptParameters] = "Parameter0 Parameter1" }); - - output.AssertSuccess(); - output.AssertOutput("Parameters Parameter0Parameter1"); - } - - [Test, RequiresDotNet45] - public void HasInvalidSyntax_ShowNotWriteExtraWarningLine() - { - var (output, _) = RunScript("InvalidSyntax.csx", new Dictionary()); - - output.CapturedOutput.AllMessages.Should().NotContain(DotnetScriptCompilerWarningWrapper.WarningLogLine); - //We are expecting failure - output.AssertFailure(); - } - } -} \ No newline at end of file diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/ScriptCsProxyFixture.cs b/source/Calamari.Tests/Fixtures/ScriptCS/ScriptCsProxyFixture.cs deleted file mode 100644 index cbdb4fd704..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/ScriptCsProxyFixture.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Net; -using Calamari.Testing.Helpers; -using Calamari.Tests.Fixtures.Integration.Proxies; -using Calamari.Tests.Fixtures.PowerShell; -using Calamari.Tests.Helpers; -using FluentAssertions; -using NUnit.Framework; - -namespace Calamari.Tests.Fixtures.ScriptCS -{ - [TestFixture] - [Category(TestCategory.ScriptingSupport.ScriptCS)] - public class ScriptCSProxyFixture : WindowsScriptProxyFixtureBase - { - protected override CalamariResult RunScript() - { - return RunScript("Proxy.csx").result; - } - - protected override bool TestWebRequestDefaultProxy => true; - } -} \ No newline at end of file diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/CreateArtifact.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/CreateArtifact.csx deleted file mode 100644 index ae69ed1bbf..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/CreateArtifact.csx +++ /dev/null @@ -1,9 +0,0 @@ - -using System; -using System.IO; - -System.IO.Directory.CreateDirectory("Temp"); -System.IO.File.WriteAllBytes(Path.Combine("Temp","myFile.txt"), new byte[100]); - -Octopus.CreateArtifact(Path.Combine("Temp","myFile.txt")); - diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Hello.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Hello.csx deleted file mode 100644 index 05f55fab90..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Hello.csx +++ /dev/null @@ -1,4 +0,0 @@ -using System; - -Console.WriteLine("Hello " + Octopus.Parameters["Name"]); -Console.WriteLine("This is ScriptCS") diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Parameters.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Parameters.csx deleted file mode 100644 index fbe474095e..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Parameters.csx +++ /dev/null @@ -1,3 +0,0 @@ -using System; - -Console.WriteLine("Parameters " + Env.ScriptArgs[0] + Env.ScriptArgs[1]); diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/PrintEncodedVariable.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/PrintEncodedVariable.csx deleted file mode 100644 index 2ae804ea44..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/PrintEncodedVariable.csx +++ /dev/null @@ -1,5 +0,0 @@ - -using System; - -Octopus.SetVariable("Donkey","Kong"); - diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/PrintSensitiveVariable.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/PrintSensitiveVariable.csx deleted file mode 100644 index 47444cbe64..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/PrintSensitiveVariable.csx +++ /dev/null @@ -1,4 +0,0 @@ - -using System; - -Octopus.SetVariable("Password","correct horse battery staple", true); diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Proxy.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Proxy.csx deleted file mode 100644 index dd6c610ca2..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/Proxy.csx +++ /dev/null @@ -1,26 +0,0 @@ -using System; -Console.WriteLine("HTTP_PROXY:"+Environment.GetEnvironmentVariable("HTTP_PROXY")); -Console.WriteLine("HTTPS_PROXY:"+Environment.GetEnvironmentVariable("HTTPS_PROXY")); -Console.WriteLine("NO_PROXY:"+Environment.GetEnvironmentVariable("NO_PROXY")); -if (Environment.OSVersion.Platform == PlatformID.Win32NT) -{ - var testUri = new Uri("http://octopustesturl.com"); - var octopusProxyUri = System.Net.WebRequest.DefaultWebProxy.GetProxy(testUri); - if (octopusProxyUri.Host != "octopustesturl.com") - { - Console.WriteLine("WebRequest.DefaultProxy:" + octopusProxyUri); - } - else - { - Console.WriteLine("WebRequest.DefaultProxy:None"); - } -} - -var bypassUri = Environment.GetEnvironmentVariable("TEST_ONLY_PROXY_EXCEPTION_URI"); -if (!string.IsNullOrEmpty(bypassUri)) -{ - if(System.Net.WebRequest.DefaultWebProxy.IsBypassed(new Uri(bypassUri))) - { - Console.WriteLine("ProxyBypassed:" + bypassUri); - } -} \ No newline at end of file diff --git a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/UpdateProgress.csx b/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/UpdateProgress.csx deleted file mode 100644 index 4c4ef84891..0000000000 --- a/source/Calamari.Tests/Fixtures/ScriptCS/Scripts/UpdateProgress.csx +++ /dev/null @@ -1,3 +0,0 @@ -using System; - -Octopus.UpdateProgress(50, "Half Way"); diff --git a/source/Calamari/Calamari.csproj b/source/Calamari/Calamari.csproj index 7ca25bafba..1bb2f36a91 100644 --- a/source/Calamari/Calamari.csproj +++ b/source/Calamari/Calamari.csproj @@ -18,23 +18,15 @@ Calamari win-x64;linux-x64;osx-x64;linux-arm;linux-arm64 Calamari.exe.manifest - net462;net6.0 - 8 + 10 + net6.0 CS8632 true - - $(DefineConstants);IIS_SUPPORT; - anycpu - $(DefineConstants);DEBUG - @@ -46,10 +38,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -62,22 +50,6 @@ - - - - - - - - - - - - - - - - @@ -89,10 +61,10 @@ PreserveNewest - + - +