-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,25 +210,48 @@ 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) | ||
// Define an action to set the runtime and self-contained switches. | ||
var applyRuntimeSwitchAction = (Action)(() => | ||
{ | ||
arguments.Append($" -r {LambdaConstants.RUNTIME_HIERARCHY_STARTING_POINT}"); | ||
if (msbuildParameters == null || | ||
msbuildParameters.IndexOf("--runtime", StringComparison.InvariantCultureIgnoreCase) == -1) | ||
{ | ||
arguments.Append($" --runtime {LambdaUtilities.DetermineRuntimeParameter(targetFramework)}"); | ||
} | ||
|
||
if (msbuildParameters == null || | ||
msbuildParameters.IndexOf("--self-contained", StringComparison.InvariantCultureIgnoreCase) == -1) | ||
{ | ||
arguments.Append(" --self-contained false "); | ||
} | ||
|
||
if (string.IsNullOrEmpty(msbuildParameters) || | ||
!msbuildParameters.Contains("PreserveCompilationContext")) | ||
}); | ||
|
||
// This is here to not change existing behavior for the 2.0 and 2.1 runtimes. For those runtimes if | ||
// cshtml files are being used we need to support that cshtml being compiled at runtime. In order to do that we | ||
// need to not turn PreserveCompilationContext which provides reference assemblies to the runtime | ||
// compilation and not set a runtime. | ||
// | ||
// If there are no cshtml then disable PreserveCompilationContext to reduce package size and continue | ||
// to use the same runtime identifier that we used when those runtimes were launched. | ||
if (new string[] { "netcoreapp2.0", "netcoreapp2.1" }.Contains(targetFramework)) | ||
{ | ||
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 |
||
{ | ||
_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"); | ||
applyRuntimeSwitchAction(); | ||
|
||
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 | ||
{ | ||
applyRuntimeSwitchAction(); | ||
} | ||
|
||
// If we have a manifest of packages already deploy in target deployment environment then write it to disk and add the | ||
// command line switch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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