Skip to content

Commit

Permalink
Merge pull request #1248 from OfficeDev/v-hrajandira/CsharpNewToolkitPR2
Browse files Browse the repository at this point in the history
PR 3 - Implement New toolkit version csharp samples
  • Loading branch information
Harikrishnan-MSFT authored May 30, 2024
2 parents cd6cf6d + b4f2e4f commit 2dbb917
Show file tree
Hide file tree
Showing 71 changed files with 453 additions and 263 deletions.
2 changes: 1 addition & 1 deletion samples/bot-file-upload/csharp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TeamsFx files
build
AppManifest/build
appPackage/build
env/.env.*.user
env/.env.local
appsettings.Development.json
Expand Down
31 changes: 8 additions & 23 deletions samples/bot-file-upload/csharp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
{
"profiles": {
// Debug project within Teams
"Microsoft Teams (browser)": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "https://teams.microsoft.com/l/app/%TEAMSAPPID%?installAppPackage=true&webjoin=true&appTenantId=%TENANTID%&login_hint=%USERNAME%",
"applicationUrl": "http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"hotReloadProfile": "aspnetcore"
"Start Project": {
"commandName": "Project",
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7130;http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"hotReloadProfile": "aspnetcore"
}
//// Uncomment following profile to debug project only (without launching Teams)
//,
//"Start Project (not in Teams)": {
// "commandName": "Project",
// "dotnetRunMessages": true,
// "launchBrowser": true,
// "applicationUrl": "https://localhost:7130;http://localhost:5130",
// "environmentVariables": {
// "ASPNETCORE_ENVIRONMENT": "Development"
// },
// "hotReloadProfile": "aspnetcore"
//}
}
}
9 changes: 5 additions & 4 deletions samples/bot-file-upload/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can
## Run the app (Using Teams Toolkit for Visual Studio)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio.
1. Install Visual Studio 2022 **Version 17.9 or higher** [Visual Studio](https://visualstudio.microsoft.com/downloads/)
1. Install Visual Studio 2022 **Version 17.10 Preview 4 or higher** [Visual Studio](https://visualstudio.microsoft.com/downloads/)
1. Install Teams Toolkit for Visual Studio [Teams Toolkit extension](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)
1. In the debug dropdown menu of Visual Studio, select Dev Tunnels > Create A Tunnel (set authentication type to Public) or select an existing public dev tunnel.
1. In Visual Studio, right-click your project and **Select Teams Toolkit > Prepare Teams App Dependencies**
1. In the debug dropdown menu of Visual Studio, select default startup project > **Microsoft Teams (browser)**
1. In Visual Studio, right-click your **TeamsApp** project and **Select Teams Toolkit > Prepare Teams App Dependencies**
1. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
1. Select **Debug > Start Debugging** or **F5** to run the menu in Visual Studio.
1. In the browser that launches, select the **Add** button to install the app to Teams.
Expand Down Expand Up @@ -99,9 +100,9 @@ the Teams service needs to call into the bot.
1) Run your bot, either from Visual Studio with `F5` or using `dotnet run` in the appropriate folder.

1) __*This step is specific to Teams.*__
- **Edit** the `manifest.json` contained in the `AppManifest` folder to replace your Microsoft App Id (that was created when you registered your bot earlier) *everywhere* you see the place holder string `<<YOUR-MICROSOFT-APP-ID>>` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` contained in the `appPackage` folder to replace your Microsoft App Id (that was created when you registered your bot earlier) *everywhere* you see the place holder string `<<YOUR-MICROSOFT-APP-ID>>` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` for `validDomains` with base Url domain. E.g. if you are using ngrok it would be `https://1234.ngrok-free.app` then your domain-name will be `1234.ngrok-free.app` and if you are using dev tunnels then your domain will be like: `12345.devtunnels.ms`.
- **Zip** up the contents of the `AppManifest` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Zip** up the contents of the `appPackage` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Upload** the `manifest.zip` to Teams (In Teams Apps/Manage your apps click "Upload an app". Browse to and Open the .zip file. At the next dialog, click the Add button.)
- Add the app to personal scope (Supported app scope)
Expand Down
9 changes: 9 additions & 0 deletions samples/bot-file-upload/csharp/TeamsApp/TeamsApp.ttkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.TeamsFx.Sdk">
<PropertyGroup Label="Globals">
<ProjectGuid>c7fd0e24-2254-4184-bf12-6c75d2752f28</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ APP_NAME_SUFFIX=local
# Generated during provision, you can also add your own variables.
BOT_ID=
TEAMS_APP_ID=
TEAMSFX_M365_USER_NAME=

BOT_ENDPOINT=
BOT_DOMAIN=

RESOURCE_SUFFIX=
AAD_APP_CLIENT_ID=
AAD_APP_OBJECT_ID=
Expand All @@ -20,4 +15,13 @@ AAD_APP_OAUTH_AUTHORITY=
AAD_APP_OAUTH_AUTHORITY_HOST=
TEAMS_APP_TENANT_ID=
MICROSOFT_APP_TYPE=
MICROSOFT_APP_TENANT_ID=
MICROSOFT_APP_TENANT_ID=
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP_NAME=



