aws / aws-toolkit-visual-studio

AWS Toolkit for Visual Studio - a plugin to interact with AWS
https://aws.amazon.com/visualstudio/
Apache License 2.0
108 stars 29 forks source link

AWS Lambda Function and Microsoft.Data.SqlClient and Mock Lambda Tool #112

Open genifycom opened 4 years ago

genifycom commented 4 years ago

Visual Studio Version 16.6.4 DotNet version 3.1.302

Step 1: Create a Lambda function empty. Step 2: Debug using the Mock lambda tool. All is well. Step 3: Add nuget package Microsoft.Data.SqlClient (no code was added) Step 4: Debugging produces:

AWS .NET Core 3.1 Mock Lambda Test Tool (0.10.0) Unknown error occurred causing process exit: Dependency resolution failed for component C:\Dev\SourceControl\Development\Test\AWSLambda1\bin\Debug\netcoreapp3.1\AWSLambda1.dll with error code -2147450740. Detailed error: Error: An assembly specified in the application dependencies manifest (AWSLambda1.deps.json) was not found: package: 'Microsoft.Data.SqlClient.SNI.runtime', version: '2.0.0' path: 'runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll'

at System.Runtime.Loader.AssemblyDependencyResolver..ctor(String componentAssemblyPath) at Amazon.Lambda.TestTool.Runtime.LambdaAssemblyLoadContext..ctor(String lambdaPath) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LambdaAssemblyLoadContext.cs:line 28 at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String directory, IAWSService awsService) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 71 at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String directory) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 46 at Amazon.Lambda.TestTool.TestToolStartup.Startup(String productName, Action`2 uiStartup, String[] args, RunConfiguration runConfiguration) in C:\codebuild\tmp\output\src142363207\src\Tools\LambdaTestTool\src\Amazon.Lambda.TestTool\TestToolStartup.cs:line 77

rli commented 4 years ago

Hi, this looks a bit like the issue you cut last month -- https://github.com/aws/aws-toolkit-visual-studio/issues/100

Does modifying your .csproj file fix the problem?

genifycom commented 4 years ago

Here is the current csproj

`

netcoreapp3.1 true Lambda

`

rli commented 4 years ago

As with the previous issue, the addition of <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> into the PropertyGroup section of the .csproj should allow the Mock Lambda Tool to find that dependency

genifycom commented 4 years ago

Fantastic. Thank you. It works now. Will this be included in future templates automatically?