Skip to content

Commit b56962a

Browse files
committed
Add bootstrap initialization and update package dependencies for framework-dependent deployment
1 parent e2db3cd commit b56962a

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

Samples/WindowsML/cpp/CppConsoleDesktop.FrameworkDependent/CppConsoleDesktop.FrameworkDependent.vcxproj

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!-- Framework-dependent deployment requires bootstrap initialization -->
4+
<PropertyGroup>
5+
<WindowsAppSDKSelfContained>false</WindowsAppSDKSelfContained>
6+
<WindowsAppSdkBootstrapInitialize>true</WindowsAppSdkBootstrapInitialize>
7+
</PropertyGroup>
38
<Import Project="packages\Microsoft.WindowsAppSDK.Runtime.1.8.250805005-experimental\build\native\Microsoft.WindowsAppSDK.Runtime.props" Condition="Exists('packages\Microsoft.WindowsAppSDK.Runtime.1.8.250805005-experimental\build\native\Microsoft.WindowsAppSDK.Runtime.props')" />
49
<Import Project="packages\Microsoft.WindowsAppSDK.Base.1.8.250509001-experimental\build\native\Microsoft.WindowsAppSDK.Base.props" Condition="Exists('packages\Microsoft.WindowsAppSDK.Base.1.8.250509001-experimental\build\native\Microsoft.WindowsAppSDK.Base.props')" />
510
<Import Project="packages\Microsoft.Windows.SDK.BuildTools.MSIX.1.7.20250508.1\build\Microsoft.Windows.SDK.BuildTools.MSIX.props" Condition="Exists('packages\Microsoft.Windows.SDK.BuildTools.MSIX.1.7.20250508.1\build\Microsoft.Windows.SDK.BuildTools.MSIX.props')" />
611
<Import Project="packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props')" />
12+
<Import Project="packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.props" Condition="Exists('packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.props')" />
13+
<Import Project="packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.props" Condition="Exists('packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.props')" />
714
<Import Project="packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.props" Condition="Exists('packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.props')" />
815
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
916
<ItemGroup Label="ProjectConfigurations">
@@ -20,8 +27,6 @@
2027
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
2128
<WindowsPackageType>None</WindowsPackageType>
2229
<DefaultLanguage>en-US</DefaultLanguage>
23-
<!-- Framework-dependent deployment (default) -->
24-
<WindowsAppSDKSelfContained>false</WindowsAppSDKSelfContained>
2530
</PropertyGroup>
2631
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2732
<PropertyGroup Label="Configuration">
@@ -54,6 +59,8 @@
5459
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
5560
<ImportGroup Label="ExtensionTargets">
5661
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" />
62+
<Import Project="packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.targets" Condition="Exists('packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.targets')" />
63+
<Import Project="packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.targets" Condition="Exists('packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.targets')" />
5764
<Import Project="packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.targets" Condition="Exists('packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.targets')" />
5865
<Import Project="packages\Microsoft.WindowsAppSDK.Runtime.1.8.250805005-experimental\build\native\Microsoft.WindowsAppSDK.Runtime.targets" Condition="Exists('packages\Microsoft.WindowsAppSDK.Runtime.1.8.250805005-experimental\build\native\Microsoft.WindowsAppSDK.Runtime.targets')" />
5966
<Import Project="packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets')" />
@@ -66,6 +73,10 @@
6673
</PropertyGroup>
6774
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props'))" />
6875
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets'))" />
76+
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.props'))" />
77+
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.Foundation.1.8.250701000-experimental\build\native\Microsoft.WindowsAppSDK.Foundation.targets'))" />
78+
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.props'))" />
79+
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.InteractiveExperiences.1.8.250626001-experimental\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.targets'))" />
6980
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.props'))" />
7081
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.ML.1.8.1054-experimental\build\native\Microsoft.WindowsAppSDK.ML.targets'))" />
7182
<Error Condition="!Exists('packages\Microsoft.WindowsAppSDK.Runtime.1.8.250805005-experimental\build\native\Microsoft.WindowsAppSDK.Runtime.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.WindowsAppSDK.Runtime.1.8.250805005-experimental\build\native\Microsoft.WindowsAppSDK.Runtime.props'))" />

Samples/WindowsML/cpp/CppConsoleDesktop.FrameworkDependent/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,77 @@ msbuild CppConsoleDesktop.FrameworkDependent.vcxproj /p:Platform=x64 /p:Configur
3333
- WindowsAppSDK ML package (core machine learning functionality)
3434
- WindowsAppSDK Runtime package (framework runtime components)
3535
- WindowsAppSDK Base package (required for proper binary deployment)
36+
- WindowsAppSDK Foundation package (required for Windows App SDK bootstrap functionality)
37+
- WindowsAppSDK InteractiveExperiences package (required dependency for Foundation - provides UI metadata including Microsoft.UI.WindowId)
3638
- CppWinRT package (Windows Runtime projections)
3739
- Windows SDK Build Tools packages (build-time dependencies)
3840

3941
See `packages.config` for current package versions.
4042