TEAMSFX_M365_USER_NAME=

BOT_ENDPOINT=
BOT_DOMAIN=
9 changes: 9 additions & 0 deletions samples/bot-file-upload/csharp/TeamsApp/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
// Debug project within Teams
"Microsoft Teams (browser)": {
"commandName": "Project",
"launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ provision:
# Generate runtime appsettings to JSON file
- uses: file/createOrUpdateJsonFile
with:
target: ./appsettings.json
target: ../appsettings.json
content:
MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
Expand All @@ -61,41 +61,25 @@ provision:
- uses: teamsApp/validateManifest
with:
# Path to manifest template
manifestPath: ./AppManifest/manifest.json
manifestPath: ./appPackage/manifest.json

# Build Teams app package with latest env value
- uses: teamsApp/zipAppPackage
with:
# Path to manifest template
manifestPath: ./AppManifest/manifest.json
outputZipPath: ./AppManifest/build/AppManifest.${{TEAMSFX_ENV}}.zip
outputJsonPath: ./AppManifest/build/manifest.${{TEAMSFX_ENV}}.json
manifestPath: ./appPackage/manifest.json
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
outputJsonPath: ./appPackage/build/manifest.${{TEAMSFX_ENV}}.json
# Validate app package using validation rules
- uses: teamsApp/validateAppPackage
with:
# Relative path to this file. This is the path for built zip file.
appPackagePath: ./AppManifest/build/AppManifest.${{TEAMSFX_ENV}}.zip
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip

# Apply the Teams app manifest to an existing Teams app in
# Teams Developer Portal.
# Will use the app id in manifest file to determine which Teams app to update.
- uses: teamsApp/update
with:
# Relative path to this file. This is the path for built zip file.
appPackagePath: ./AppManifest/build/AppManifest.${{TEAMSFX_ENV}}.zip

# Create or update debug profile in lauchsettings file
- uses: file/createOrUpdateJsonFile
with:
target: ./Properties/launchSettings.json
content:
profiles:
Microsoft Teams (browser):
commandName: "Project"
dotnetRunMessages: true
launchBrowser: true
launchUrl: "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}"
applicationUrl: "http://localhost:5130"
environmentVariables:
ASPNETCORE_ENVIRONMENT: "Development"
hotReloadProfile: "aspnetcore"
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
File renamed without changes.
7 changes: 7 additions & 0 deletions samples/bot-file-upload/csharp/TeamsFileUpload.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<Compile Remove="TeamsApp\**" />
<Content Remove="TeamsApp\**" />
<EmbeddedResource Remove="TeamsApp\**" />
<None Remove="TeamsApp\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.11" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.18.1" />
Expand Down
11 changes: 11 additions & 0 deletions samples/bot-file-upload/csharp/TeamsFileUpload.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamsFileUpload", "TeamsFileUpload.csproj", "{446A5BE5-CDE7-485C-8E4B-21C5BC32300B}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{C7FD0E24-2254-4184-BF12-6C75D2752F28}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36AC51F0-88F5-4548-977B-A201316B8F84}"
ProjectSection(SolutionItems) = preProject
TeamsFileUpload.slnLaunch.user = TeamsFileUpload.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +22,10 @@ Global
{446A5BE5-CDE7-485C-8E4B-21C5BC32300B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{446A5BE5-CDE7-485C-8E4B-21C5BC32300B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{446A5BE5-CDE7-485C-8E4B-21C5BC32300B}.Release|Any CPU.Build.0 = Release|Any CPU
{C7FD0E24-2254-4184-BF12-6C75D2752F28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7FD0E24-2254-4184-BF12-6C75D2752F28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7FD0E24-2254-4184-BF12-6C75D2752F28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7FD0E24-2254-4184-BF12-6C75D2752F28}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
17 changes: 17 additions & 0 deletions samples/bot-file-upload/csharp/TeamsFileUpload.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "TeamsFileUpload.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft Teams (browser)"
}
]
}
]
11 changes: 6 additions & 5 deletions samples/tab-conversations/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can
## Run the app (Using Teams Toolkit for Visual Studio)

The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio.
1. Install Visual Studio 2022 **Version 17.8 or higher** [Visual Studio](https://visualstudio.microsoft.com/downloads/)
1. Install Visual Studio 2022 **Version 17.10 Preview 4 or higher** [Visual Studio](https://visualstudio.microsoft.com/downloads/)
1. Install Teams Toolkit for Visual Studio [Teams Toolkit extension](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)
1. In Visual Studio, right-click your project and **Select Teams Toolkit > Prepare Teams App Dependencies**
1. In the debug dropdown menu of Visual Studio, select default startup project > **Microsoft Teams (browser)**
1. In Visual Studio, right-click your **TeamsApp** project and **Select Teams Toolkit > Prepare Teams App Dependencies**
1. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps.
1. Select **Debug > Start Debugging** or **F5** to run the menu in Visual Studio.
1. In the browser that launches, select the **Add** button to install the app to Teams.
Expand Down Expand Up @@ -92,14 +93,14 @@ The simplest way to run this sample in Teams is to use Teams Toolkit for Visual

4. Setup Manifest for Teams
- __*This step is specific to Teams.*__
- **Edit** the `manifest.json` contained in the ./AppManifest folder to replace your Microsoft App Id (that was created when you registered your app registration earlier) *everywhere* you see the place holder string `{{Microsoft-App-Id}}` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` contained in the ./appPackage folder to replace your Microsoft App Id (that was created when you registered your app registration earlier) *everywhere* you see the place holder string `{{Microsoft-App-Id}}` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` for `validDomains` and replace `{{domain-name}}` with base Url of your domain. E.g. if you are using ngrok it would be `https://1234.ngrok-free.app` then your domain-name will be `1234.ngrok-free.app` and if you are using dev tunnels then your domain will be like: `12345.devtunnels.ms`.
- **Zip** up the contents of the `AppManifest` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Zip** up the contents of the `appPackage` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)

- Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
- Go to Microsoft Teams. From the lower left corner, select Apps
- From the lower left corner, choose Upload a custom App
- Go to your project directory, the ./AppManifest folder, select the zip folder, and choose Open.
- Go to your project directory, the ./appPackage folder, select the zip folder, and choose Open.
- Select Add in the pop-up dialog box. Your app is uploaded to Teams.

## Running the sample
Expand Down
17 changes: 14 additions & 3 deletions samples/tab-conversations/csharp/TabConversation.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
# Visual Studio Version 17
VisualStudioVersion = 17.10.34814.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TabConversation", "TabConversation\TabConversation.csproj", "{801722A2-02B1-4A1E-9639-4358D5D87D98}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TabConversation", "TabConversation\TabConversation.csproj", "{801722A2-02B1-4A1E-9639-4358D5D87D98}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{696F2F0A-C3AA-4FF8-8D35-98A5F4CE4960}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3EB8E93C-B90F-4921-9826-F80C58F428B9}"
ProjectSection(SolutionItems) = preProject
TabConversation.slnLaunch.user = TabConversation.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +22,10 @@ Global
{801722A2-02B1-4A1E-9639-4358D5D87D98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{801722A2-02B1-4A1E-9639-4358D5D87D98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{801722A2-02B1-4A1E-9639-4358D5D87D98}.Release|Any CPU.Build.0 = Release|Any CPU
{696F2F0A-C3AA-4FF8-8D35-98A5F4CE4960}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{696F2F0A-C3AA-4FF8-8D35-98A5F4CE4960}.Debug|Any CPU.Build.0 = Debug|Any CPU
{696F2F0A-C3AA-4FF8-8D35-98A5F4CE4960}.Release|Any CPU.ActiveCfg = Release|Any CPU
{696F2F0A-C3AA-4FF8-8D35-98A5F4CE4960}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
17 changes: 17 additions & 0 deletions samples/tab-conversations/csharp/TabConversation.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "TabConversation\\TabConversation.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft Teams (browser)"
}
]
}
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TeamsFx files
build
AppManifest/build
appPackage/build
env/.env.*.user
env/.env.local
appsettings.Development.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
{
"profiles": {
// Debug project within Teams
"Microsoft Teams (browser)": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "https://teams.microsoft.com/l/app/294d0749-3209-4cfe-9f85-2d0c99684e8d?installAppPackage=true&webjoin=true&appTenantId=72f988bf-86f1-41af-91ab-2d7cd011db47&[email protected]",
"applicationUrl": "https://localhost:44302;http://localhost:2544",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"hotReloadProfile": "aspnetcore"
"Start Project": {
"commandName": "Project",
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:44302;http://localhost:2544",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"hotReloadProfile": "aspnetcore"
}
//// Uncomment following profile to debug project only (without launching Teams)
//,
//"Start Project (not in Teams)": {
// "commandName": "Project",
// "dotnetRunMessages": true,
// "launchBrowser": true,
// "applicationUrl": "https://localhost:44302;http://localhost:2544",
// "environmentVariables": {
// "ASPNETCORE_ENVIRONMENT": "Development"
// },
// "hotReloadProfile": "aspnetcore"
//}
}
}
9 changes: 9 additions & 0 deletions samples/tab-conversations/csharp/TeamsApp/TeamsApp.ttkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.TeamsFx.Sdk">
<PropertyGroup Label="Globals">
<ProjectGuid>696f2f0a-c3aa-4ff8-8d35-98a5f4ce4960</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.12/MicrosoftTeams.schema.json",
"manifestVersion": "1.12",
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.0",
"id": "${{TEAMS_APP_ID}}",
"packageName": "com.microsoft.tabconversations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ TAB_ENDPOINT=
APP_NAME_SUFFIX=
TAB_DOMAIN=
TEAMS_APP_TENANT_ID=



TEAMSFX_M365_USER_NAME=
Loading

0 comments on commit 2dbb917

Please sign in to comment.