Skip to content

Commit

Permalink
Merge pull request #124 from microsoft/stevenbrix/winui-app
Browse files Browse the repository at this point in the history
add winui desktop test app
  • Loading branch information
stevenbrix authored Apr 10, 2020
2 parents 252c1c4 + d6ab3bf commit 9871382
Show file tree
Hide file tree
Showing 32 changed files with 2,309 additions and 114 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<VCProjectVersion>15.0</VCProjectVersion>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<CppWinRTVerbosity>high</CppWinRTVerbosity>
<MicrosoftWinUIVersion>3.0.0-preview1.200407.3-CI</MicrosoftWinUIVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(VisualStudioVersion)' == '15.0'">
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,27 @@ The **/testcomp** folder contains an implementation of a WinRT test component, d

The **/unittest** folder contains unit tests for validating the projection generated for the TestComp project (above), for the TestWinRT\TestComponent project (below), and for foundational parts of the Windows SDK. All pull requests should ensure that this project executes without errors.

## /winuiprojection

The **/winuiprojection** folder contains a project for generating and building a complete Windows SDK and WinUI projection. It's used by both **/winuitest** and **/winuidesktopsample**.

This is built into a separate project because the WinUI Xaml Compiler needs reference assemblies during Pass1 that contain definitions for platform types.
These types don't exist if you try to build the projection directly into the test app, so we first go through this project.

## /winuitest

The **/winuitest** folder contains a smoke test for generating and building a complete Windows SDK and WinUI projection, ensuring that most edge cases are validated. All pull requests should ensure that this project builds without errors.
The **/winuitest** is a simple test project that can be used for running automated tests with WinUI.

## /winuidesktopsample

The **/winuidesktopsample** is an end-to-end test app that uses the generated projection from the **/winuiprojection** project.

**Note** in order to load .xbf files, you need to set the **WinUIDesktopSample.Package** property as the startup project.

## /winuidesktopsample.package

The **/winuidesktopsample.package** project creates an .msix for the **/winuidesktopsample** project.
This is currently required to test apps that need to load .xbf files.

## /TestWinRT

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions WinUI/WinUIDesktopSample.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="d7e2f174-610e-4175-9509-45bb576eecbf"
Publisher="CN=steve"
Version="1.0.0.0" />

<Properties>
<DisplayName>WinUIDesktopSample.Package</DisplayName>
<PublisherDisplayName>steve</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="WinUIDesktopSample.Package"
Description="WinUIDesktopSample.Package"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Beware Dragons:
There are many BuildingInsideVisualStudio checks in here because this project can't build from the
command line w/o doing more evil trickery. This is only needed for manual testing when in VS, so it
isn't the worst thing in the world.
https://developercommunity.visualstudio.com/content/problem/954242/appx-packaging-project-fails-with-multi-targeted-l.html
-->
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" Condition="'$(BuildingInsideVisualStudio)'=='true'" />
<PropertyGroup>
<ProjectGuid>9b7aea9c-47db-4b8f-966a-7c64c02febf7</ProjectGuid>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\WinUIDesktopSample\WinUIDesktopSample.csproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
<ProjectReference Include="..\WinUIDesktopSample\WinUIDesktopSample.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" Condition="'$(BuildingInsideVisualStudio)'=='true'" />
<Target Name="Build" Condition="'$(BuildingInsideVisualStudio)'!='true'" />
</Project>
8 changes: 8 additions & 0 deletions WinUI/WinUIDesktopSample/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="WinUIDesktopSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Application.Resources>

</Application.Resources>
</Application>
51 changes: 51 additions & 0 deletions WinUI/WinUIDesktopSample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;

namespace WinUIDesktopSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
}

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
var window = new Microsoft.UI.Xaml.Window
{
// This will cause the InvalidCast exception. Once that is fixed, this can
// be removed and just use the new MainPage() line below for setting content
Content = new Microsoft.UI.Xaml.Shapes.Rectangle()
{
Fill = new SolidColorBrush(Windows.UI.Colors.Red),
Width = 200,
Height = 200
}
};

window.Content = new MainPage();

window.Activate();
}
}

public static class Program
{
static void Main(string[] args)
{
WinRT.ComWrappersSupport.InitializeComWrappers();

Microsoft.UI.Xaml.Application.Start((e) => new App());
}
}
}
17 changes: 17 additions & 0 deletions WinUI/WinUIDesktopSample/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Page x:Class="WinUIDesktopSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="NetCoreDesktopSample"
mc:Ignorable="d"
Height="450" Width="800">
<Page.Content>
<Grid>
<Grid.Children>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Hello from WinUI Desktop!" />
</Grid.Children>
</Grid>
</Page.Content>

</Page>
20 changes: 20 additions & 0 deletions WinUI/WinUIDesktopSample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace WinUIDesktopSample
{
/// <summary>
/// Interaction logic for MainPage.xaml
/// </summary>
public partial class MainPage : Page
{
public MainPage()
{
}
}
}
40 changes: 40 additions & 0 deletions WinUI/WinUIDesktopSample/WinUIDesktopSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<DefineConstants>DISABLE_XAML_GENERATED_MAIN</DefineConstants>
<GenerateTestProjection>true</GenerateTestProjection>
<ApplicationManifest>WinUIDesktopSample.exe.manifest</ApplicationManifest>
<!--
There seems to be a codegen bug when referencing the cswinrt interop assembly of the Win32XamlHost
project. Since we don't really need those metadata providers yet, this is just an easy workaround
-->
<XamlCodeGenerationControlFlags>DoNotGenerateOtherProviders</XamlCodeGenerationControlFlags>
<Platforms>x86;x64</Platforms>
</PropertyGroup>

<ItemGroup>
<Manifest Include="WinUIDesktopSample.exe.manifest">
<DeploymentContent>true</DeploymentContent>
</Manifest>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VCRTForwarders.140" Version="1.0.5" />
<!--
Exclude compile time assets so we don't pick up the interop assembly from the WinUI Nuget
since we are building our own in the WinUIProjection project
-->
<PackageReference Include="Microsoft.WinUI" Version="$(MicrosoftWinUIVersion)" GeneratePathProperty="true">
<ExcludeAssets>compile;</ExcludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\WinRT.Runtime\WinRT.Runtime.csproj" />
<ProjectReference Include="..\WinUIProjection\WinUIProjection.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 9871382

Please sign in to comment.