Muokkaa

Jaa


Debug your Microsoft Teams app locally using Microsoft Visual Studio

Visual Studio allows you to debug tabs, bots, and message extensions. You can debug your app locally in Visual Studio using Microsoft Teams Toolkit by performing:

Set up dev tunnel (Only for bot and message extension)

In the debug dropdown menu:

  1. Select Dev Tunnels.

  2. If you have already an existing dev tunnel, select the existing tunnel from the list. For example, in the following image PublicDevTunnel is an existing dev tunnel.

  3. If you haven't created a tunnel, select Create a Tunnel.... A new window appears.

    Screenshot shows the dev tunnel for debug option.

  4. Enter the name of the dev tunnel and under Access select Public from the dropdown.

  5. Select OK.

Set up your Teams Toolkit

To debug your app after you create a project, perform the following steps:

  1. Right-click on your project.

  2. Select Teams Toolkit > Prepare Teams App Dependencies.

    Screenshot shows the local debug teams app dependencies.

    Note

    In this scenario the project name is MyTeamsApp1.

    Your Microsoft 365 account needs to have the custom app upload permission before you sign in. Ensure that your Teams app can be uploaded to the tenant, otherwise your Teams app can fail to run in Teams Client.

  3. Sign in to your Microsoft 365 Account and then select Continue.

    Screenshot shows sign in to Microsoft 365 account.

    Note

    Learn more about the custom app upload permission, see prepare your Microsoft 365 tenant.

  4. Select Debug > Start Debugging or select F5.

    Screenshot shows start debugging.

    Visual Studio launches the Teams app inside Microsoft Teams client in your browser. For more information, see Teams Toolkit Overview.

  5. Select Add to install your app in Teams.

    Screenshot of the app details dialog with the option to add the app in Teams.

  6. Select Open to open the app in personal scope.

    Alternatively, you can either search and select the required scope or select a channel or chat from the list, and move through the dialog to select Go.

    Screenshot of the scope selection dialog with the list of shared scopes.

    You can also use the hot reload function of Visual Studio during debug. For more information, see .NET hot reload.

    Note

    When you debug a notification bot app, ensure that you post HTTP request to http://localhost:5130/api/notification in order to trigger notification. If you've selected HTTP trigger when creating the project, you can use any API tools such as, cURL (Windows Command Prompt), Postman, or any other API tool.

    Before you try to run the Teams app locally, if you make any changes to the app manifest (previously called Teams app manifest) file /appPackage/manifest.json, ensure that you perform the Prepare Teams App Dependencies command.

Next step

See also