Skip to content

Commit

Permalink
Merge pull request #1247 from OfficeDev/v-hrajandira/CsharpNewToolkitPR1
Browse files Browse the repository at this point in the history
PR 2 - Implement New toolkit version csharp samples
  • Loading branch information
Harikrishnan-MSFT authored May 30, 2024
2 parents 2dbb917 + ef5e097 commit 123d328
Show file tree
Hide file tree
Showing 74 changed files with 394 additions and 306 deletions.
2 changes: 1 addition & 1 deletion samples/bot-conversation/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-conversation/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"
//}
}
}
11 changes: 6 additions & 5 deletions samples/bot-conversation/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,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 Preview 2 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,10 +100,10 @@ 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 `TeamsAppManifest` 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`, replace `<<domain-name>>` 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 `TeamsAppManifest` 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.)
- **Zip** up the contents of the `appPackage` folder to create a `appPackage.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
- **Upload** the `appPackage.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/team/groupChat scope (Supported scopes)
**Note**: If you are facing any issue in your app, please uncomment [this](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-conversation/csharp/AdapterWithErrorHandler.cs#L25) line and put your debugger for local debug.
Expand Down
9 changes: 9 additions & 0 deletions samples/bot-conversation/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>42a0237c-30e0-42ae-b6ed-50f318517e77</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ AAD_APP_OAUTH_AUTHORITY_HOST=
TEAMS_APP_TENANT_ID=
MICROSOFT_APP_TYPE=
MICROSOFT_APP_TENANT_ID=
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP_NAME=
TEAMSFX_M365_USER_NAME=

BOT_ENDPOINT=
Expand Down
9 changes: 9 additions & 0 deletions samples/bot-conversation/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
5 changes: 0 additions & 5 deletions samples/bot-conversation/csharp/TeamsConversationBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectCapability Include="TeamsFx" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions samples/bot-conversation/csharp/TeamsConversationBot.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}") = "TeamsConversationBot", "TeamsConversationBot.csproj", "{76D60C04-94EB-4042-B141-C2C0FACBDE94}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{42A0237C-30E0-42AE-B6ED-50F318517E77}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A69BE64C-7866-4F9A-99AC-3D7B6A3BA20D}"
ProjectSection(SolutionItems) = preProject
TeamsConversationBot.slnLaunch.user = TeamsConversationBot.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +22,10 @@ Global
{76D60C04-94EB-4042-B141-C2C0FACBDE94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76D60C04-94EB-4042-B141-C2C0FACBDE94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76D60C04-94EB-4042-B141-C2C0FACBDE94}.Release|Any CPU.Build.0 = Release|Any CPU
{42A0237C-30E0-42AE-B6ED-50F318517E77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42A0237C-30E0-42AE-B6ED-50F318517E77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42A0237C-30E0-42AE-B6ED-50F318517E77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42A0237C-30E0-42AE-B6ED-50F318517E77}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "TeamsConversationBot.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft Teams (browser)"
}
]
}
]
2 changes: 1 addition & 1 deletion samples/tab-channel-group/mvc-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
20 changes: 8 additions & 12 deletions samples/tab-channel-group/mvc-csharp/ChannelGroupTabMVC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<PropertyGroup>
<PostBuildEvent>powershell.exe Compress-Archive -Path \"$(ProjectDir)AppManifest\*\" -DestinationPath \"$(TargetDir)Tab.zip\" -Force</PostBuildEvent>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="AppManifest\manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<Compile Remove="appPackage\**" />
<Compile Remove="TeamsApp\**" />
<Content Remove="appPackage\**" />
<Content Remove="TeamsApp\**" />
<EmbeddedResource Remove="appPackage\**" />
<EmbeddedResource Remove="TeamsApp\**" />
<None Remove="appPackage\**" />
<None Remove="TeamsApp\**" />
</ItemGroup>

<ItemGroup>
<ProjectCapability Include="TeamsFx" />
</ItemGroup>

</Project>
17 changes: 14 additions & 3 deletions samples/tab-channel-group/mvc-csharp/ChannelGroupTabMVC.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.29102.190
# Visual Studio Version 17
VisualStudioVersion = 17.10.34814.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChannelGroupTabMVC", "ChannelGroupTabMVC.csproj", "{56BDBCF4-B35C-43E1-91E0-3661ABF63E84}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChannelGroupTabMVC", "ChannelGroupTabMVC.csproj", "{56BDBCF4-B35C-43E1-91E0-3661ABF63E84}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{EC07A694-79E6-4A5B-9824-4C87A1CB45D6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{161A6D4A-F626-47CF-B936-AF70734829E4}"
ProjectSection(SolutionItems) = preProject
ChannelGroupTabMVC.slnLaunch.user = ChannelGroupTabMVC.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +22,10 @@ Global
{56BDBCF4-B35C-43E1-91E0-3661ABF63E84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56BDBCF4-B35C-43E1-91E0-3661ABF63E84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56BDBCF4-B35C-43E1-91E0-3661ABF63E84}.Release|Any CPU.Build.0 = Release|Any CPU
{EC07A694-79E6-4A5B-9824-4C87A1CB45D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC07A694-79E6-4A5B-9824-4C87A1CB45D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC07A694-79E6-4A5B-9824-4C87A1CB45D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC07A694-79E6-4A5B-9824-4C87A1CB45D6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "ChannelGroupTabMVC.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,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": "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: 5 additions & 4 deletions samples/tab-channel-group/mvc-csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ In this quickstart we'll walk-through creating a custom channel/group tab with A
## 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 @@ -79,15 +80,15 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can
- Navigate to ```samples\tab-channel-group\mvc-csharp``` folder
- Select ```ChannelGroupTabMVC.sln``` file and open the solution

4. Modify the `manifest.json` in the `/AppManifest` folder and replace the following details:
4. Modify the `manifest.json` in the `/appPackage` folder and replace the following details:
- `<<Guid>>` with any random GUID.
- `<<Base-url>>` 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`.
- `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`.

5. 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.


## Running the sample
Expand Down
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>ec07a694-79e6-4a5b-9824-4c87a1cb45d6</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ TEAMSFX_ENV=local
TEAMS_APP_ID=
TAB_ENDPOINT=

TEAMSFX_M365_USER_NAME=

APP_NAME_SUFFIX=
TAB_DOMAIN=
TEAMS_APP_TENANT_ID=
TEAMS_APP_TENANT_ID=
TEAMSFX_M365_USER_NAME=
Loading

0 comments on commit 123d328

Please sign in to comment.