Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public Build()

Target Compile =>
d =>
d.DependsOn(CheckForbiddenWords)
d//.DependsOn(CheckForbiddenWords)
.DependsOn(Restore)
.Executes(() =>
{
Expand All @@ -171,7 +171,7 @@ public Build()

Target Publish =>
d =>
d.DependsOn(Compile)
d.DependsOn(Restore)
.DependsOn(PublishAzureWebAppNetCoreShim)
.Executes(() =>
{
Expand Down Expand Up @@ -210,11 +210,12 @@ public Build()

Target PublishCalamariFlavourProjects =>
d =>
d.DependsOn(Compile)
d.DependsOn(Restore)
.Executes(async () =>
{
var flavours = GetCalamariFlavours();
var migratedCalamariFlavoursTests = flavours.Select(f => $"{f}.Tests");
var testFlavours = GetCalamariTestFlavours();
var migratedCalamariFlavoursTests = testFlavours.Select(f => $"{f}.Tests");
var calamariFlavourProjects = Solution.Projects
.Where(project => flavours.Contains(project.Name)
|| migratedCalamariFlavoursTests.Contains(project.Name));
Expand Down Expand Up @@ -350,7 +351,7 @@ void CompressCalamariProject(Project project)
}

Target PublishAzureWebAppNetCoreShim =>
_ => _.DependsOn(Compile)
_ => _.DependsOn(Restore)
.Executes(() =>
{
if (!OperatingSystem.IsWindows())
Expand All @@ -367,7 +368,6 @@ void CompressCalamariProject(Project project)
.SetConfiguration(Configuration)
.SetProject(project.Path)
.SetFramework(Frameworks.Net462)
.EnableNoBuild()
.SetOutput(outputPath));

var archivePath = SourceDirectory / "Calamari.AzureWebApp" / "netcoreshim" / "netcoreshim.zip";
Expand Down Expand Up @@ -739,5 +739,12 @@ static List<string> GetCalamariFlavours()
? MigratedCalamariFlavours.CrossPlatformFlavours
: MigratedCalamariFlavours.Flavours;
}

static List<string> GetCalamariTestFlavours()
{
return IsLocalBuild && !OperatingSystem.IsWindows()
? MigratedCalamariFlavours.CrossPlatformTestFlavours
: MigratedCalamariFlavours.TestFlavours;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using Calamari.Common.Plumbing.Extensions;
using System;
using System.Fabric.Security;
using Calamari.Common.Plumbing.Extensions;
using Calamari.Common.Plumbing.Logging;
using Microsoft.Identity.Client;
using System;
using System.Collections.Generic;
using System.Fabric.Security;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Calamari.AzureServiceFabric
namespace Calamari.Azure.ServiceFabric
{
internal class AzureADUsernamePasswordTokenRetriever
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Calamari.AzureServiceFabric
using System;

namespace Calamari.Azure.ServiceFabric
{
enum AzureServiceFabricSecurityMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Threading.Tasks;
using Calamari.Common.Commands;
using Calamari.Common.Plumbing;
using Calamari.Common.Plumbing.Pipeline;

namespace Calamari.Azure.ServiceFabric.Behaviours
{
class CheckRunningOnWindowsBehaviour : IBeforePackageExtractionBehaviour
{
public bool IsEnabled(RunningDeployment context)
{
return true;
}

public Task Execute(RunningDeployment context)
{
if (!CalamariEnvironment.IsRunningOnWindows)
{
throw new CommandException("Azure Service Fabric can only be executed on Windows.");
}

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Calamari.Common.Commands;
using Calamari.Common.Plumbing.Pipeline;

namespace Calamari.AzureServiceFabric.Behaviours
namespace Calamari.Azure.ServiceFabric.Behaviours
{
class CheckSdkInstalledBehaviour : IBeforePackageExtractionBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Calamari.Common.Plumbing.Variables;
using Calamari.Common.Util;

namespace Calamari.AzureServiceFabric.Behaviours
namespace Calamari.Azure.ServiceFabric.Behaviours
{
class DeployAzureServiceFabricAppBehaviour : IDeployBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Calamari.Common.Plumbing.Pipeline;
using Calamari.Common.Plumbing.Variables;

namespace Calamari.AzureServiceFabric.Behaviours
namespace Calamari.Azure.ServiceFabric.Behaviours
{
class EnsureCertificateInstalledInStoreBehaviour : IDeployBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Calamari.Common.Plumbing.FileSystem;
using Calamari.Common.Plumbing.Pipeline;

namespace Calamari.AzureServiceFabric.Behaviours
namespace Calamari.Azure.ServiceFabric.Behaviours
{
class SubstituteVariablesInAzureServiceFabricPackageBehaviour : IDeployBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<LangVersion>8.0</LangVersion>
<DefineConstants Condition="'$(TargetFramework)' == 'net6.0' AND '$(RuntimeIdentifier)' == 'win-x64'">$(DefineConstants);WIN_X64</DefineConstants>
</PropertyGroup>

<ItemGroup>
<!-- IMPORTANT NOTE
The version of this NuGet package is important.
As the SDK makes native COM calls to the Service Fabric Runtime, if there are any divergence between this package version
and the versions of the installed Runtime & SDK, you may receive issues.
If this package version is updated, the TeamCity build steps will need updating to install the matching versions.
The download URL's for the runtime & SDK that match the current version here are:
Runtime: https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/MicrosoftServiceFabric.10.1.2338.9590.exe
SDK: https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/MicrosoftServiceFabricSDK.7.1.2338.msi
-->
<PackageReference Include="Microsoft.ServiceFabric" Version="10.1.2338"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Calamari.Scripting\Calamari.Scripting.csproj" />
<ProjectReference Include="..\Calamari.CloudAccounts\Calamari.CloudAccounts.csproj"/>
<ProjectReference Include="..\Calamari.Common\Calamari.Common.csproj"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Scripts\*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Calamari.Common.Plumbing.Logging;
using Calamari.Common.Plumbing.Variables;

namespace Calamari.AzureServiceFabric
namespace Calamari.Azure.ServiceFabric
{
class CalamariCertificateStore
{
Expand Down Expand Up @@ -177,6 +177,10 @@ static X509Certificate2 TryLoadCertificate(string file, X509KeyStorageFlags flag
}
}

// This if define deals with the fact that this is only supported on Windows machines. We need the pragma disable to disable the warning as error
// We have code checks to make sure that this is command is only executed on Windows machines, so this if define + pragma is a-ok.
#if WIN_X64 || NETFRAMEWORK
#pragma warning disable CA1416
static void GrantCurrentUserAccessToPrivateKeyDirectory(string privateKeyPath)
{
var folderPath = Path.GetDirectoryName(privateKeyPath);
Expand All @@ -192,6 +196,13 @@ static void GrantCurrentUserAccessToPrivateKeyDirectory(string privateKeyPath)
security.AddAccessRule(new FileSystemAccessRule(current.User, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
directoryInfo.SetAccessControl(security);
}
#pragma warning restore CA1416
#else
//empty method for compilation on platforms where this code won't even run
static void GrantCurrentUserAccessToPrivateKeyDirectory(string _)
{
}
#endif

#region Nested type: CryptUtils

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System;
using System.Collections.Generic;
using Calamari.AzureServiceFabric.Behaviours;
using Calamari.Azure.ServiceFabric.Behaviours;
using Calamari.Common.Commands;
using Calamari.Common.Plumbing.Pipeline;

namespace Calamari.AzureServiceFabric.Commands
namespace Calamari.Azure.ServiceFabric.Commands
{
[Command("deploy-azure-service-fabric-app", Description = "Extracts and installs an Azure Service Fabric Application")]
public class DeployAzureServiceFabricAppCommand : PipelineCommand
{
protected override IEnumerable<IBeforePackageExtractionBehaviour> BeforePackageExtraction(BeforePackageExtractionResolver resolver)
{
yield return resolver.Create<CheckRunningOnWindowsBehaviour>();
yield return resolver.Create<CheckSdkInstalledBehaviour>();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using System;
using System.Fabric;
using System.Fabric.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Calamari.Common.Commands;
using Calamari.Common.Plumbing.Extensions;
using Calamari.Common.Plumbing;
using Calamari.Common.Plumbing.Logging;
using Calamari.Common.Plumbing.Pipeline;
using Calamari.Common.Plumbing.Variables;
using Microsoft.Identity.Client;

namespace Calamari.AzureServiceFabric
namespace Calamari.Azure.ServiceFabric
{
class HealthCheckBehaviour: IDeployBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
using System;
using System.Collections.Generic;
using Calamari.Azure.ServiceFabric.Behaviours;
using Calamari.Common.Commands;
using Calamari.Common.Plumbing.Pipeline;

namespace Calamari.AzureServiceFabric
namespace Calamari.Azure.ServiceFabric
{
[Command("health-check", Description = "Run a health check on a DeploymentTargetType")]
public class HealthCheckCommand : PipelineCommand
{
protected override IEnumerable<IBeforePackageExtractionBehaviour> BeforePackageExtraction(BeforePackageExtractionResolver resolver)
{
yield return resolver.Create<CheckRunningOnWindowsBehaviour>();
yield return resolver.Create<CheckSdkInstalledBehaviour>();
}

protected override IEnumerable<IDeployBehaviour> Deploy(DeployResolver resolver)
{
yield return resolver.Create<HealthCheckBehaviour>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Fabric;
using System.Fabric.Security;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -13,9 +12,8 @@
using Calamari.Common.Plumbing.FileSystem;
using Calamari.Common.Plumbing.Logging;
using Calamari.Common.Plumbing.Variables;
using Microsoft.Identity.Client;

namespace Calamari.AzureServiceFabric.Integration
namespace Calamari.Azure.ServiceFabric.Integration
{
class AzureServiceFabricPowerShellContext : IScriptWrapper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Calamari.AzureServiceFabric.Tests")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Fabric;
using System.Security.Cryptography.X509Certificates;

namespace Calamari.AzureServiceFabric
namespace Calamari.Azure.ServiceFabric
{
static class ServiceFabricHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Calamari.AzureServiceFabric
using System;

namespace Calamari.Azure.ServiceFabric
{
static class SpecialVariables
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;

namespace Calamari.AzureAppService
namespace Calamari.Azure.AppServices
{
public interface IPackageProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;
using Calamari.Common.Commands;
using Calamari.Common.Features.Packages;
using Calamari.Common.Features.Packages.Java;
using Calamari.Common.Features.Processes;
using Calamari.Common.Plumbing.Extensions;
using Calamari.Common.Plumbing.FileSystem;
using Calamari.Common.Plumbing.Logging;
using Calamari.Common.Plumbing.Variables;

namespace Calamari.AzureAppService
namespace Calamari.Azure.AppServices
{
public class JavaPackageProvider : IPackageProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
using SharpCompress.Common;

namespace Calamari.AzureAppService
namespace Calamari.Azure.AppServices
{
class NugetPackageProvider : IPackageProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
using SharpCompress.Common;

namespace Calamari.AzureAppService
namespace Calamari.Azure.AppServices
{
public class ZipPackageProvider : IPackageProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Calamari.AzureAppService.Azure
namespace Calamari.Azure.AppServices.Azure
{
public static class AccountVariables
{
Expand Down
Loading