Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR 11 - Implement New toolkit version csharp samples #1317

Merged
merged 16 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions .github/workflows/build-complete-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ jobs:
- project_path: 'samples/app-HR-talent/csharp/src/TeamsTalentMgmtAppV6.csproj'
name: 'app-HR-talent'
version: '6.0.x'

- project_path: 'samples/app-complete-sample/csharp/AppCompleteSample/AppCompleteSample.csproj'
name: 'app-complete-sample'
version: '6.0.x'

fail-fast: false
name: Build All "${{ matrix.name }}" csharp
Expand All @@ -486,33 +490,6 @@ jobs:
- name: Build app
run: dotnet build "${{ matrix.project_path }}" --configuration Release

build-dotnet-samples:
runs-on: windows-latest
#Add project path, name as below for any new additions
strategy:
matrix:
include:
- project_path: 'samples/app-complete-sample/csharp/AppCompleteSample.sln'
name: 'app-complete-sample'

fail-fast: false
name: Build "${{ matrix.name }}" csharp
steps:
- uses: actions/checkout@v2

- name: Setup MSBuild path
uses: microsoft/setup-msbuild@v1.0.2

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5

- name: Restore NuGet packages
run: nuget restore ${{ matrix.project_path }}

- name: Build
run: msbuild ${{ matrix.project_path }} /p:Configuration=Release


build-nodejs-samples:
runs-on: windows-latest
#Add project path, name and version as below for any new additions
Expand Down
15 changes: 13 additions & 2 deletions samples/app-complete-auth/csharp/AppCompleteAuth.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@

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.35004.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppCompleteAuth", "AppCompleteAuth\AppCompleteAuth.csproj", "{BEE3FB6B-5F07-491F-9669-23B0C1CA4A30}"
EndProject
Project("{A9E3F50B-275E-4AF7-ADCE-8BE12D41E305}") = "TeamsApp", "TeamsApp\TeamsApp.ttkproj", "{FE9B3CEB-680A-4700-B38F-9D9FC3D84F90}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{34241478-2412-4A04-BF42-1EC53D208D33}"
ProjectSection(SolutionItems) = preProject
AppCompleteAuth.slnLaunch.user = AppCompleteAuth.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +22,10 @@ Global
{BEE3FB6B-5F07-491F-9669-23B0C1CA4A30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEE3FB6B-5F07-491F-9669-23B0C1CA4A30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEE3FB6B-5F07-491F-9669-23B0C1CA4A30}.Release|Any CPU.Build.0 = Release|Any CPU
{FE9B3CEB-680A-4700-B38F-9D9FC3D84F90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE9B3CEB-680A-4700-B38F-9D9FC3D84F90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE9B3CEB-680A-4700-B38F-9D9FC3D84F90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE9B3CEB-680A-4700-B38F-9D9FC3D84F90}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
32 changes: 32 additions & 0 deletions samples/app-complete-auth/csharp/AppCompleteAuth.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "AppCompleteAuth\\AppCompleteAuth.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft Teams (browser)"
}
]
},
{
"Name": "Outlook (browser)",
"Projects": [
{
"Path": "AppCompleteAuth\\AppCompleteAuth.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Outlook (browser)"
}
]
}
]
25 changes: 25 additions & 0 deletions samples/app-complete-auth/csharp/AppCompleteAuth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TeamsFx files
build
appPackage/build
env/.env.*.user
env/.env.local
appsettings.Development.json
.deployment

# User-specific files
*.user

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Notification local store
.notification.localstore.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:3978",
"sslPort": 0
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"EchoBot": {
"Start Project": {
"commandName": "Project",
"launchBrowser": true,
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7130;http://localhost:5130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:3978"
"hotReloadProfile": "aspnetcore"
}
}
}
21 changes: 18 additions & 3 deletions samples/app-complete-auth/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can

