Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Expand $(~) to $(HOME) or $(USERPROFILE) depending on OS #10160

Open
kzu opened this issue May 21, 2024 · 4 comments
Open
Labels
backlog Feature Request needs-design Requires discussion with the dev team before attempting a fix. Priority:2 Work that is important, but not critical for the release triaged

Comments

@kzu
Copy link
Contributor

kzu commented May 21, 2024

Summary

Currently, you need to do something like the following to consistently get the ~ home directory in a cross-platform way:

<PropertyGroup>
    <UserProfileHome Condition="'$([MSBuild]::IsOSUnixLike())' == 'true'">$(HOME)</UserProfileHome>
    <UserProfileHome Condition="'$([MSBuild]::IsOSUnixLike())' != 'true'">$(USERPROFILE)</UserProfileHome>
</PropertyGroup>

It would be awesome if the well-known shorthand ~ (even PowerShell Core knows it) could be used directly in MSBuild as a built-in envvar alias for either $(HOME) or $(USERPROFILE) depending on the current OS, just like pwsh does it.

Background and Motivation

No particular problem, just a desire for more consistency across developer tooling in the ecosystem (following the lead from pwsh).

Proposed Feature

Summary contains the proposal, which would be to consider ~ as an alias to either Home or UserProfile envvar names in Unix-like vs Windows.

Alternative Designs

No response

@danmoseley
Copy link
Member

Or MsbuildHomeDir ?

@AR-May
Copy link
Member

AR-May commented May 21, 2024

Team triage: @baronfel what do you think of this suggestion?

@baronfel
Copy link
Member

It seems reasonable to me, but we should check for consistency with the Runtime's SpecialFolders enum in addition to various popular shells like bash, zsh, fish, and pwsh.

@kzu
Copy link
Contributor Author

kzu commented May 21, 2024

@danmoseley that would be confusing, since it might mean the MSBuild home dir (i.e. where msbuild.exe lives).

@AR-May AR-May added needs-design Requires discussion with the dev team before attempting a fix. backlog Priority:2 Work that is important, but not critical for the release triaged labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Feature Request needs-design Requires discussion with the dev team before attempting a fix. Priority:2 Work that is important, but not critical for the release triaged
Projects
None yet
Development

No branches or pull requests

4 participants