diff --git a/Tools/LambdaTestTool/README.md b/Tools/LambdaTestTool/README.md index 55b760e32..b0ac7f918 100644 --- a/Tools/LambdaTestTool/README.md +++ b/Tools/LambdaTestTool/README.md @@ -83,6 +83,7 @@ using the commandline switches as described below. To switch to the no web inter These options are valid for either mode the Lambda test tool is running in. --path <directory> The path to the lambda project to execute. If not set then the current directory will be used. + --print-tool-path <vs|vscode|other> Printing the .NET Lambda Test Tool location path to be inserted in the IDE." These options are valid when using the web interface to select and execute the Lambda code. @@ -157,6 +158,12 @@ Before using Visual Studio Code you must follow the instructions above on instal To debug with Visual Studio Code and the .NET Mock Lambda Test Tool edit the [launch.json](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) configuration file and have the `program` property point to `dotnet-lambda-test-tool-3.1.exe` and make sure `cwd` is pointing the .NET Core Lambda project. Note that on a non-windows environment the executable will be called `dotnet-lambda-test-tool-3.1` without the ".exe" at the end. The `dotnet-lambda-test-tool-3.1.exe` executable can be found in the `.dotnet/tools` directory under your home directory. Depending on your file system settings, the `.dotnet` directory can appear hidden. +**Note:** to make it easier to find the location of a tool, you can call it with the arguments `--print-tool-path` and copy the resulting path into the IDE. + +``` +dotnet lambda-test-tool-3.1 --print-tool-path vscode +``` + ```json { "version": "0.2.0", @@ -195,6 +202,12 @@ The path to the .NET Core 3.1 entry assembly is: /.dotnet/tools/.store/amazon.lambda.testtool-3.1//amazon.lambda.testtool-3.1//tools/netcoreapp3.1/any/Amazon.Lambda.TestTool.WebTester31.dll ``` +**Note:** to make it easier to find the location of a tool, you can call it with the arguments `--print-tool-path` and +copy the resulting path into the IDE. + +``` +dotnet lambda-test-tool-3.1 --print-tool-path other +``` Remember when you update your version of the .NET Mock Lambda Test Tool to update the nuget versions numbers in this path string for your IDE's configuration. @@ -223,6 +236,13 @@ The path to the .NET Core 3.1 entry assembly is: /.dotnet/tools/.store/amazon.lambda.testtool-3.1//amazon.lambda.testtool-3.1//tools/netcoreapp3.1/any/Amazon.Lambda.TestTool.WebTester31.dll ``` +**Note:** to make it easier to find the location of a tool, you can call it with the arguments `--print-tool-path` and +copy the resulting path into the IDE. + +``` +dotnet lambda-test-tool-3.1 --print-tool-path other +``` + Remember when you update your version of the .NET Mock Lambda Test Tool to update the nuget versions numbers in this path string for your IDE's configuration. Follow these steps to configure Visual Studio for Mac: diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/CommandLineOptions.cs b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/CommandLineOptions.cs index dba2ab350..0a8475989 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/CommandLineOptions.cs +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/CommandLineOptions.cs @@ -26,6 +26,8 @@ public class CommandLineOptions public bool ShowHelp { get; set; } + public string PrintToolPathIde { get; set; } + public bool PauseExit { get; set; } = true; public static CommandLineOptions Parse(string[] args) @@ -43,6 +45,11 @@ public static CommandLineOptions Parse(string[] args) { i++; } + break; + case "--print-tool-path": + options.PrintToolPathIde = GetNextStringValue(i); + i++; + break; case "--host": options.Host = GetNextStringValue(i); @@ -145,6 +152,7 @@ public static void PrintUsage() Console.WriteLine("These options are valid for either mode the Lambda test tool is running in."); Console.WriteLine(); Console.WriteLine("\t--path The path to the lambda project to execute. If not set then the current directory will be used."); + Console.WriteLine("\t--print-tool-path Printing the .NET Lambda Test Tool location path to be inserted in the IDE."); Console.WriteLine(); Console.WriteLine("These options are valid when using the web interface to select and execute the Lambda code."); diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/TestToolStartup.cs b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/TestToolStartup.cs index 6080f7b95..eded603dd 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/TestToolStartup.cs +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/TestToolStartup.cs @@ -42,6 +42,12 @@ public static void Startup(string productName, Action return; } + if (!string.IsNullOrEmpty(commandOptions.PrintToolPathIde)) + { + Console.WriteLine(Utils.GetToolPath(commandOptions.PrintToolPathIde)); + return; + } + var localLambdaOptions = new LocalLambdaOptions() { Host = commandOptions.Host, diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Utils.cs b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Utils.cs index bb6f5f2e8..885f9a289 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Utils.cs +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Utils.cs @@ -241,5 +241,21 @@ public static string SearchLatestCompilationDirectory(string debugDirectory) return depsFile[0].Directory.FullName; } + + /// + /// Return tool path compatible with specific IDE for debug purposes + /// + /// + /// + public static string GetToolPath(string ideName) + { + ideName = ideName.Trim().ToLower(); + if (ideName == "vs" || ideName == "vscode") + { + return Process.GetCurrentProcess().MainModule!.FileName; + } + + return Assembly.GetEntryAssembly()!.Location; + } } }