-
Notifications
You must be signed in to change notification settings - Fork 148
Add support for .NET Core build #80
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
Conversation
Unzip package zip file Update DESIGN.md
-dvc | --disable-version-check Disable the .NET Core version check. Only for advanced usage. | ||
``` | ||
|
||
Currently **--framework** is the only required parameter which tells the underlying build process what version of .NET Core to build for. |
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.
How is this infomation passed in? is it decided by the builder based on the runtime?
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.
For most users --framework will be already set in the aws-lambda-tools-defaults.json file so they won't have to do anything. If it is not set then the user would need to specify it on the sam build command line which would get passed into the builder. I tried to follow the examples I saw in the other builders for grabbing options that were passed on the commandline.
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.
So this is currently not supported in SAM CLI, although the correct plumbing exists thru options
property. See #4
How big of a requirement is this? Do you know the fraction of users that use parameters vs .json file to pass this value?
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.
It is not big requirement since the framework will most likely be set through the *.json file. It is a good thing to have for the future. As long as the code is doing it in the way SAM envisions this being handled in the future is all that I require now. We should make sure SAM init version of a .NET Core project includes the json file like all of the rest of our .NET tooling does.
I also might update the Amazon.Lambda.Tools to auto detect the framework based on the project file. If/when I do this work SAM build would pull that change in automatically due to the nature of this PR always updating the version of Amazon.Lambda.Tools.
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.
Yeah, in the future when we add add sam build --debug
mode, we would want to pass this over to lambda-builders, and the dotnet workflow to pick it up as the configuration.
This would also yield a conversation on which is higher priority, the flag or the information in the json config file.
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.
The existing Amazon.Lambda.Tools .NET Core Global tool that this wraps around already has the rule that if a value is specified in the command line it overrides any setting in the json file. I would expect that rule to apply from sam build as well.
The tool is installed by executing the command `dotnet tool install -g Amazon.Lambda.Tools` This will install the | ||
tool from [NuGet](https://www.nuget.org/packages/Amazon.Lambda.Tools/) the .NET package management system. | ||
|
||
To keep the tool updated the command `dotnet tool update -g Amazon.Lambda.Tools` will be executed if the install |
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.
Nice!
|
||
#### Output | ||
|
||
The output of `dotnet lambda package` command is a zip archive that consumers can then deploy to Lambda. For SAM build |
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.
Yes, this is a requirement mainly stemming from the ability to customize the zip file later during package. See this discussion - #69 (comment)
-dvc | --disable-version-check Disable the .NET Core version check. Only for advanced usage. | ||
``` | ||
|
||
Currently **--framework** is the only required parameter which tells the underlying build process what version of .NET Core to build for. |
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.
So this is currently not supported in SAM CLI, although the correct plumbing exists thru options
property. See #4
How big of a requirement is this? Do you know the fraction of users that use parameters vs .json file to pass this value?
class GlobalToolInstallAction(BaseAction): | ||
|
||
""" | ||
A Lambda Builder Action which runs bundle install in order to build a full Gemfile.lock |
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.
docstring update
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.
Updated
|
||
class RunPackageAction(BaseAction): | ||
""" | ||
A Lambda Builder Action which vendors dependencies to the vendor/bundle directory. |
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.
docstring update
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.
Updated
|
||
def execute(self): | ||
try: | ||
LOG.debug("Running bundle install --deployment in %s", self.source_dir) |
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.
log statement needs update
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.
Updated
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, | ||
source_dir, | ||
runtime=self.runtime, | ||
options={"--framework": "netcoreapp2.1", "--configuration": "Debug"}) |
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.
we currently need a way to support args support in aws-sam-cli, i.e flags passed to sam build
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.
Is it fine to leave this hear till sam build adds support for passing args?
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.
Yeah think thats fine.
""" | ||
NAME = "DotnetCliPackageBuilder" | ||
|
||
CAPABILITY = Capability(language="dotnet", |
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.
Do we need to add resolver and validator for the executables used by the workflow?
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.
Do you have an example of what you mean?
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.
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.
I added a resolver to make sure the dotnet CLI is installed.
A validator is not needed because the dotnet CLI has its own built in versioning system to match the available installed .NET SDK with the selected project. A validator would just duplicate that work and possibly get in the way.
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.
changes to travis might be required to get the tests to pass on linux, to install dotnet executable beforehand.
I see windows is passing! woohoo 💯 , we may still need some more test coverage to get the overall gate to pass though after installing dotnet on the travis boxes.
-dvc | --disable-version-check Disable the .NET Core version check. Only for advanced usage. | ||
``` | ||
|
||
Currently **--framework** is the only required parameter which tells the underlying build process what version of .NET Core to build for. |
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.
Yeah, in the future when we add add sam build --debug
mode, we would want to pass this over to lambda-builders, and the dotnet workflow to pick it up as the configuration.
This would also yield a conversation on which is higher priority, the flag or the information in the json config file.
This looks good to me! All gates pass. Just a follow up question, do we need a test with any tough to build dependencies in the builder? |
# The package command contains lots of useful information on how the package was created and | ||
# information when the package command was not successful. For that reason the output is | ||
# always written to the output to help developers diagnose issues. | ||
sys.stdout.write(out.decode('utf8').strip()) |
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.
Also can we write this to Logs instead?
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.
Are logs written to stdout by default during SAM build? I want users to see that information.
Closing in favor of a new clean branch |
* Add support for java21 * fix black formatting * update gha to use java 21 * add missing java 21 testing projects * use gradle-8.4 for java21 --------- Co-authored-by: Mohamed ElAsmar <[email protected]>
* Add support for java21 * fix black formatting * update gha to use java 21 * add missing java 21 testing projects * use gradle-8.4 for java21 --------- Co-authored-by: Mohamed ElAsmar <[email protected]>
Description of changes:
Add support for building .NET Core Lambda function as part of SAM build.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.