43+
## Windows App SDK Bootstrap Configuration
44+
45+
Framework-dependent applications require bootstrap initialization to properly discover and initialize the Windows App SDK runtime at startup. This project is configured to automatically include the necessary bootstrap code.
46+
47+
### How It Works
48+
49+
1. **Foundation Package**: The `Microsoft.WindowsAppSDK.Foundation` package provides bootstrap functionality for framework-dependent deployments.
50+
51+
2. **InteractiveExperiences Dependency**: Foundation package depends on `Microsoft.WindowsAppSDK.InteractiveExperiences` which provides essential UI metadata (like `Microsoft.UI.WindowId`) required by CppWinRT projections.
52+
53+
3. **Bootstrap Property**: The project sets `<WindowsAppSdkBootstrapInitialize>true</WindowsAppSdkBootstrapInitialize>` **before** importing any Windows App SDK packages.
54+
55+
4. **Auto-Generated Code**: When the property is set correctly, the Foundation package automatically includes `MddBootstrapAutoInitializer.cpp` in the build, which handles runtime discovery and initialization.
56+
57+
### Key Configuration Requirements
58+
59+
- The `WindowsAppSdkBootstrapInitialize` property must be defined **before** importing Windows App SDK packages
60+
- The Foundation package `.props` and `.targets` files must be imported in the correct order
61+
- The InteractiveExperiences package is required as a dependency of Foundation
62+
- Framework-dependent projects (`WindowsAppSDKSelfContained=false`) require this bootstrap mechanism
63+
64+
### Manual Configuration Steps
65+
66+
If setting up a new framework-dependent project:
67+
68+
1. Add the required packages to `packages.config`:
69+
```xml
70+
<package id="Microsoft.WindowsAppSDK.Foundation" version="1.8.250701000-experimental" targetFramework="native" />
71+
<package id="Microsoft.WindowsAppSDK.InteractiveExperiences" version="1.8.250626001-experimental" targetFramework="native" />
72+
<package id="Microsoft.WindowsAppSDK.Runtime" version="1.8.250805005-experimental" targetFramework="native" />
73+
<package id="Microsoft.WindowsAppSDK.Base" version="1.8.250509001-experimental" targetFramework="native" />
74+
```
75+
76+
2. Set the bootstrap property at the top of your `.vcxproj` file (before any imports):
77+
```xml
78+
<PropertyGroup>
79+
<WindowsAppSdkBootstrapInitialize>true</WindowsAppSdkBootstrapInitialize>
80+
</PropertyGroup>
81+
```
82+
83+
3. Import Foundation and InteractiveExperiences package build files:
84+
```xml
85+
<!-- In props section -->
86+
<Import Project="packages\Microsoft.WindowsAppSDK.Foundation.[version]\build\native\Microsoft.WindowsAppSDK.Foundation.props" />
87+
<Import Project="packages\Microsoft.WindowsAppSDK.InteractiveExperiences.[version]\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.props" />
88+
89+
<!-- In targets section -->
90+
<Import Project="packages\Microsoft.WindowsAppSDK.Foundation.[version]\build\native\Microsoft.WindowsAppSDK.Foundation.targets" />
91+
<Import Project="packages\Microsoft.WindowsAppSDK.InteractiveExperiences.[version]\build\native\Microsoft.WindowsAppSDK.InteractiveExperiences.targets" />
92+
```
93+
94+
### Common Issues and Solutions
95+
96+
- **CppWinRT Error: "Microsoft.UI.WindowId could not be found"**
97+
- **Solution**: Ensure the InteractiveExperiences package is included. Foundation depends on UI metadata provided by this package.
98+
99+
- **Bootstrap initialization not working**
100+
- **Solution**: Verify the `WindowsAppSdkBootstrapInitialize` property is set to `true` **before** any package imports in the vcxproj file.
101+
102+
- **Duplicate file warnings during build**
103+
- **Note**: Multiple packages may include the same auto-initializer files. The linker will automatically ignore duplicates - these warnings are informational only.
104+
105+
This configuration ensures the Windows App SDK runtime is properly initialized when your application starts, even when the runtime is not packaged with your application.
106+
41107
## Deployment Requirements
42108

43109
The target machine must have the Windows App SDK Runtime installed. This is the recommended deployment model for most applications as it allows for shared runtime components and easier servicing.

Samples/WindowsML/cpp/CppConsoleDesktop.FrameworkDependent/packages.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.3233" targetFramework="native" />
55
<package id="Microsoft.Windows.SDK.BuildTools.MSIX" version="1.7.20250508.1" targetFramework="native" developmentDependency="true" />
66
<package id="Microsoft.WindowsAppSDK.Base" version="1.8.250509001-experimental" targetFramework="native" />
7+
<package id="Microsoft.WindowsAppSDK.Foundation" version="1.8.250701000-experimental" targetFramework="native" />
8+
<package id="Microsoft.WindowsAppSDK.InteractiveExperiences" version="1.8.250626001-experimental" targetFramework="native" />
79
<package id="Microsoft.WindowsAppSDK.ML" version="1.8.1054-experimental" targetFramework="native" />
810
<package id="Microsoft.WindowsAppSDK.Runtime" version="1.8.250805005-experimental" targetFramework="native" />
911
</packages>

0 commit comments

Comments
 (0)