Support Visual Studio 2026 and write args to the active VC configuration - #199
Open
CoreyShay wants to merge 1 commit into
Open
Support Visual Studio 2026 and write args to the active VC configuration#199CoreyShay wants to merge 1 commit into
CoreyShay wants to merge 1 commit into
Conversation
Two changes are needed to make the extension usable in VS2026 (18.x): 1. Widen the VS2022 InstallationTarget from [17.0, 18.0) to [17.0, 19.0) so the VSIX can be installed at all. 2. For C/C++ projects the arguments were written to the configuration returned by VCProject.ActiveConfiguration. In VS2026 that can be a different configuration than the one which is actually active, so the arguments were written to the wrong configuration in the .vcxproj.user file and nothing was applied to the project being debugged. The arguments are selected using Project.ConfigurationManager.ActiveConfiguration (see ItemAggregationService), so resolve the VCConfiguration by matching "Configuration|Platform" against VCProject.Configurations to make the read and the write agree. If no match is found the previous behaviour is used as a fallback. The VFProjEngine (Fortran) path already avoided Project.Object.ActiveConfiguration for a similar reason. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 extension cannot be used with Visual Studio 2026 (18.x):
InstallationTargetis capped at[17.0, 18.0).args.jsonis written, but the project keeps its old arguments and the debugged process does not receive them.Cause
For C/C++ projects,
SetVCProjEngineConfigwrites toVCProject.ActiveConfiguration.In VS2026 that property can return a configuration which is not the one currently selected. In my case the active configuration was
BattleNet_GameTest|x64, but the arguments were written into theBattleNet_GameProfileSecured|x64group of the.vcxproj.user— so the configuration actually being debugged never saw them.The arguments themselves are selected using
Project.ConfigurationManager.ActiveConfiguration(ItemAggregationService), so the read side and the write side disagreed about which configuration is active.There is already precedent for
Project.Object.ActiveConfigurationbeing unreliable: the Fortran path (SetVFProjEngineConfig) deliberately usesConfigurationManager.ActiveConfiguration, with a comment noting thatProject.Object.ActiveConfigurationthrows aRuntimeBinderExceptionthere.Fix
Add
GetActiveVCConfiguration, which resolves theVCConfigurationby matching"{ConfigurationName}|{PlatformName}"(the format ofVCConfiguration.Name) fromProject.ConfigurationManager.ActiveConfigurationagainstVCProject.Configurations.This makes the read side and the write side agree. If no match is found, it logs a warning and falls back to the previous
VCProject.ActiveConfiguration, so behaviour on older Visual Studio versions is unchanged.The manifest change widens the existing
Microsoft.VisualStudio.Communitytargets (amd64 and arm64) from[17.0, 18.0)to[17.0, 19.0). It also normalises the arm64 entry, which was missing a space and read[17.0,18.0).Verification
Verified in Visual Studio 2026 Enterprise 18.7.11903.348 against a large C++ solution:
.vcxproj.user.Also verified that the VSIX still builds and the unit test suite passes (39/39).
Notes
This is rebased on top of #197, so it sits directly below the new
LoadVCPropInfo().Happy to split the manifest bump and the configuration fix into separate PRs if you would prefer that, or to adjust how VS2026 is targeted — for example a dedicated
SmartCmdArgs18project instead of widening the VS2022 range.