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 1 - Implement New toolkit version csharp samples. #1238

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion samples/tab-personal/mvc-csharp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# TeamsFx files
build
AppManifest/build
env/.env.*.user
env/.env.local
appsettings.Development.json
Expand Down
17 changes: 5 additions & 12 deletions samples/tab-personal/mvc-csharp/PersonalTabMVC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
</ItemGroup>

<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="TeamsApp\**" />
<Content Remove="TeamsApp\**" />
<EmbeddedResource Remove="TeamsApp\**" />
<None Remove="TeamsApp\**" />
</ItemGroup>

<ItemGroup>
<ProjectCapability Include="TeamsFx" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
</ItemGroup>

</Project>
17 changes: 14 additions & 3 deletions samples/tab-personal/mvc-csharp/PersonalTabMVC.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}") = "PersonalTabMVC", "PersonalTabMVC.csproj", "{7A669C36-AFDE-4E7B-9492-DDBF27355289}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersonalTabMVC", "PersonalTabMVC.csproj", "{7A669C36-AFDE-4E7B-9492-DDBF27355289}"
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", "{A507D705-ACCA-4083-8CB9-B252FEC3694D}"
ProjectSection(SolutionItems) = preProject
PersonalTabMVC.slnLaunch.user = PersonalTabMVC.slnLaunch.user
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +22,10 @@ Global
{7A669C36-AFDE-4E7B-9492-DDBF27355289}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A669C36-AFDE-4E7B-9492-DDBF27355289}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A669C36-AFDE-4E7B-9492-DDBF27355289}.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
47 changes: 47 additions & 0 deletions samples/tab-personal/mvc-csharp/PersonalTabMVC.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"Name": "Microsoft Teams (browser)",
"Projects": [
{
"Path": "PersonalTabMVC.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft Teams (browser)"
}
]
},
{
"Name": "Microsoft 365 app (browser)",
"Projects": [
{
"Path": "PersonalTabMVC.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Microsoft 365 app (browser)"
}
]
},
{
"Name": "Outlook (browser)",
"Projects": [
{
"Path": "PersonalTabMVC.csproj",
"Action": "Start",
"DebugTarget": "Start Project"
},
{
"Path": "TeamsApp\\TeamsApp.ttkproj",
"Action": "StartWithoutDebugging",
"DebugTarget": "Outlook (browser)"
}
]
}
]
31 changes: 8 additions & 23 deletions samples/tab-personal/mvc-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": "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"
//}
}
}
4 changes: 2 additions & 2 deletions samples/tab-personal/mvc-csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ The simplest way to run this sample in Teams is to use Teams Toolkit for Visual
- Navigate to ```samples\tab-personal\mvc-csharp``` folder
- Select ```PersonalTabMVC.sln``` file and open the solution

4. Modify the `manifest.json` in the `/AppManifest` or `/Manifest_Hub` folder and replace the following details:
4. Modify the `manifest.json` in the `/appPackage` or `/Manifest_Hub` 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 or ./Manifest_Hub folder, select the zip folder, and choose Open.
- Go to your project directory, the ./appPackage or ./Manifest_Hub folder, select the zip folder, and choose Open.

**Note:** If you want to test your app across multi hub like: Outlook/Office.com, please update the `manifest.json` in the `/Manifest_Hub` folder with the required values.

Expand Down
14 changes: 14 additions & 0 deletions samples/tab-personal/mvc-csharp/TeamsApp/TeamsApp.ttkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>
<None Include="appPackage\color.png" />
<None Include="appPackage\manifest.json" />
<None Include="appPackage\outline.png" />
Harikrishnan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ TAB_ENDPOINT=
APP_NAME_SUFFIX=
TAB_DOMAIN=
TEAMS_APP_TENANT_ID=
TEAMSFX_M365_USER_NAME=

TEAMSFX_M365_USER_NAME=

M365_TITLE_ID=
M365_APP_ID=
17 changes: 17 additions & 0 deletions samples/tab-personal/mvc-csharp/TeamsApp/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"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}}"
},
"Microsoft 365 app (browser)": {
"commandName": "Project",
"launchUrl": "https://www.office.com/m365apps/${{M365_APP_ID}}?auth=2&login_hint=${{TEAMSFX_M365_USER_NAME}}"
},
"Outlook (browser)": {
"commandName": "Project",
"launchUrl": "https://outlook.office.com/host/${{M365_APP_ID}}?login_hint=${{TEAMSFX_M365_USER_NAME}}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,34 @@ 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
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
# Extend your Teams app to Outlook and the Microsoft 365 app
- uses: teamsApp/extendToM365
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: "https://localhost:44302;http://localhost:2544"
environmentVariables:
ASPNETCORE_ENVIRONMENT: "Development"
hotReloadProfile: "aspnetcore"
# Relative path to the build app package.
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
# Write the information of created resources into environment file for
# the specified environment variable(s).
writeToEnvironmentFile:
titleId: M365_TITLE_ID
appId: M365_APP_ID
4 changes: 2 additions & 2 deletions samples/tab-sso/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ 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`.
**Note:** If you want to test your app across multi hub like: Outlook/Office.com, please update the `manifest.json` in the `tab-sso\csharp\TeamsTabSSO\AppManifest_Hub` folder with the required values.
- **Edit** the `manifest.json` for `webApplicationInfo` resource `"api://{{domain-name}}/{{Microsoft-App-Id}}"` with MicrosoftAppId. E.g. `"api://1245.ngrok-free.app/{{Microsoft-App-Id}}`.
Expand All @@ -153,7 +153,7 @@ The simplest way to run this sample in Teams is to use Teams Toolkit for Visual
- 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
14 changes: 14 additions & 0 deletions samples/tab-sso/csharp/TeamsApp/TeamsApp.ttkproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>
Harikrishnan-MSFT marked this conversation as resolved.
Show resolved Hide resolved
<None Include="appPackage\color.png" />
<None Include="appPackage\manifest.json" />
<None Include="appPackage\outline.png" />
</ItemGroup>
<ItemGroup>
<ProjectCapability Include="ProjectConfigurationsDeclaredDimensions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ APP_NAME_SUFFIX=
TAB_DOMAIN=
TEAMS_APP_TENANT_ID=
AAD_APP_ACCESS_AS_USER_PERMISSION_ID=
TEAMSFX_M365_USER_NAME=



TEAMSFX_M365_USER_NAME=

M365_TITLE_ID=
M365_APP_ID=
17 changes: 17 additions & 0 deletions samples/tab-sso/csharp/TeamsApp/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"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}}"
},
"Microsoft 365 app (browser)": {
"commandName": "Project",
"launchUrl": "https://www.office.com/m365apps/${{M365_APP_ID}}?auth=2&login_hint=${{TEAMSFX_M365_USER_NAME}}"
},
"Outlook (browser)": {
"commandName": "Project",
"launchUrl": "https://outlook.office.com/host/${{M365_APP_ID}}?login_hint=${{TEAMSFX_M365_USER_NAME}}"
}
}
}