Skip to content

Commit c158d6a

Browse files
Add CsWinRT authoring samples (#174)
* initial sample files * add C# app * add activatableclass * updates * update readme * anycpu not supported * fix styles * change to anycpu library * update to 1.6.1 * Update README.md * import platformtoolset * Add unpackaged C++ app and upgrade to 1.1preview2 * Create SamplesCI-CustomControl.yml * update to cswinrt 1.6.3 * rename yml * try setting readytorun to false * ready to run should be true * workaround for PublishReadyToRun=false
1 parent 268554c commit c158d6a

File tree

104 files changed

+3773
-0
lines changed

Some content is hidden

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

104 files changed

+3773
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. -->
3+
<Application
4+
x:Class="CppApp.App"
5+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
6+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
7+
xmlns:local="using:CppApp">
8+
9+
<Application.Resources>
10+
<!-- Application-specific resources -->
11+
<ResourceDictionary>
12+
<ResourceDictionary.MergedDictionaries>
13+
<!--
14+
Styles that define common aspects of the platform look and feel
15+
Required by Visual Studio project and item templates
16+
-->
17+
<ResourceDictionary Source="ms-appx:///Styles.xaml"/>
18+
</ResourceDictionary.MergedDictionaries>
19+
</ResourceDictionary>
20+
</Application.Resources>
21+
</Application>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
#include "pch.h"
5+
6+
#include "App.xaml.h"
7+
#include "MainWindow.xaml.h"
8+
9+
namespace winrt
10+
{
11+
using namespace Windows::Foundation;
12+
using namespace Microsoft::UI::Xaml;
13+
}
14+
15+
namespace winrt::CppApp::implementation
16+
{
17+
App::App()
18+
{
19+
InitializeComponent();
20+
21+
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
22+
UnhandledException([](winrt::IInspectable const&, winrt::UnhandledExceptionEventArgs const& e)
23+
{
24+
if (IsDebuggerPresent())
25+
{
26+
auto errorMessage = e.Message();
27+
__debugbreak();
28+
}
29+
});
30+
#endif
31+
}
32+
33+
void App::OnLaunched(winrt::LaunchActivatedEventArgs const&)
34+
{
35+
window = winrt::make<MainWindow>();
36+
window.Activate();
37+
}
38+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
#pragma once
5+
#include "App.xaml.g.h"
6+
#include "pch.h"
7+
8+
namespace winrt::CppApp::implementation
9+
{
10+
struct App : AppT<App>
11+
{
12+
App();
13+
14+
void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);
15+
16+
private:
17+
Microsoft::UI::Xaml::Window window{ nullptr };
18+
};
19+
}
76.3 KB
Loading
10.6 KB
Loading
2.73 KB
Loading
10.9 KB
Loading
3.06 KB
Loading
Binary file not shown.
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props')" />
4+
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.props')" />
5+
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.props')" />
6+
<Import Project="..\..\Build.Common.Cpp.props" Condition="Exists('..\..\Build.Common.Cpp.props')" />
7+
<PropertyGroup Label="Globals">
8+
<CppWinRTOptimized>true</CppWinRTOptimized>
9+
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
10+
<MinimalCoreWin>true</MinimalCoreWin>
11+
<ProjectGuid>{34a4ad19-a703-47f3-b279-e505c6a2a935}</ProjectGuid>
12+
<ProjectName>CppApp</ProjectName>
13+
<RootNamespace>CppApp</RootNamespace>
14+
<!--
15+
$(TargetName) should be same as $(RootNamespace) so that the produced binaries (.exe/.pri/etc.)
16+
have a name that matches the .winmd
17+
-->
18+
<TargetName>$(RootNamespace)</TargetName>
19+
<DefaultLanguage>en-US</DefaultLanguage>
20+
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
21+
<AppContainerApplication>false</AppContainerApplication>
22+
<AppxPackage>true</AppxPackage>
23+
<ApplicationType>Windows Store</ApplicationType>
24+
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
25+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
26+
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
27+
<UseWinUI>true</UseWinUI>
28+
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
29+
</PropertyGroup>
30+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
31+
<ItemGroup Label="ProjectConfigurations">
32+
<ProjectConfiguration Include="Debug|Win32">
33+
<Configuration>Debug</Configuration>
34+
<Platform>Win32</Platform>
35+
</ProjectConfiguration>
36+
<ProjectConfiguration Include="Debug|x64">
37+
<Configuration>Debug</Configuration>
38+
<Platform>x64</Platform>
39+
</ProjectConfiguration>
40+
<ProjectConfiguration Include="Debug|arm64">
41+
<Configuration>Debug</Configuration>
42+
<Platform>arm64</Platform>
43+
</ProjectConfiguration>
44+
<ProjectConfiguration Include="Release|Win32">
45+
<Configuration>Release</Configuration>
46+
<Platform>Win32</Platform>
47+
</ProjectConfiguration>
48+
<ProjectConfiguration Include="Release|x64">
49+
<Configuration>Release</Configuration>
50+
<Platform>x64</Platform>
51+
</ProjectConfiguration>
52+
<ProjectConfiguration Include="Release|arm64">
53+
<Configuration>Release</Configuration>
54+
<Platform>arm64</Platform>
55+
</ProjectConfiguration>
56+
</ItemGroup>
57+
<PropertyGroup Label="Configuration">
58+
<ConfigurationType>Application</ConfigurationType>
59+
<CharacterSet>Unicode</CharacterSet>
60+
<DesktopCompatible>true</DesktopCompatible>
61+
</PropertyGroup>
62+
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
63+
<UseDebugLibraries>true</UseDebugLibraries>
64+
<LinkIncremental>true</LinkIncremental>
65+
</PropertyGroup>
66+
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
67+
<UseDebugLibraries>false</UseDebugLibraries>
68+
<WholeProgramOptimization>true</WholeProgramOptimization>
69+
<LinkIncremental>false</LinkIncremental>
70+
</PropertyGroup>
71+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
72+
<ImportGroup Label="ExtensionSettings">
73+
</ImportGroup>
74+
<ImportGroup Label="PropertySheets">
75+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
76+
</ImportGroup>
77+
<ItemDefinitionGroup>
78+
<ClCompile>
79+
<PrecompiledHeader>Use</PrecompiledHeader>
80+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
81+
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
82+
<WarningLevel>Level4</WarningLevel>
83+
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
84+
</ClCompile>
85+
</ItemDefinitionGroup>
86+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
87+
<ClCompile>
88+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
89+
</ClCompile>
90+
</ItemDefinitionGroup>
91+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
92+
<ClCompile>
93+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
94+
</ClCompile>
95+
<Link>
96+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
97+
<OptimizeReferences>true</OptimizeReferences>
98+
</Link>
99+
</ItemDefinitionGroup>
100+
<ItemGroup>
101+
<Manifest Include="app.manifest" />
102+
</ItemGroup>
103+
<ItemGroup>
104+
<ClInclude Include="MainPage.xaml.h">
105+
<DependentUpon>MainPage.xaml</DependentUpon>
106+
<SubType>Code</SubType>
107+
</ClInclude>
108+
<ClInclude Include="pch.h" />
109+
<ClInclude Include="App.xaml.h">
110+
<DependentUpon>App.xaml</DependentUpon>
111+
</ClInclude>
112+
<ClInclude Include="MainWindow.xaml.h">
113+
<DependentUpon>MainWindow.xaml</DependentUpon>
114+
</ClInclude>
115+
<ClInclude Include="SampleConfiguration.h" />
116+
<ClInclude Include="Scenario1_CustomControl.xaml.h">
117+
<DependentUpon>Scenario1_CustomControl.xaml</DependentUpon>
118+
<SubType>Code</SubType>
119+
</ClInclude>
120+
<ClInclude Include="Scenario2_UserControl.xaml.h">
121+
<DependentUpon>Scenario2_UserControl.xaml</DependentUpon>
122+
<SubType>Code</SubType>
123+
</ClInclude>
124+
<ClInclude Include="SettingsPage.xaml.h">
125+
<DependentUpon>SettingsPage.xaml</DependentUpon>
126+
<SubType>Code</SubType>
127+
</ClInclude>
128+
</ItemGroup>
129+
<ItemGroup>
130+
<ApplicationDefinition Include="App.xaml" />
131+
<Page Include="MainPage.xaml">
132+
<SubType>Designer</SubType>
133+
</Page>
134+
<Page Include="MainWindow.xaml" />
135+
<Page Include="Scenario1_CustomControl.xaml">
136+
<SubType>Designer</SubType>
137+
</Page>
138+
<Page Include="Scenario2_UserControl.xaml">
139+
<SubType>Designer</SubType>
140+
</Page>
141+
<Page Include="SettingsPage.xaml">
142+
<SubType>Designer</SubType>
143+
</Page>
144+
<Page Include="Styles.xaml">
145+
<SubType>Designer</SubType>
146+
</Page>
147+
</ItemGroup>
148+
<ItemGroup>
149+
<ClCompile Include="MainPage.xaml.cpp">
150+
<DependentUpon>MainPage.xaml</DependentUpon>
151+
<SubType>Code</SubType>
152+
</ClCompile>
153+
<ClCompile Include="pch.cpp">
154+
<PrecompiledHeader>Create</PrecompiledHeader>
155+
</ClCompile>
156+
<ClCompile Include="App.xaml.cpp">
157+
<DependentUpon>App.xaml</DependentUpon>
158+
</ClCompile>
159+
<ClCompile Include="MainWindow.xaml.cpp">
160+
<DependentUpon>MainWindow.xaml</DependentUpon>
161+
</ClCompile>
162+
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
163+
<ClCompile Include="SampleConfiguration.cpp" />
164+
<ClCompile Include="Scenario1_CustomControl.xaml.cpp">
165+
<DependentUpon>Scenario1_CustomControl.xaml</DependentUpon>
166+
<SubType>Code</SubType>
167+
</ClCompile>
168+
<ClCompile Include="Scenario2_UserControl.xaml.cpp">
169+
<DependentUpon>Scenario2_UserControl.xaml</DependentUpon>
170+
<SubType>Code</SubType>
171+
</ClCompile>
172+
<ClCompile Include="SettingsPage.xaml.cpp">
173+
<DependentUpon>SettingsPage.xaml</DependentUpon>
174+
<SubType>Code</SubType>
175+
</ClCompile>
176+
</ItemGroup>
177+
<ItemGroup>
178+
<Midl Include="Project.idl">
179+
<SubType>Code</SubType>
180+
</Midl>
181+
</ItemGroup>
182+
<ItemGroup>
183+
<Image Include="Assets\SplashScreen.png" />
184+
<Image Include="Assets\Square150x150Logo.png" />
185+
<Image Include="Assets\Square44x44Logo.png" />
186+
<Image Include="Assets\Wide310x150Logo.png" />
187+
<Image Include="Assets\logo.png" />
188+
<Image Include="Assets\windows-sdk.ico" />
189+
</ItemGroup>
190+
<!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
191+
Tools extension to be activated for this project even if the Windows App SDK Nuget
192+
package has not yet been restored -->
193+
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnablePreviewMsixTooling)'=='true'">
194+
<ProjectCapability Include="Msix" />
195+
</ItemGroup>
196+
<ItemGroup>
197+
<None Include="packages.config" />
198+
</ItemGroup>
199+
<ItemGroup>
200+
<ProjectReference Include="..\WinUIComponentCs\WinUIComponentCs.csproj">
201+
<Project>{bcc816dc-0f01-4f0f-8506-df6afefaea92}</Project>
202+
</ProjectReference>
203+
</ItemGroup>
204+
<ItemGroup>
205+
<AppxManifest Include="Package.appxmanifest">
206+
<SubType>Designer</SubType>
207+
</AppxManifest>
208+
</ItemGroup>
209+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
210+
<ImportGroup Label="ExtensionTargets">
211+
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.targets')" />
212+
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.targets')" />
213+
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets')" />
214+
</ImportGroup>
215+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
216+
<PropertyGroup>
217+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
218+
</PropertyGroup>
219+
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
220+
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.210922.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
221+
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.props'))" />
222+
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.1.0-preview2\build\native\Microsoft.WindowsAppSDK.targets'))" />
223+
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.props'))" />
224+
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22000.197\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
225+
</Target>
226+
</Project>

0 commit comments

Comments
 (0)