The wrong dev tunnel is being selected
Opened this issue · 4 comments
Describe the bug
I'm using Visual Studio 2022 17.10
I have a solution that contains a .NET 8.0 API called MyProject.API
I used the Microsoft Teams app template to add a Command Bot called MyProject.ChatBot
When following the steps in TeamsApp/GettingStarted.md, it asks me to create a Dev Tunnel. When I do, it creates dev tunnels for the API project and the ChatBot project.
When I run "Prepare Teams App dependencies", it's using the DevTunnel for MyProject.API instead of MyProject.ChatBot. The .env.local file has the wrong dev tunnel on BOT_ENDPOINT. If I change this file, validation fails.
To Reproduce
- Create a new solution with a .NET 8.0 API in it. Name the project "MyProject.API"
- Add a Command Bot project to the solution. The name must alphabetically come after the API Project, so name it "MyProject.ChatBot"
- Follow the steps in TeamsApp/GettingStarted.md
- Notice that TeamsApp/env/.env.local has the wrong BOT_ENDPOINT value. It should be the dev tunnel for MyProject.ChatBot, but instead its pointing to MyProject.API.
Expected behavior
The Teams Toolkit -> Prepare Teams App Dependencies UI option should pick the dev tunnel for the ChatBot instead of assuming the first dev tunnel in the list is the correct one for BOT_ENDPOINT.
Screenshots
N/A
VS Code Extension Information (please complete the following information):
I am not using the VS Code extension. I'm using VS 2022 17.10
CLI Information (please complete the following information):
Not using the CLI, I'm using VS 2022 17.10
Additional context
I have a workaround but it's less than ideal. If I temporarily remove MyProject.API from the solution, everything works and it selects the ChatBot project's dev tunnel.
I do not know if this matters, but I also have a Blazor app called MyProject.Web and a .NET 8.0 console app called MyProject.Notifications inside the solution. These do not get dev tunnels so they should be fine.
@xiaolang124 Sorry, I should have been more clear. The issue isn't the wrong devtunnel being picked. It's that the wrong port for the wrong project is being created.
- I set the startup project as TtkDevTunnelBug.ChatBot
- I create a public persistent devtunnel, it has 0 ports
- I run "Prepare Teams App Dependencies". The DevTunnel now has 1 port, but it's to the API instead of the ChatBot.
- This incorrect devtunnel URL is written to .env.local
Here's a minimal reproduction repo. All I did was add an ASP.NET API, Blazor WebAssembly app, and the Teams Chat Command Bot. I made sure the API's name was alphabetically sorted above the Bot.
Thanks for sharing the steps to reproduce the issue. I can reproduce the bug. We will investigate this further.
There is another workaround. You can update your BOT_ENDPOINT and BOT_DOMAIN in 'env.local' to the correct values and select "None" for the dev tunnel when preparing the Teams app. Then you can select the dev tunnel and continue to debug.