Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions .autover/changes/a4b5c0a2-7029-491b-90d1-12bba898c249.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "Amazon.ElasticBeanstalk.Tools",
"Type": "Patch",
"ChangelogMessages": [
"Fixed an ElasticBeanstalk deployment issue for Linux platform where Procfile was sometimes being generated with incorrect entrypoint when multiple runtimeconfig.json files were present."
]
}
]
}
12 changes: 12 additions & 0 deletions src/Amazon.Common.DotNetCli.Tools/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ public static string LookupTargetFrameworkFromProjectFile(string projectLocation
return null;
}

/// <summary>
/// Looks up the assembly name from a project file.
/// </summary>
/// <param name="projectLocation">The location of the project file.</param>
/// <param name="msBuildParameters">Additonal MSBuild paramteres passed by the user from the commandline</param>
/// <returns>The assembly name of the project.</returns>
public static string LookupAssemblyNameFromProjectFile(string projectLocation, string msBuildParameters)
{
var properties = LookupProjectProperties(projectLocation, msBuildParameters, "AssemblyName");
return properties.TryGetValue("AssemblyName", out var assemblyName) ? assemblyName : null;
}

/// <summary>
/// Retrieve the `OutputType` property of a given project
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected override async Task<bool> PerformActionAsync()
}

this.Logger?.WriteLine("Configuring application bundle for a Linux deployment");
EBUtilities.SetupPackageForLinux(this.Logger, this, this.DeployEnvironmentOptions, publishLocation, proxyServer, applicationPort);
EBUtilities.SetupPackageForLinux(this.Logger, this, this.DeployEnvironmentOptions, publishLocation, proxyServer, applicationPort, projectLocation);
}

zipArchivePath = Path.Combine(Directory.GetParent(publishLocation).FullName, new DirectoryInfo(projectLocation).Name + "-" + DateTime.Now.Ticks + ".zip");
Expand Down
15 changes: 7 additions & 8 deletions src/Amazon.ElasticBeanstalk.Tools/EBUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Runtime.CompilerServices;
using Amazon.Common.DotNetCli.Tools;
using Amazon.Common.DotNetCli.Tools.Options;
using Amazon.ElasticBeanstalk.Model;
using Amazon.ElasticBeanstalk.Tools.Commands;
using ThirdParty.Json.LitJson;
Expand Down Expand Up @@ -109,25 +110,23 @@ public static bool IsLoadBalancedEnvironmentType(string environmentType)
}


public static void SetupPackageForLinux(IToolLogger logger, EBBaseCommand command, DeployEnvironmentProperties options, string publishLocation, string reverseProxy, int? applicationPort)
public static void SetupPackageForLinux(IToolLogger logger, EBBaseCommand command, DeployEnvironmentProperties options, string publishLocation, string reverseProxy, int? applicationPort, string projectLocation)
{
// Setup Procfile
var procfilePath = Path.Combine(publishLocation, "Procfile");

if(File.Exists(procfilePath))
if (File.Exists(procfilePath))
{
logger?.WriteLine("Found existing Procfile file found and using that for deployment");
return;
}

logger?.WriteLine("Writing Procfile for deployment bundle");

var runtimeConfigFilePath = Directory.GetFiles(publishLocation, "*.runtimeconfig.json").FirstOrDefault();
var runtimeConfigFileName = Path.GetFileName(runtimeConfigFilePath);
var executingAssembly = runtimeConfigFileName.Substring(0, runtimeConfigFileName.Length - "runtimeconfig.json".Length - 1);
var executingAssembly = Utilities.LookupAssemblyNameFromProjectFile(projectLocation, null);
var runtimeConfigFilePath = Directory.GetFiles(publishLocation, $"{executingAssembly}.runtimeconfig.json").FirstOrDefault();

string webCommandLine;
if(IsSelfContainedPublish(runtimeConfigFilePath))
if (IsSelfContainedPublish(runtimeConfigFilePath))
{
webCommandLine = $"./{executingAssembly}";
}
Expand All @@ -136,7 +135,7 @@ public static void SetupPackageForLinux(IToolLogger logger, EBBaseCommand comman
webCommandLine = $"dotnet exec ./{executingAssembly}.dll";
}

if(string.Equals(reverseProxy, EBConstants.PROXY_SERVER_NONE, StringComparison.InvariantCulture))
if (string.Equals(reverseProxy, EBConstants.PROXY_SERVER_NONE, StringComparison.InvariantCulture))
{
logger?.WriteLine("... Proxy server disabled, configuring Kestrel to listen to traffic from all hosts");
var port = applicationPort.HasValue ? applicationPort.Value : EBConstants.DEFAULT_APPLICATION_PORT;
Expand Down