Consolidate duplicate VSHostObject implementations#53028
Open
YuliiaKovalova wants to merge 3 commits intorelease/10.0.3xxfrom
Open
Consolidate duplicate VSHostObject implementations#53028YuliiaKovalova wants to merge 3 commits intorelease/10.0.3xxfrom
YuliiaKovalova wants to merge 3 commits intorelease/10.0.3xxfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates two independent VSHostObject implementations that were duplicated across the Microsoft.NET.Build.Containers and Microsoft.NET.Sdk.Publish.Tasks projects. The consolidated implementation is placed in src/Common/VSHostObject.cs following the repo's established pattern for shared code, and uses the more robust JSON-based QueryAllTaskItems reflection protocol from the Containers version with IEnumerable fallback.
Changes:
- Moved VSHostObject implementation to src/Common with namespace change to Microsoft.NET.Sdk.Common
- Updated all usage sites to use the new constructor signature and API methods (TryGetCredentials, GetTaskItems)
- Enhanced metadata handling to copy all metadata from JSON DTOs while gracefully handling reserved MSBuild metadata names
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Common/VSHostObject.cs | Consolidated VSHostObject implementation with improved documentation, public GetTaskItems method, and robust metadata handling |
| src/WebSdk/Publish/Tasks/Tasks/ZipDeploy/ZipDeploy.cs | Updated to use new VSHostObject constructor and TryGetCredentials API |
| src/WebSdk/Publish/Tasks/Tasks/OneDeploy/OneDeploy.cs | Updated to use new VSHostObject constructor and TryGetCredentials API |
| src/WebSdk/Publish/Tasks/Tasks/MsDeploy/VsMsdeploy.cs | Updated to use new VSHostObject constructor, TryGetCredentials, and GetTaskItems APIs with inline file skip filtering |
| src/WebSdk/Publish/Tasks/MsDeploy/VSHostObject.cs | Deleted - replaced by shared implementation in src/Common |
| src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj | Added Compile link to src/Common/VSHostObject.cs |
| src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImageToolTask.cs | Added using directive for Microsoft.NET.Sdk.Common namespace |
| src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs | Added using directive for Microsoft.NET.Sdk.Common namespace |
| src/Containers/Microsoft.NET.Build.Containers/Microsoft.NET.Build.Containers.csproj | Removed old VSHostObject.cs, added Compile link to src/Common/VSHostObject.cs |
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.
Summary
There were two independent VSHostObject classes serving the same purpose — extracting credentials from a Visual Studio host object — one in Microsoft.NET.Build.Containers and one in Microsoft.NET.Sdk.Publish.Tasks. This PR consolidates them into a single shared implementation, following the repo's existing pattern for shared code (e.g., EnvironmentVariableNames.cs)
Details
Eliminate code duplication between the Containers and WebSdk projects.
The Containers version had a more robust implementation (JSON-based QueryAllTaskItems reflection protocol with [IEnumerable fallback), while the WebSdk version only supported the legacy IEnumerable path. The consolidated version gives both projects the improved behavior.