-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch --runtime value to linux-x64 #112
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using Amazon.Common.DotNetCli.Tools; | ||
using System.Linq; | ||
|
||
namespace Amazon.Lambda.Tools | ||
{ | ||
|
@@ -81,7 +82,9 @@ public int Store(LambdaToolsDefaults defaults, string projectLocation, string ou | |
} | ||
|
||
arguments.Append($" --manifest \"{fullPackageManifest}\""); | ||
arguments.Append($" --runtime {LambdaConstants.RUNTIME_HIERARCHY_STARTING_POINT}"); | ||
|
||
|
||
arguments.Append($" --runtime {LambdaUtilities.DetermineRuntimeParameter(targetFramework)}"); | ||
|
||
if(!enableOptimization) | ||
{ | ||
|
@@ -207,23 +210,38 @@ public int Publish(LambdaToolsDefaults defaults, string projectLocation, string | |
{ | ||
arguments.Append(" /p:GenerateRuntimeConfigurationFiles=true"); | ||
|
||
// If you set the runtime to RUNTIME_HIERARCHY_STARTING_POINT it will trim out the Windows and Mac OS specific dependencies but Razor view precompilation | ||
// will not run. So only do this packaging optimization if there are no Razor views. | ||
if (Directory.GetFiles(fullProjectLocation, "*.cshtml", SearchOption.AllDirectories).Length == 0) | ||
if (new string[] { "netcoreapp2.0", "netcoreapp2.1" }.Contains(targetFramework)) | ||
{ | ||
arguments.Append($" -r {LambdaConstants.RUNTIME_HIERARCHY_STARTING_POINT}"); | ||
if(Directory.GetFiles(fullProjectLocation, "*.cshtml", SearchOption.AllDirectories).Length == 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we still have this, the comment reason that got deleted still seems important (With slight modifications). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comment |
||
{ | ||
arguments.Append($" -r {LambdaConstants.LEGACY_RUNTIME_HIERARCHY_STARTING_POINT}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could do You can also consider moving the common configurations for both You can disregard this if you think it is more readable like this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to call LambdaUtilities.DetermineRuntimeParameter and put the setting of runtime and self contained in a shared Action. |
||
|
||
if (msbuildParameters == null || | ||
msbuildParameters.IndexOf("--self-contained", StringComparison.InvariantCultureIgnoreCase) == -1) | ||
{ | ||
arguments.Append(" --self-contained false "); | ||
} | ||
|
||
if (string.IsNullOrEmpty(msbuildParameters) || | ||
!msbuildParameters.Contains("PreserveCompilationContext")) | ||
{ | ||
_logger?.WriteLine("... Disabling compilation context to reduce package size. If compilation context is needed pass in the \"/p:PreserveCompilationContext=false\" switch."); | ||
arguments.Append(" /p:PreserveCompilationContext=false"); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
if (msbuildParameters == null || | ||
msbuildParameters.IndexOf("--self-contained", StringComparison.InvariantCultureIgnoreCase) == -1) | ||
msbuildParameters.IndexOf("--runtime", StringComparison.InvariantCultureIgnoreCase) == -1) | ||
{ | ||
arguments.Append(" --self-contained false "); | ||
arguments.Append($" -r {LambdaUtilities.DetermineRuntimeParameter(targetFramework)}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe --runtime and -r are the same. Should probably pick one. Also this seems like it could end up duplicating the same thing already added always on line 87. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Standardized on --runtime |
||
} | ||
|
||
if (string.IsNullOrEmpty(msbuildParameters) || | ||
!msbuildParameters.Contains("PreserveCompilationContext")) | ||
if (msbuildParameters == null || | ||
msbuildParameters.IndexOf("--self-contained", StringComparison.InvariantCultureIgnoreCase) == -1) | ||
{ | ||
_logger?.WriteLine("... Disabling compilation context to reduce package size. If compilation context is needed pass in the \"/p:PreserveCompilationContext=false\" switch."); | ||
arguments.Append(" /p:PreserveCompilationContext=false"); | ||
arguments.Append(" --self-contained false "); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you comment on why this is different for "netcoreapp2.0" and "netcoreapp2.1"? Why you don't need
p:PreserveCompilationContext
for other targets? Also why you don't need to check for Razor views for other targets?Also this comment was useful, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment