-
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?
Conversation
Co-authored-by: mattleibow <[email protected]>
…urces need fixing) Co-authored-by: mattleibow <[email protected]>
mattleibow
left a comment
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.
We don't need the sample-sourcegen-test project. Update the DeviceTestingKitApp.DeviceTests project to use this new source gen.
Also, no need for the new TestApp, since the sample test is the test app.
src/DeviceRunners.SourceGenerators/Templates/MauiProgram.cs.template
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/Templates/Properties/launchSettings.json.template
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/Templates/Usings.cs.template
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/Templates/Platforms/Windows/App.xaml.cs.template
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/Templates/Platforms/Android/MainApplication.cs.template
Outdated
Show resolved
Hide resolved
…ceTests to use source generator Co-authored-by: mattleibow <[email protected]>
Done. Removed the |
…e names Co-authored-by: mattleibow <[email protected]>
mattleibow
left a comment
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.
no need for the attributes project, look in the host csproj for msbuild props.
src/DeviceRunners.SourceGenerators.Attributes/DeviceRunners.SourceGenerators.Attributes.csproj
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators.Attributes/DeviceTestAppAttribute.cs
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators.Attributes/DeviceTestAppAttribute.cs
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators.Attributes/DeviceTestAppAttribute.cs
Outdated
Show resolved
Hide resolved
… source generator to use MSBuild properties Co-authored-by: mattleibow <[email protected]>
Removed the attributes project entirely. The source generator now uses MSBuild properties (ApplicationTitle, ApplicationId) instead of attributes. Commit 69bc566. |
mattleibow
left a comment
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.
Please also make the targets file do the right things. This needs to be a drop-in test suite system.
src/DeviceRunners.SourceGenerators/Templates/Platforms/MacCatalyst/AppDelegate.cs.template
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/Templates/Platforms/Windows/App.xaml.cs.template
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/Templates/Platforms/iOS/AppDelegate.cs.template
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/build/DeviceRunners.SourceGenerators.props
Outdated
Show resolved
Hide resolved
sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj
Outdated
Show resolved
Hide resolved
src/DeviceRunners.SourceGenerators/build/DeviceRunners.SourceGenerators.targets
Outdated
Show resolved
Hide resolved
test/DeviceRunners.SourceGenerators.Tests/DeviceTestAppGeneratorTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: mattleibow <[email protected]>
Updated targets file with complete MSBuild integration - adds Info.plist files as PartialAppManifest, processes Windows XAML/manifest files, and excludes Visual Studio test runner files. The source generator now auto-detects MAUI projects with test frameworks for a true drop-in experience. Commit b0d69a2. |
Co-authored-by: mattleibow <[email protected]>
src/DeviceRunners.SourceGenerators/build/DeviceRunners.SourceGenerators.targets
Outdated
Show resolved
Hide resolved
sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj
Show resolved
Hide resolved
...unners.VisualRunners.Maui.Bootstrap/build/DeviceRunners.VisualRunners.Maui.Bootstrap.targets
Show resolved
Hide resolved
…or for template processing Co-authored-by: mattleibow <[email protected]>
| </ItemGroup> | ||
|
|
||
| <!-- Import the device test app generation targets from Bootstrap package --> | ||
| <Import Project="..\..\..\src\DeviceRunners.VisualRunners.Maui.Bootstrap\build\DeviceRunners.VisualRunners.Maui.Bootstrap.props" /> |
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.
The props should be right at the top of the file. The first thing.
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.
Moved the props imports to the top of the project file, right after the Project element. Commit 7155889.
| <_ProcessedContent>$(_TemplateContent.Replace('{{RootNamespace}}', '$(RootNamespace)'))</_ProcessedContent> | ||
| <_ProcessedContent>$(_ProcessedContent.Replace('{{ApplicationTitle}}', '$(ApplicationTitle)'))</_ProcessedContent> | ||
| <_ProcessedContent>$(_ProcessedContent.Replace('{{ApplicationId}}', '$(ApplicationId)'))</_ProcessedContent> | ||
| <_ProcessedContent>$(_ProcessedContent.Replace('{{AppId}}', '$(ApplicationId)'))</_ProcessedContent> |
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.
Replace all AppId templating instances with ApplicationId. No need to have of the same.
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.
Replaced all AppId templating instances with ApplicationId in both the targets file and template files. Commit 7155889.
| </PropertyGroup> | ||
|
|
||
| <!-- Write processed file --> | ||
| <WriteLinesToFile File="%(TemplateFile.Destination)" Lines="$(_ProcessedContent)" Overwrite="true" /> |
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.
This task has a WriteOnlyWhenDifferent which we want to be true to reduce build churn
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.
Added WriteOnlyWhenDifferent="true" to the WriteLinesToFile task to reduce build churn. Commit 7155889.
| // and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
|
||
| namespace DeviceTestingKitApp.DeviceTests.WinUI; | ||
| namespace {{RootNamespace}}; |
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.
| 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.
…ove build performance Co-authored-by: mattleibow <[email protected]>
|
|
||
| <!-- 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" /> |
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.
The props at the top, the targets at the bottom.
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 import ordering - props import moved to top, targets import moved to bottom of the project file. Commit 358c652.
...unners.VisualRunners.Maui.Bootstrap/build/DeviceRunners.VisualRunners.Maui.Bootstrap.targets
Show resolved
Hide resolved
...unners.VisualRunners.Maui.Bootstrap/build/DeviceRunners.VisualRunners.Maui.Bootstrap.targets
Outdated
Show resolved
Hide resolved
Co-authored-by: mattleibow <[email protected]>
|
@copilot Right now, the PR title and description is no longer correct for this PR. Can you give me a new title and description in markdown that I can copy paste directly. Make sure it encompases all the changes and focuses on the changes. Also note any issues you had and share them. |
Here's the updated PR title and description: TitleCreate MSBuild template system for automatic DeviceRunners test app bootstrap DescriptionThis PR introduces a comprehensive MSBuild-based template system that automatically generates all the boilerplate files needed for a DeviceRunners test app, eliminating the need for developers to manually create and maintain platform-specific files. 🔧 Bootstrap Infrastructure
🏗️ Generated FilesThe bootstrap system automatically creates platform-specific entry points:
📝 Simple UsageDevelopers can now create a device test app by simply:
The system automatically detects MAUI projects and generates all necessary files. ⚙️ ConfigurationUses standard MSBuild properties:
🧪 Testing & Validation
✅ Benefits
🔄 Evolution NotesThis PR initially started as a Roslyn source generator but evolved into a simpler, more maintainable MSBuild template system after realizing that complex code generation wasn't necessary - simple file templating with string replacement achieves the same goal with much less complexity. 💡 Key Technical Decisions
This represents a major step toward making device testing as simple as installing a NuGet package. Addressing #88. |
This PR introduces a comprehensive MSBuild-based template system that automatically generates all the boilerplate files needed for a DeviceRunners test app, eliminating the need for developers to manually create and maintain platform-specific files.
🔧 Bootstrap Infrastructure
🏗️ Generated Files
The bootstrap system automatically creates platform-specific entry points:
MainActivity.cs,MainApplication.csProgram.cs,AppDelegate.cs,Info.plist(via PartialAppManifest)App.xaml.cs,App.xaml,app.manifest,Package.appxmanifestProgram.cs,AppDelegate.cs,Info.plist(via PartialAppManifest)📝 Simple Usage
Developers can now create a device test app by simply:
DeviceRunners.VisualRunners.Maui.BootstrapThe system automatically detects MAUI projects and generates all necessary files.
⚙️ Configuration
Uses standard MSBuild properties:
ApplicationTitle- Application display nameApplicationId- Bundle/package identifierRootNamespace- Code namespace🧪 Testing & Validation
DeviceTestingKitApp.DeviceTestssample✅ Benefits
🔄 Evolution Notes
This PR initially started as a Roslyn source generator but evolved into a simpler, more maintainable MSBuild template system after realizing that complex code generation wasn't necessary - simple file templating with string replacement achieves the same goal with much less complexity.
💡 Key Technical Decisions
build/templates/folderThis represents a major step toward making device testing as simple as installing a NuGet package.
Addressing #88.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.