Skip to content

Commit 85ff237

Browse files
authored
User/alexlam/split alc activation main 231031 (#317)
* Split Samples\AppLifecycle\Activation into cs and cpp folders * Restructure folders associated with large artifacts to break them into smaller artifacts * Updated references to Build.Common.Cpp.props in vcxproj files and restructured SelfContainedDeployment * Factored out cs-winui-packaged-wap from under SelfContainedDeployment\cs into new folder SelfContainedDeployment\cs1 * Merged AppLifecycle\Activation\cpp1 into AppLifecycle\Activation\cpp
1 parent 619f056 commit 85ff237

File tree

568 files changed

+607
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

568 files changed

+607
-99
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Grouping the sample apps into subfolders cs, cs1, etc. for C# apps, and cpp for C++ apps, is an attempt to even out the sizes of artifacts produced in the Aggregrator pipeline.
2+
Each of the cpp, cs, cs1, etc. folders is being built by a separate job agent in the AzDO pipeline, producing a single corresponding artifact.
3+
Currently, it appears that artifacts larger than ~5GB have an elevated chance of hitting an "Out of memory" error during artifact download, thus breaking pipeline runs, hence the desire to keep artifacts relatively small.
4+
We cannot eliminate the subfolders at the cs, cs1, cpp, etc. level to come up with the following "flat" structure (unless we revert to the old design of AppLifecycle\Activation being one big artifact):
5+
```
6+
AppLifecycle\Activation\cpp-console-unpackaged
7+
AppLifecycle\Activation\cpp-win32-packaged
8+
....
9+
AppLifecycle\Activation\cs-wpf-packaged
10+
```
11+
That is because the yaml code in AzDO pipeline is currently using "-" as a stand-in for "\\" (because "\\" itself is illegal in AzDO pipeline artifact names) so when the yaml code is using the string "AppLifecycle\Activation\cpp-win32-packaged" to construct a file path to locate the .sln file of a sample app, it would not be distinguishable from the string "AppLifecycle-Activation-cpp-win32-packaged", thus breaking the existing code for locating the .sln files.
12+
13+
OTOH, the following folder structure should work:
14+
```
15+
AppLifecycle\Activation\cpp\console\unpackaged
16+
AppLifecycle\Activation\cpp\win32\packaged
17+
AppLifecycle\Activation\cpp\win32\unpackaged
18+
AppLifecycle\Activation\cpp\winui\packaged
19+
AppLifecycle\Activation\cs\console\unpackaged
20+
AppLifecycle\Activation\cs\winforms\unpackaged
21+
AppLifecycle\Activation\cs\winui\packaged
22+
AppLifecycle\Activation\cs\wpf\unpackaged
23+
AppLifecycle\Activation\cs\wpf\packaged
24+
```
25+
however it was not adopted because:
26+
- it's not really much prettier than the current structure,
27+
- it causes the AzDO pipeline to spawn 9 seperate jobs, one for each leaf folder above, and that is more granular than what we desire (we don't have enough job agents to build all sample apps in parallel even today, so needing more job agents is expected to regress performance).

Samples/AppLifecycle/Activation/cpp/cpp-console-unpackaged/CppWinRtConsoleActivation/CppWinRtConsoleActivation.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Import Project="$(NugetPackageDirectory)\Microsoft.WindowsAppSDK.1.4.230822000\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.WindowsAppSDK.1.4.230822000\build\native\Microsoft.WindowsAppSDK.props')" />
88
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props')" />
99
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
10-
<Import Project="..\..\..\..\Build.Common.Cpp.props" Condition="Exists('..\..\..\..\Build.Common.Cpp.props')" />
10+
<Import Project="..\..\..\..\..\Build.Common.Cpp.props" Condition="Exists('..\..\..\..\..\Build.Common.Cpp.props')" />
1111
<PropertyGroup Label="Globals">
1212
<CppWinRTOptimized>true</CppWinRTOptimized>
1313
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>

Samples/AppLifecycle/Activation/cpp/cpp-winui-packaged/CppWinUiDesktopActivation/CppWinUiDesktopActivation/CppWinUiDesktopActivation.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Import Project="$(NugetPackageDirectory)\Microsoft.WindowsAppSDK.1.4.230822000\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.WindowsAppSDK.1.4.230822000\build\native\Microsoft.WindowsAppSDK.props')" />
88
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.SDK.BuildTools.10.0.22621.756\build\Microsoft.Windows.SDK.BuildTools.props')" />
99
<Import Project="$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(NugetPackageDirectory)\Microsoft.Windows.CppWinRT.2.0.221104.6\build\native\Microsoft.Windows.CppWinRT.props')" />
10-
<Import Project="..\..\..\..\..\Build.Common.Cpp.props" Condition="Exists('..\..\..\..\..\Build.Common.Cpp.props')"/>
10+
<Import Project="..\..\..\..\..\..\Build.Common.Cpp.props" Condition="Exists('..\..\..\..\..\..\Build.Common.Cpp.props')"/>
1111
<PropertyGroup Label="Globals">
1212
<CppWinRTOptimized>true</CppWinRTOptimized>
1313
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. -->
3+
<Application x:Class="CsWpfActivation.App"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="clr-namespace:CsWpfActivation"
7+
StartupUri="MainWindow.xaml">
8+
<Application.Resources>
9+
10+
</Application.Resources>
11+
</Application>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
using System.Windows;
5+
6+
namespace CsWpfActivation
7+
{
8+
public partial class App : Application
9+
{
10+
}
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
6+
<UseWPF>true</UseWPF>
7+
<Platforms>x64;x86;ARM64</Platforms>
8+
<RuntimeIdentifiers>win10-x64;win10-x86;win10-arm64;win-x86;win-x64;win-arm64</RuntimeIdentifiers>
9+
<StartupObject>CsWpfActivation.Program</StartupObject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ApplicationDefinition Remove="App.xaml" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230822000" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!-- Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. -->
3+
<Window x:Class="CsWpfActivation.MainWindow"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
Title="C# WPF Activation" Height="480" Width="480">
10+
11+
<DockPanel>
12+
<ToolBarTray DockPanel.Dock="Top">
13+
<ToolBar>
14+
<Button
15+
x:Name="ActivationInfoWasButton" Click="ActivationInfoWasButton_Click"
16+
ToolTip="Get activation info WAS" Content="ActivationInfo WAS"/>
17+
<Button
18+
x:Name="ActivationInfoUwpButton" Click="ActivationInfoUwpButton_Click"
19+
ToolTip="Get activation info UWP" Content="ActivationInfo UWP"/>
20+
</ToolBar>
21+
</ToolBarTray>
22+
23+
<ListView
24+
x:Name="StatusListView" Background="Transparent"
25+
ScrollViewer.VerticalScrollBarVisibility="Visible">
26+
</ListView>
27+
28+
</DockPanel>
29+
</Window>
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
// NOTES. This app is cloned from the unpackaged version. The key differences are as follows:
5+
// 1. A packaged app cannot use the Register/Unregister APIs for rich activation; instead it declares activation kinds in its manifest.
6+
// 2. A packaged app does not need to initialize the Windows App SDK for unpackaged support.
7+
// 3. The Package project must include a reference to the Windows App SDK NuGet in addition to the app project itself.
8+
// 4. A packaged app can declare rich activation extensions in the manifest, and retrieve activation arguments via the Windows App SDK GetActivatedEventArgs API.
9+
// 5. A packaged app can use the UWP GetActivatedEventArgs API instead of the Windows App SDK version.
10+
// 6. MddBootstrap.cs is not needed.
11+
12+
using WindowsAppSdk = Microsoft.Windows.AppLifecycle;
13+
using System;
14+
using System.Linq;
15+
using System.Windows;
16+
using Windows.ApplicationModel.Activation;
17+
using Windows.Storage;
18+
19+
namespace CsWpfActivation
20+
{
21+
public partial class MainWindow : Window
22+
{
23+
24+
public MainWindow()
25+
{
26+
InitializeComponent();
27+
}
28+
29+
private void OutputMessage(string message)
30+
{
31+
Dispatcher.BeginInvoke(new Action(() =>
32+
{
33+
StatusListView.Items.Add(message);
34+
}));
35+
}
36+
37+
private void ActivationInfoWasButton_Click(object sender, RoutedEventArgs e)
38+
{
39+
GetActivationInfoWas();
40+
}
41+
42+
private void ActivationInfoUwpButton_Click(object sender, RoutedEventArgs e)
43+
{
44+
GetActivationInfoUwp();
45+
}
46+
47+
private void GetActivationInfoWas()
48+
{
49+
// The Windows App SDK GetActivatedEventArgs returns an AppActivationArguments
50+
// object, which exposes the specific activation type via its Data property.
51+
WindowsAppSdk.AppActivationArguments args =
52+
WindowsAppSdk.AppInstance.GetCurrent().GetActivatedEventArgs();
53+
54+
// The Windows App SDK includes the ExtendedActivationKind enum, which
55+
// includes and extends the UWP ActivationKind enum.
56+
WindowsAppSdk.ExtendedActivationKind kind = args.Kind;
57+
OutputMessage($"ActivationKind: {kind}");
58+
59+
if (kind == WindowsAppSdk.ExtendedActivationKind.Launch)
60+
{
61+
if (args.Data is ILaunchActivatedEventArgs launchArgs)
62+
{
63+
string argString = launchArgs.Arguments;
64+
string[] argStrings = argString.Split();
65+
foreach (string arg in argStrings)
66+
{
67+
if (!string.IsNullOrWhiteSpace(arg))
68+
{
69+
OutputMessage(arg);
70+
}
71+
}
72+
}
73+
}
74+
else if (kind == WindowsAppSdk.ExtendedActivationKind.File)
75+
{
76+
if (args.Data is IFileActivatedEventArgs fileArgs)
77+
{
78+
IStorageItem file = fileArgs.Files.FirstOrDefault();
79+
OutputMessage(file.Name);
80+
}
81+
}
82+
else if (kind == WindowsAppSdk.ExtendedActivationKind.Protocol)
83+
{
84+
if (args.Data is IProtocolActivatedEventArgs protocolArgs)
85+
{
86+
Uri uri = protocolArgs.Uri;
87+
OutputMessage(uri.AbsoluteUri);
88+
}
89+
}
90+
else if (kind == WindowsAppSdk.ExtendedActivationKind.StartupTask)
91+
{
92+
if (args.Data is IStartupTaskActivatedEventArgs startupArgs)
93+
{
94+
OutputMessage(startupArgs.TaskId);
95+
}
96+
}
97+
}
98+
99+
// Use the UWP version of AppInstance::GetActivatedEventArgs.
100+
private void GetActivationInfoUwp()
101+
{
102+
// The UWP GetActivatedEventArgs returns an IActivatedEventArgs,
103+
// which can be directly cast to the specific activation type it represents.
104+
IActivatedEventArgs args =
105+
Windows.ApplicationModel.AppInstance.GetActivatedEventArgs();
106+
ActivationKind kind = args.Kind;
107+
OutputMessage($"ActivationKind: {kind}");
108+
109+
if (kind == ActivationKind.Launch)
110+
{
111+
if (args is ILaunchActivatedEventArgs launchArgs)
112+
{
113+
string argString = launchArgs.Arguments;
114+
string[] argStrings = argString.Split();
115+
foreach (string arg in argStrings)
116+
{
117+
if (!string.IsNullOrWhiteSpace(arg))
118+
{
119+
OutputMessage(arg);
120+
}
121+
}
122+
}
123+
}
124+
else if (kind == ActivationKind.File)
125+
{
126+
if (args is IFileActivatedEventArgs fileArgs)
127+
{
128+
IStorageItem file = fileArgs.Files.FirstOrDefault();
129+
OutputMessage(file.Name);
130+
}
131+
}
132+
else if (kind == ActivationKind.Protocol)
133+
{
134+
if (args is IProtocolActivatedEventArgs protocolArgs)
135+
{
136+
Uri uri = protocolArgs.Uri;
137+
OutputMessage(uri.AbsoluteUri);
138+
}
139+
}
140+
else if (kind == ActivationKind.StartupTask)
141+
{
142+
if (args is IStartupTaskActivatedEventArgs startupArgs)
143+
{
144+
OutputMessage(startupArgs.TaskId);
145+
}
146+
}
147+
}
148+
149+
}
150+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
using System;
5+
6+
namespace CsWpfActivation
7+
{
8+
public class Program
9+
{
10+
[STAThread]
11+
static void Main(string[] args)
12+
{
13+
App app = new()
14+
{
15+
StartupUri = new Uri("MainWindow.xaml", UriKind.Relative)
16+
};
17+
app.Run();
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)