Skip to content

Expose Platform API from SMA and uses that in NuGetProvider - #1282

Merged
Quoc Truong (quoctruong) merged 2 commits into
masterfrom
quoct/fixnugetprovider
Jul 6, 2016
Merged

Quoc Truong (quoctruong) merged 2 commits into
masterfrom
quoct/fixnugetprovider

Conversation

@quoctruong

@quoctruong Quoc Truong (quoctruong) commented Jul 5, 2016 •

Copy link
Copy Markdown

Make the Platform class public.
Added PowerShell location to the XDG_Type enum.
Uses these locations in NuGetProvider


This change is Reviewable

@@ -50,6 +50,7 @@ public enum XDG_Type
PROFILE,

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.

Add comment to each of these to specify what they are used for

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think adding POWERSEHLL to XDG_Type enum does not seem to be cohesive. In your case, should default powershell path be enough?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would say returning xdgPowerShellDefault directory should be good enough for NuGet provider.

@andyleejordan Andy Jordan (andyleejordan) Jul 5, 2016 •

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.

That would leave us not implementing XDG BDS at all. (For this particular case.)

string xdgcachehome = System.Environment.GetEnvironmentVariable("XDG_CACHE_HOME");
string xdgConfigHomeDefault = Path.Combine ( System.Environment.GetEnvironmentVariable("HOME"), ".config", "powershell");
string xdgModuleDefault = Path.Combine ( System.Environment.GetEnvironmentVariable("HOME"), ".local", "share", "powershell", "Modules");
string xdgPowerShellDefault = Path.Combine( System.Environment.GetEnvironmentVariable("HOME"), ".local", "share", "powershell");

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.

I like this, but at this point, it should rightfully be called what it is: xdgDataHomeDefault.

@quoctruong

Copy link
Copy Markdown
Author

src/Microsoft.PackageManagement.NuGetProvider/NugetLightRequest.cs, line 241 [r1] (raw file):

Previously, andschwa (Andy Schwartzmeyer) wrote…

The one thing that makes me uncomfortable with this is that it is, by its nature, user dependent. This will be the user's default install location. A shared "all user" location would need to be where PowerShell resides, so /opt/microsoft/powershell/PackageManagement. But that likewise makes me uncomfortable as the powershell folder is owned by the package, which has every right to rewrite the whole folder on upgrade. Perhaps go up a directory, to /opt/microsoft/PackageManagement. Raghu Shantha (@raghushantha) what do you think?

I didn't separate user installation and admin installation location because if an admin wants to, he/she can still specify the Destination directly. Also, Andy Jordan (@andschwa) , is there a way to check whether the cmdlet is run on sudo or not?

Comments from Reviewable


case Platform.XDG_Type.MODULES:
//the user has set XDG_DATA_HOME corresponding to module path
if (String.IsNullOrEmpty(xdgdatahome)){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DATA is better.

@raghushantha

Copy link
Copy Markdown
Member

:shipit:

@raghushantha Raghu Shantha (raghushantha) added the Area-PackageManagement specific to PackageManagement module (aka OneGet) label Jul 6, 2016
@quoctruong

Copy link
Copy Markdown
Author

Thanks!

@quoctruong
Quoc Truong (quoctruong) merged commit 862b7f4 into master Jul 6, 2016
@quoctruong
Quoc Truong (quoctruong) deleted the quoct/fixnugetprovider branch July 6, 2016 19:16
@andyleejordan

Copy link
Copy Markdown
Member

Ah GitHub went down as I tried to add this: :shipit:

Thanks Quoc Truong (@quoctruong)!

@andyleejordan

Copy link
Copy Markdown
Member

I can't seem to reply directly to this Quoc Truong (@quoctruong):

I didn't separate user installation and admin installation location because if an admin wants to, he/she can still specify the Destination directly. Also, Andy Jordan (@andschwa) , is there a way to check whether the cmdlet is run on sudo or not?

Cmdlets themselves won't be run as sudo, as they're not separate processes. But PowerShell may have been. If you need to check the process, I believe you check EUID, which will be 0 when running as root.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…ider

Expose Platform API from SMA and uses that in NuGetProvider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-PackageManagement specific to PackageManagement module (aka OneGet)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants