Move Blazor targets logic into conditional import to fix library project issues#30111
Open
Copilot wants to merge 4 commits into
Open
Move Blazor targets logic into conditional import to fix library project issues#30111Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Move the Blazor targets logic into a new file and conditionally import
Move Blazor targets logic into conditional import to fix library project issues
Jun 21, 2025
mattleibow
requested changes
Jun 21, 2025
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This was referenced May 17, 2026
Contributor
|
/review -b feature/refactor-copilot-yml |
This comment has been minimized.
This comment has been minimized.
Contributor
|
/review -b feature/enhanced-reviewer -p windows |
Collaborator
|
|
kubaflo
requested changes
Jun 6, 2026
kubaflo
left a comment
Contributor
There was a problem hiding this comment.
Can you please resolve conflicts?
Contributor
|
/review rerun |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
Microsoft.AspNetCore.Components.WebView.Maui.targetsfile was always imported into all projects by NuGet, including library projects that don't need Blazor-specific build logic. This caused unnecessary overhead and potential conflicts for library projects that reference the BlazorWebView package.Solution
Implemented a conditional import pattern by:
Microsoft.AspNetCore.Components.WebView.Maui.targetstoMicrosoft.AspNetCore.Components.WebView.Maui.Sdk.targetsMicrosoft.AspNetCore.Components.WebView.Maui.targetsthat conditionally imports the SDK targetsThe new targets file only imports the actual Blazor build logic when:
OutputType=ExeOROutputType=WinExeORAndroidApplication=TrueORImportMicrosoftAspNetCoreComponentsWebViewMauiTargets=TrueExample
Before: All projects (including libraries) would import Blazor-specific targets
After: Only application projects import the Blazor targets
Testing
✅ Library projects (OutputType=Library) - targets not imported
✅ Application projects (OutputType=Exe/WinExe) - targets imported correctly
✅ Android applications (AndroidApplication=True) - targets imported correctly
✅ Override scenario - manual import flag works
✅ All existing BlazorWebView samples and tests continue to build successfully
This is a minimal, backward-compatible change that solves the import issue while preserving all existing functionality.
Fixes #30110.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.