-
Notifications
You must be signed in to change notification settings - Fork 11
Create MSBuild template system for automatic DeviceRunners test app bootstrap #89
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
base: main
Are you sure you want to change the base?
Changes from 18 commits
9485b14
5b4a5f1
847d793
afd68d7
b29c268
69bc566
b0d69a2
5d1ccdc
abdc8b3
ef4070f
a1292e4
13d8302
c868ea5
f8c36fa
bae90d0
63a87aa
da8eb70
7155889
f58838f
358c652
23512d8
a6a6d68
910a686
ca5d396
573763f
0badc69
a84733f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,15 +24,8 @@ | |
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <!-- App Icon --> | ||
| <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" /> | ||
|
|
||
| <!-- Splash Screen --> | ||
| <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" /> | ||
|
|
||
| <!-- Images --> | ||
| <MauiImage Include="Resources\Images\*" /> | ||
| <MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
|
|
||
| <!-- Custom Fonts --> | ||
| <MauiFont Include="Resources\Fonts\*" /> | ||
|
|
@@ -44,10 +37,6 @@ | |
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.Logging.Debug" /> | ||
| <PackageReference Include="Microsoft.Extensions.Logging.Console" /> | ||
| <PackageReference Include="Microsoft.Maui.Controls" /> | ||
| <PackageReference Include="Microsoft.Maui.Controls.Compatibility" /> | ||
| <PackageReference Include="xunit" /> | ||
| <PackageReference Include="xunit.runner.utility" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
|
|
@@ -58,18 +47,16 @@ | |
| <ProjectReference Include="..\..\..\src\DeviceRunners.VisualRunners.Xunit\DeviceRunners.VisualRunners.Xunit.csproj" /> | ||
| <ProjectReference Include="..\..\..\src\DeviceRunners.VisualRunners.NUnit\DeviceRunners.VisualRunners.NUnit.csproj" /> | ||
| <ProjectReference Include="..\..\..\src\DeviceRunners.VisualRunners.Maui\DeviceRunners.VisualRunners.Maui.csproj" /> | ||
| <ProjectReference Include="..\..\..\src\DeviceRunners.VisualRunners.Maui.Bootstrap\DeviceRunners.VisualRunners.Maui.Bootstrap.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Import the device test app generation targets from Bootstrap package --> | ||
| <Import Project="..\..\..\src\DeviceRunners.VisualRunners.Maui.Bootstrap\build\DeviceRunners.VisualRunners.Maui.Bootstrap.props" /> | ||
|
||
| <Import Project="..\..\..\src\DeviceRunners.VisualRunners.Maui.Bootstrap\build\DeviceRunners.VisualRunners.Maui.Bootstrap.targets" /> | ||
|
|
||
| <ItemGroup Condition="'$(TestingMode)' == 'XHarness'"> | ||
| <ProjectReference Include="..\..\..\src\DeviceRunners.XHarness.Xunit\DeviceRunners.XHarness.Xunit.csproj" /> | ||
| <ProjectReference Include="..\..\..\src\DeviceRunners.XHarness.Maui\DeviceRunners.XHarness.Maui.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <Target Name="RemoveVisualStudioTestRunner" BeforeTargets="_ComputeAppxPackagePayload"> | ||
| <ItemGroup> | ||
| <_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> | ||
| <PackagingOutputs Remove="@(_VisualStudioTestRunnerFiles)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| </Project> | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netstandard2.0</TargetFramework> | ||
| <LangVersion>latest</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <IncludeBuildOutput>false</IncludeBuildOutput> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="build\DeviceRunners.VisualRunners.Maui.Bootstrap.targets" Pack="true" PackagePath="build\" /> | ||
| <None Include="build\DeviceRunners.VisualRunners.Maui.Bootstrap.props" Pack="true" PackagePath="build\" /> | ||
| <None Include="build\templates\**\*" Pack="true" PackagePath="build\templates\" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project> | ||
| <!-- Auto-detect if we should generate device test app files --> | ||
| <PropertyGroup> | ||
| <_ShouldGenerateDeviceTestApp Condition="'$(UseMaui)' == 'true' AND '$(DesignTimeBuild)' != 'true'">true</_ShouldGenerateDeviceTestApp> | ||
| </PropertyGroup> | ||
| </Project> |
mattleibow marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project> | ||
|
|
||
| <!-- Define all template files and their destinations --> | ||
| <ItemGroup> | ||
| <!-- Android templates --> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/Android/MainActivity.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/Android/MainActivity.cs</Destination> | ||
| <Platform>android</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
mattleibow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </TemplateFile> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/Android/MainApplication.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/Android/MainApplication.cs</Destination> | ||
| <Platform>android</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
| </TemplateFile> | ||
|
|
||
| <!-- iOS templates --> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/iOS/Program.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/iOS/Program.cs</Destination> | ||
| <Platform>ios</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
| </TemplateFile> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/iOS/AppDelegate.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/iOS/AppDelegate.cs</Destination> | ||
| <Platform>ios</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
| </TemplateFile> | ||
|
|
||
| <!-- macOS Catalyst templates --> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/MacCatalyst/Program.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/MacCatalyst/Program.cs</Destination> | ||
| <Platform>maccatalyst</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
| </TemplateFile> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/MacCatalyst/AppDelegate.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/MacCatalyst/AppDelegate.cs</Destination> | ||
| <Platform>maccatalyst</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
| </TemplateFile> | ||
|
|
||
| <!-- Windows templates --> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Platforms/Windows/App.xaml.cs.template"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/Windows/App.xaml.cs</Destination> | ||
| <Platform>windows</Platform> | ||
| <BuildAction>Compile</BuildAction> | ||
| </TemplateFile> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Windows/App.xaml"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/Windows/App.xaml</Destination> | ||
| <Platform>windows</Platform> | ||
| <BuildAction>Page</BuildAction> | ||
| </TemplateFile> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Windows/app.manifest"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/Windows/app.manifest</Destination> | ||
| <Platform>windows</Platform> | ||
| <BuildAction>ApplicationManifest</BuildAction> | ||
| </TemplateFile> | ||
| <TemplateFile Include="$(MSBuildThisFileDirectory)templates/Windows/Package.appxmanifest"> | ||
| <Destination>$(IntermediateOutputPath)Platforms/Windows/Package.appxmanifest</Destination> | ||
| <Platform>windows</Platform> | ||
| <BuildAction>AppxManifest</BuildAction> | ||
| </TemplateFile> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Process all template files in one target using batching --> | ||
| <Target Name="ProcessAllTemplates" BeforeTargets="BeforeCompile" Condition="'$(_ShouldGenerateDeviceTestApp)' == 'true'" | ||
| Inputs="@(TemplateFile)" Outputs="%(TemplateFile.Destination)"> | ||
|
|
||
| <!-- Create output directory --> | ||
| <MakeDir Directories="$([System.IO.Path]::GetDirectoryName('%(TemplateFile.Destination)'))" /> | ||
|
|
||
| <!-- Read template file as single string --> | ||
| <PropertyGroup> | ||
| <_TemplateContent>$([System.IO.File]::ReadAllText('%(TemplateFile.Identity)'))</_TemplateContent> | ||
| <_ProcessedContent>$(_TemplateContent.Replace('{{RootNamespace}}', '$(RootNamespace)'))</_ProcessedContent> | ||
| <_ProcessedContent>$(_ProcessedContent.Replace('{{ApplicationTitle}}', '$(ApplicationTitle)'))</_ProcessedContent> | ||
| <_ProcessedContent>$(_ProcessedContent.Replace('{{ApplicationId}}', '$(ApplicationId)'))</_ProcessedContent> | ||
| <_ProcessedContent>$(_ProcessedContent.Replace('{{AppId}}', '$(ApplicationId)'))</_ProcessedContent> | ||
|
||
| </PropertyGroup> | ||
|
|
||
| <!-- Write processed file --> | ||
| <WriteLinesToFile File="%(TemplateFile.Destination)" Lines="$(_ProcessedContent)" Overwrite="true" /> | ||
|
||
| </Target> | ||
|
|
||
| <!-- Add iOS partial app manifest --> | ||
| <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'ios'"> | ||
| <PartialAppManifest Include="$(MSBuildThisFileDirectory)templates/iOS/Info.plist" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Add macOS Catalyst partial app manifest --> | ||
| <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'"> | ||
| <PartialAppManifest Include="$(MSBuildThisFileDirectory)templates/MacCatalyst/Info.plist" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Include processed files in build based on platform and build action --> | ||
| <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'android' AND '$(_ShouldGenerateDeviceTestApp)' == 'true'"> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/Android/MainActivity.cs" /> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/Android/MainApplication.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'ios' AND '$(_ShouldGenerateDeviceTestApp)' == 'true'"> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/iOS/Program.cs" /> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/iOS/AppDelegate.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst' AND '$(_ShouldGenerateDeviceTestApp)' == 'true'"> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/MacCatalyst/Program.cs" /> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/MacCatalyst/AppDelegate.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows' AND '$(_ShouldGenerateDeviceTestApp)' == 'true'"> | ||
| <Compile Include="$(IntermediateOutputPath)Platforms/Windows/App.xaml.cs" /> | ||
| <Page Include="$(IntermediateOutputPath)Platforms/Windows/App.xaml" /> | ||
| <ApplicationManifest Include="$(IntermediateOutputPath)Platforms/Windows/app.manifest" /> | ||
| <AppxManifest Include="$(IntermediateOutputPath)Platforms/Windows/Package.appxmanifest" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Exclude default Visual Studio test runner files from packaging --> | ||
| <Target Name="RemoveVisualStudioTestRunner" BeforeTargets="_ComputeAppxPackagePayload"> | ||
| <ItemGroup> | ||
| <_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> | ||
| <PackagingOutputs Remove="@(_VisualStudioTestRunnerFiles)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- Add default app icon and splash screen from templates --> | ||
| <ItemGroup> | ||
| <MauiIcon Include="$(MSBuildThisFileDirectory)templates/Resources/AppIcon/appicon.svg" ForegroundFile="$(MSBuildThisFileDirectory)templates/Resources/AppIcon/appiconfg.svg" Color="#512BD4" /> | ||
| <MauiSplashScreen Include="$(MSBuildThisFileDirectory)templates/Resources/Splash/splash.svg" Color="#512BD4" BaseSize="128,128" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,4 +27,4 @@ | |
| <key>XSAppIconAssets</key> | ||
| <string>Assets.xcassets/appicon.appiconset</string> | ||
| </dict> | ||
| </plist> | ||
| </plist> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using Android.App; | ||
| using Android.Content.PM; | ||
| using Android.OS; | ||
|
|
||
| namespace {{RootNamespace}}; | ||
|
|
||
| [Activity(Name = "{{AppId}}.MainActivity", Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] | ||
| public class MainActivity : MauiAppCompatActivity | ||
| { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using Foundation; | ||
|
|
||
| namespace {{RootNamespace}}; | ||
|
|
||
| [Register("AppDelegate")] | ||
| public class AppDelegate : MauiUIApplicationDelegate | ||
| { | ||
| protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,9 +1,9 @@ | ||||||
| ο»Ώusing Microsoft.UI.Xaml; | ||||||
| using Microsoft.UI.Xaml; | ||||||
|
|
||||||
| // To learn more about WinUI, the WinUI project structure, | ||||||
| // and more about our project templates, see: http://aka.ms/winui-project-info. | ||||||
|
|
||||||
| namespace DeviceTestingKitApp.DeviceTests.WinUI; | ||||||
| namespace {{RootNamespace}}; | ||||||
|
||||||
| namespace {{RootNamespace}}; | |
| namespace {{RootNamespace}}.WinUI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the namespace template to use {{RootNamespace}}.WinUI as suggested. Commit 7155889.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using Foundation; | ||
|
|
||
| namespace {{RootNamespace}}; | ||
|
|
||
| [Register("AppDelegate")] | ||
| public class AppDelegate : MauiUIApplicationDelegate | ||
| { | ||
| protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.