File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,9 +42,25 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
4242 {
4343 var solution = await VS . Solutions . GetCurrentSolutionAsync ( ) . ConfigureAwait ( false )
4444 ?? throw new InvalidOperationException ( "Open a solution before adding a Dataverse solution project." ) ;
45- var initialParentDirectory = Path . GetDirectoryName ( solution . FullPath )
45+ var solutionDir = Path . GetDirectoryName ( solution . FullPath )
4646 ?? throw new InvalidOperationException ( "The current solution must be saved before adding a project." ) ;
4747
48+ // When invoked from a solution folder, use that folder's path; otherwise fall back to solution directory.
49+ var selectedItems = await VS . Solutions . GetActiveItemsAsync ( ) . ConfigureAwait ( false ) ;
50+ var initialParentDirectory = solutionDir ;
51+ foreach ( var item in selectedItems )
52+ {
53+ if ( item . Type == SolutionItemType . SolutionFolder && ! string . IsNullOrEmpty ( item . FullPath ) )
54+ {
55+ var folderDir = Path . GetDirectoryName ( item . FullPath ) ;
56+ if ( ! string . IsNullOrEmpty ( folderDir ) )
57+ {
58+ initialParentDirectory = folderDir ;
59+ }
60+ break ;
61+ }
62+ }
63+
4864 var request = await DataverseSolutionProjectDialog . ShowDialogAsync (
4965 initialParentDirectory ,
5066 RepositoryFactory ,
Original file line number Diff line number Diff line change 137137 <CanonicalName >.XrmTools.ResetTemplates</CanonicalName >
138138 </Strings >
139139 </Button >
140- <Button guid =" XrmToolsCmdSetId" id =" AddDataverseSolutionProjectCmdId" priority =" 0x0100" type =" Button" >
141- <Parent guid =" XrmToolsCmdSetId" id =" XrmToolsSolutionContextMenuGroup" />
140+ <!-- [Solution Context Menu] > [Add] > "Dataverse Solution Project..."-->
141+ <Button guid =" XrmToolsCmdSetId" id =" AddDataverseSolutionProjectCmdId" priority =" 0x0900" type =" Button" >
142+ <Parent guid =" guidSHLMainMenu" id =" IDG_VS_CTXT_SOLUTION_ADD_PROJ" />
142143 <Icon guid =" ImageCatalogGuid" id =" Package" />
143144 <CommandFlag >IconIsMoniker</CommandFlag >
144145 <Strings >
145- <ButtonText >Add Dataverse Solution Project...</ButtonText >
146+ <ButtonText >Dataverse Solution Project...</ButtonText >
146147 <CanonicalName >.XrmTools.DataverseSolution.AddProject</CanonicalName >
147148 </Strings >
148149 </Button >
353354 <!-- <CommandPlacement guid="XrmToolsCmdSetId" id="NewPluginDefinitionCmdId" priority="0x0200">
354355 <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_SLNFLDR_ADD_ITEM"/>
355356 </CommandPlacement>-->
357+ <!-- [Solution Folder Context Menu] > [Add] > "Dataverse Solution Project..."-->
358+ <CommandPlacement guid =" XrmToolsCmdSetId" id =" AddDataverseSolutionProjectCmdId" priority =" 0x0900" >
359+ <Parent guid =" guidSHLMainMenu" id =" IDG_VS_CTXT_SLNFLDR_ADD_PROJ" />
360+ </CommandPlacement >
356361 <!-- Project Context Menu > "Set environment..."-->
357362 <CommandPlacement guid =" XrmToolsCmdSetId" id =" SetEnvironmentCmdId" priority =" 0x0200" >
358363 <Parent guid =" XrmToolsCmdSetId" id =" XrmToolsProjectContextMenuGroup" />
You can’t perform that action at this time.
0 commit comments