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
107 stars 29 forks source link

Working directory not found when starting AWS Mock Lambda Test Tool using Visual Studio 2022 and launchSettings reverted #448

Open tauheedul opened 2 months ago

tauheedul commented 2 months ago

Description

Visual Studio 2022 displays the following error message while attempting to launch an existing AWS Lambda project using either .NET 6 or .NET 8.

"The working directory 'C:\{directory}\bin\net8.0' specified in the 'Mock Lambda Test Tool' debug profile does not exist"

Additionally the Visual Studio Amazon Web Services output window presents the following information.

"Some Toolkit components could not be initialized. Some functionality may not work during this IDE session."

Temporary fixes

However if you restart Visual Studio the problem is repeated.

Workaround but not ideal fix

The error suggests that when a Visual Studio 2022 lambda project is loaded the $(Configuration) project variable is empty or not initialized.

Then the Mock Lambda Test Tool is trying to load it's runtime from the following output directory by default \bin\net8.0\

However when the $(Configuration) variable is initialised by either the extension or Visual Studio it correctly uses \bin\Debug\net8.0\

My workaround is to hard code the configuration working directory variable, but this is not ideal as this is always reverted unless the file is made uneditable by unticking the write file permissions in windows explorer.

When the test utility is launched, it automatically reverts the launchSettings file to default.

Changes Remove the $(Configuration) variable and make the file uneditable.

  1. Update Properties\\launchSettings.json "Working directory" value:

.\\bin\\$(Configuration)\\net8.0 => .\\bin\\Debug\\net8.0

  1. Then open launchSettings.json file properties in windows explorer and select file permissions for the current user and untick write permissions. This will stop the AWS Toolkit extension for Visual Studio 2022 from reverting the launchSettings.json file back to default settings.

image

To Reproduce

This error is only encountered on an existing project using Visual Studio 2022 (AWS Toolkit 1.55.0.0) with .NET 6 / .NET 8

image

Show output from: Amazon Web Services output window image

There is no error using Visual Studio 2019 (AWS Toolkit 1.55.0.0) with .NET Core 3.1

Expected behavior

"The working directory 'C:\{directory}\bin\net8.0' specified in the 'Mock Lambda Test Tool' debug profile does not exist"

Toolkit Logs

Development System

Additional context

Manually reinstalling the test tool did not resolve the issue

dotnet tool uninstall --global Amazon.Lambda.TestTool-8.0
dotnet tool install --global Amazon.Lambda.TestTool-8.0 --version 0.15.2

This same issue is replicated in .NET 6

https://developercommunity.visualstudio.com/t/Visual-Studio-2022-Professional-automati/10691564?

rodion-andreev-d8 commented 1 month ago

Same issue