close
Skip to content

Use vs-pwsh icons if applicable.#19990

Merged
carlos-zamora merged 3 commits into
microsoft:mainfrom
teo-tsirpanis:vs-pwsh-icon
Mar 24, 2026
Merged

Use vs-pwsh icons if applicable.#19990
carlos-zamora merged 3 commits into
microsoft:mainfrom
teo-tsirpanis:vs-pwsh-icon

Conversation

@teo-tsirpanis
Copy link
Copy Markdown
Contributor

@teo-tsirpanis teo-tsirpanis commented Mar 18, 2026

Summary of the Pull Request

This PR updates VsDevShellGenerator to use the vs-pwsh icon in generated profiles, if modern PowerShell has been detected.

References and Relevant Issues

The icons were added in #17706, but are not used anywhere.

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

Comment on lines +50 to +53
wchar_t pwshPath[MAX_PATH] = { 0 };
const auto pwshExeName = L"pwsh.exe";
if (SearchPathW(nullptr, pwshExeName, nullptr, MAX_PATH, pwshPath, nullptr))
isPwsh = SearchPathW(nullptr, pwshExeName, nullptr, MAX_PATH, pwshPath, nullptr);
if (isPwsh)
Copy link
Copy Markdown
Member

@lhecker lhecker Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this value is used outside of this function, writing this into an out-parameter is awkward. If you think about "the flow of data" for isPwsh it now looks like this:

flowchart TD
    GenerateProfiles --> GetProfileCommandLine
    GetProfileCommandLine --> isPwsh((isPwsh))
    isPwsh --> GenerateProfiles ---> GetProfileIconPath
Loading

This looks kind of intuitively wrong, doesn't it? It would be better to write a private static bool _isPwshAvailable() noexcept member function. You can then structure it like this:

flowchart TD
    GenerateProfiles --> _isPwshAvailable --> isPwsh((isPwsh))
    isPwsh --> GetProfileCommandLine
    isPwsh --> GetProfileIconPath
Loading

You then end up with:

const auto isPwsh = _isPwshAvailable();
profile->Commandline(winrt::hstring{ GetProfileCommandLine(instance, isPwsh) });
profile->Icon(winrt::hstring{ GetProfileIconPath(isPwsh) });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it different from the old code now? Unless I'm reading it wrong, the old code would just store "pwsh.exe" in the profile. The path itself was essentially thrown away. I may be misunderstanding the old code though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I misread the code. Updated to your suggestion.

@lhecker
Copy link
Copy Markdown
Member

lhecker commented Mar 23, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@carlos-zamora
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@carlos-zamora carlos-zamora enabled auto-merge (squash) March 24, 2026 18:11
@carlos-zamora
Copy link
Copy Markdown
Member

Thanks for the contribution! Pushed a minor change (just ran the code formatter) so the new CI run shouldn't give any issues.

Enabled auto-merge and cleaned up the PR body. So we just need another ✅ from @lhecker and this should be in.

@carlos-zamora carlos-zamora merged commit e040015 into microsoft:main Mar 24, 2026
14 of 16 checks passed
@teo-tsirpanis teo-tsirpanis deleted the vs-pwsh-icon branch March 24, 2026 18:49
@github-project-automation github-project-automation Bot moved this to To Cherry Pick in 1.25 Servicing Pipeline Apr 3, 2026
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.25 Servicing Pipeline Apr 3, 2026
DHowett pushed a commit that referenced this pull request Apr 3, 2026
## Summary of the Pull Request
This PR updates `VsDevShellGenerator` to use the `vs-pwsh` icon in
generated profiles, if modern PowerShell has been detected.

## References and Relevant Issues
The icons were added in #17706, but are not used anywhere.

## Detailed Description of the Pull Request / Additional comments
* Updated `VsDevShellGenerator::GetProfileCommandLine` to accept a
`bool& isPwsh` parameter, which is set to whether the generated profile
command line is using modern PowerShell. This value gets passed to
`VsDevShellGenerator::GetProfileIconPath`'s new parameter, which
determines whether to return the icon for `powershell` or `pwsh`.

(cherry picked from commit e040015)
Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgpBNIk
Service-Version: 1.25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Cherry Picked

Development

Successfully merging this pull request may close these issues.

4 participants