- [Teams](https://teams.microsoft.com) Microsoft Teams is installed and you have an account

- [Teams Toolkit for Visual Studio](https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/toolkit-v4/install-teams-toolkit-vs?pivots=visual-studio-v17-7)

## 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.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 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.
> If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.

## Setup

### Register you app with Azure AD.
Expand Down Expand Up @@ -158,18 +173,18 @@ Please find below demo manifest which is deployed on Microsoft Azure and you can

### 4. Setup Manifest for Teams

1. Modify the `manifest.json` in the `/AppManifest` folder and replace the following details:
1. Modify the `manifest.json` in the `/appPackage` folder and replace the following details:
- `{{Microsoft-App-Id}}` with Application id generated from Step 3
- `{Base_URL_Domain}` - Your application's base url domain. E.g. for https://12345.ngrok-free.app the base url domain will be 12345.ngrok-free.app if you are using ngrok and if you are using dev tunnels then your domain will be like: `12345.devtunnels.ms`.

**Note:** If you want to test your app across multi hub like: Outlook/Office.com, please update the `manifest.json` in the `app-complete-auth\csharp\AppCompleteAuth\AppManifest_Hub` folder with the required values.

2. Zip up the contents of the `AppManifest` folder to create a `manifest.zip` or `AppManifest_Hub` folder into a `AppManifest_Hub.zip`. (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
2. Zip up the contents of the `appPackage` folder to create a `manifest.zip` or `AppManifest_Hub` folder into a `AppManifest_Hub.zip`. (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)

3. Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
- Go to Microsoft Teams and then go to side panel, select Apps
- 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.

**Note**: To test facebook auth flow please setup the sample locally as due to limitations from facebook you cannot test the facebook auth flow in the deployed version of app.
Expand Down
9 changes: 9 additions & 0 deletions samples/app-complete-auth/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>fe9b3ceb-680a-4700-b38f-9d9fc3d84f90</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
111 changes: 111 additions & 0 deletions samples/app-complete-auth/csharp/TeamsApp/aad.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"id": "${{AAD_APP_OBJECT_ID}}",
"appId": "${{AAD_APP_CLIENT_ID}}",
"name": "app-complete-auth-aad",
"accessTokenAcceptedVersion": 2,
"signInAudience": "AzureADMultipleOrgs",
"oauth2AllowIdTokenImplicitFlow": true,
"oauth2AllowImplicitFlow": true,
"optionalClaims": {
"idToken": [],
"accessToken": [
{
"name": "idtyp",
"source": null,
"essential": false,
"additionalProperties": []
}
],
"saml2Token": []
},
"requiredResourceAccess": [
{
"resourceAppId": "Microsoft Graph",
"resourceAccess": [
{
"id": "User.Read",
"type": "Scope"
}
]
}
],
"oauth2Permissions": [
{
"adminConsentDescription": "Allows Teams to call the app's web APIs as the current user.",
"adminConsentDisplayName": "Teams can access app's web APIs",
"id": "${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}",
"isEnabled": true,
"type": "User",
"userConsentDescription": "Enable Teams to call this app's web APIs with the same rights that you have",
"userConsentDisplayName": "Teams can access app's web APIs and make requests on your behalf",
"value": "access_as_user"
}
],
"preAuthorizedApplications": [
{
"appId": "1fec8e78-bce4-4aaf-ab1b-5451cc387264",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "5e3ce6c0-2b1f-4285-8d4b-75ee78787346",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "d3590ed6-52b3-4102-aeff-aad2292ab01c",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "00000002-0000-0ff1-ce00-000000000000",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "bc59ab01-8403-45c6-8796-ac3ef710b3e3",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "0ec893e0-5785-4de6-99da-4ed124e5296c",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "4765445b-32c6-49b0-83e6-1d93765276ca",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
},
{
"appId": "4345a7b9-9a63-4910-a426-35363201d503",
"permissionIds": [
"${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
]
}
],
"identifierUris": [
"api://${{BOT_DOMAIN}}/botid-${{AAD_APP_CLIENT_ID}}"
],
"replyUrlsWithType": [
{
"url": "${{BOT_ENDPOINT}}/auth-end",
"type": "Spa"
},
{
"url": "${{BOT_ENDPOINT}}/auth-start",
"type": "Spa"
},
{
"url": "https://token.botframework.com/.auth/web/redirect",
"type": "Web"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.0",
"id": "{{Microsoft-App-Id}}",
"id": "${{TEAMS_APP_ID}}",
"packageName": "com.microsoft.teams.appcompleteauth",
"webApplicationInfo": {
"id": "{{Microsoft-App-Id}}",
"resource": "api://{Base_URL_Domain}/botid-{{Microsoft-App-Id}}"
"id": "${{AAD_APP_CLIENT_ID}}",
"resource": "api://${{BOT_DOMAIN}}/botid-${{AAD_APP_CLIENT_ID}}"
},
"developer": {
"name": "Microsoft",
Expand All @@ -29,7 +29,7 @@
"accentColor": "#FFFFFF",
"staticTabs": [
{
"contentUrl": "https://{Base_URL_Domain}/tab",
"contentUrl": "https://${{BOT_DOMAIN}}/tab",
"entityId": "Auth",
"name": "Auth",
"scopes": [
Expand All @@ -39,7 +39,7 @@
],
"bots": [
{
"botId": "{{Microsoft-App-Id}}",
"botId": "${{AAD_APP_CLIENT_ID}}",
"scopes": [
"personal"
],
Expand Down Expand Up @@ -68,7 +68,7 @@
],
"composeExtensions": [
{
"botId": "{{Microsoft-App-Id}}",
"botId": "${{AAD_APP_CLIENT_ID}}",
"canUpdateConfiguration": true,
"commands": [
{
Expand Down Expand Up @@ -132,7 +132,7 @@
"value": {
"domains": [
"*.botframework.com",
"{Base_URL_Domain}"
"${{BOT_DOMAIN}}"
]
}
}
Expand All @@ -145,6 +145,6 @@
],
"validDomains": [
"token.botframework.com",
"{Base_URL_Domain}"
"${{BOT_DOMAIN}}"
]
}
Loading
Loading