PowerShell / PackageManagementProviderResource

Modules with DSC resources for the PackageManagement(aka OneGet) providers.
MIT License
37 stars 24 forks source link

PackageManagementProviderResource DSC resource does not work with local PSGallery #34

Closed vyckou closed 7 years ago

vyckou commented 7 years ago

issue_screenshot Local PowerShell gallery is running on Artifactory nuget repository It has been registered in the powershell as LocalPSGallery using PS C:\Users\MyUser> Register-PackageSource -Name LocalPSGallery -Location http://artifactory.xxxxxxxxxx.net/artifactory/api/nuget/db-nuget-windows_PSGallery -force -ProviderName PowerShellGet

I can successfully find my module "update-module" using find-module 'update-module' I can download and install it using install-module 'update-module' -Repository 'LocalPSGallery'

But DSC fails with the errors: **Unable to find package source 'LocalPSGallery'. Use Get-PackageSource to see all available package sources.

VERBOSE: [WE0031]: [[PSModule]MyPSModule] Source '' not found. Please make sure you register it. VERBOSE: [WE0031]: [[PSModule]MyPSModule] Begin invoking find-module 'update-module' **Unable to find repository 'LocalPSGallery'. Use Get-PSRepository to see all available repositories.

vyckou commented 7 years ago

Appears it does work, only you need to include Local PSGallery source DSC before specifying DSC for module. Added following configuration PackageManagementSource LocalPSGallery { Ensure = "Present" Name = "LocalPSgallery" ProviderName= "PowerShellGet" SourceUri = "http://artifactory.xxxxxx.net/artifactory/api/nuget/db-nuget-windows_PSGallery"
InstallationPolicy ="Trusted" }

before PSModule MyPSModule { Ensure = "present" Name = $Name RequiredVersion = "1.0.0.0"
Repository = "LocalPSGallery" InstallationPolicy="trusted"
}

and it works like a charm

jianyunt commented 7 years ago

@vyckou , PackageManagementSource registers package source to your local repo. I'm glad it worked out for you.

vyckou commented 7 years ago

Are there any chances to specify somewhere/somehow global package repo? That everyone could use this repo, whoever logons to the server/workstation? As with the current DSC PackageManagementSource works only for the System context, where LCM is being executed.

jianyunt commented 7 years ago

No. It's per user. The design is mainly for security concerns.

vyckou commented 7 years ago

I have managed to solve that, by adding/modifying register-packagesource command into C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 which is executed on every single run of the powerhshell. Can be easy achieved by DSC, only using not this resource, but custom- changing file contentes ;)

jianyunt commented 7 years ago

I see. it's not convenient. Any reasons you need everyone to access the repo?

I recommend you open issue for supporting AllUser in github.com/PowerShell/PowerShellGet.