Aws-lambda-dotnet: dotnet-lambda package needs a --no-restore option

Created on 13 Feb 2018  路  5Comments  路  Source: aws/aws-lambda-dotnet

The dotnet lambda package (and by extension, this could apply to any other dotnet-lambda command that runs dotnet publish under the hood) could benefit from a --no-restore option that would be passed to the dotnet publish command.

Since 2.0, build and publish commands run a restore implicitly, so the dotnet team added a --no-restore flag for scenarios where you do not want an implicit restore. This is a really important functionality for CI scenarios where we are restoring from an internal Nuget repository and need to have control of package sources at build time. A typical CI build in this scenario would look like this:

dotnet restore -s https://private-nuget-repository.myorg.com
dotnet lambda package --no-restore
guidance

Most helpful comment

With the 2.1.0 version of Amazon.Lambda.Tools you can use the --msbuild-parameters switch to pass arguments to the dotnet publish command. So you can run

dotnet lambda package --msbuild-parameters "--no-restore"

All 5 comments

With the 2.1.0 version of Amazon.Lambda.Tools you can use the --msbuild-parameters switch to pass arguments to the dotnet publish command. So you can run

dotnet lambda package --msbuild-parameters "--no-restore"

@normj thanks for the information! Was this actually documented anywhere? Because I did try and look for different options that were available but I did not find anything in the CLI help or in this repository's readme files - so I would love to know if I missed something entirely, or if this is an opportunity to improve the documentation.

This was done just recently for another GitHub issue. https://github.com/aws/aws-lambda-dotnet/issues/210

If you do dotnet lambda help package you can see the switch

> dotnet lambda help package                                                                                                          
AWS Lambda Tools for .NET Core functions (2.1.1)                                                                                      
Project Home: https://github.com/aws/aws-lambda-dotnet                                                                                

package:                                                                                                                              
   Command to package a Lambda project into a zip file ready for deployment                                                           

   dotnet lambda package [arguments] [options]                                                                                        
   Arguments:                                                                                                                         
      <ZIP-FILE> The name of the zip file to package the project into                                                                 
   Options:                                                                                                                           
      -pl    | --project-location             The location of the project, if not set the current directory will be assumed           
      -c     | --configuration                Configuration to build with, for example Release or Debug (Default Value: Release)      
      -f     | --framework                    Target framework to compile, for example netcoreapp2.0 (Default Value: netcoreapp2.0)   
      --msbuild-parameters                    Additional msbuild parameters passed to the 'dotnet publish' command                    
      -o     | --output-package               The output zip file name                                                                
      -dvc   | --disable-version-check        Disable the .NET Core version check. Only for advanced usage.                           
 C:\temp\NoPublish\src\NoPublish                                                                                                      
>                                                                                                                                     

Admittedly it was added to pass in msbuild parameters but the --no-restore switch works as well. Maybe I should have named it something different.

Another thing to follow is the RELEASE.CHANGELOG.md which you can see on the release last week was when the switch was introduced.

@normj ah you're a life-saver.

The documentation should be updated to specify how the build parameter argument should constructed. I didn't put quote marks around mine and didn't know why it was failing. No doco on AWS website, and wasn't sure from tool help. Solution was found here.

Good call out about reminding people to quote the value.

Was this page helpful?
0 / 5 - 0 ratings