Skip to content

Save/Install-Script Uses ScriptSourceLocation instead of SourceLocation for Module Dependencies #58

@ThomasNieto

Description

@ThomasNieto

Save-Script and Install-Script queries required modules from ScriptSourceLocation not SourceLocation repository.

Steps to reproduce

  1. Create a script that requires a module
  2. Store module and script on separate repositories
  3. Save or Install script
Get-PSRepository | Select-Object -Property *

Name                      : production
SourceLocation            : https://internalrepo/api/nuget/psmodule-production
Trusted                   : True
Registered                : True
InstallationPolicy        : Trusted
PackageManagementProvider : NuGet
PublishLocation           :
ScriptSourceLocation      : https://internalrepo/api/nuget/psscript-production
ScriptPublishLocation     :
ProviderOptions           : {}

Install-Script -Name Script1

Expected behavior

Save-Script and Install-Script should install/save module dependencies from SourceLocation and install/save script from ScriptSourceLocation without error.

Actual behavior

Install-Script tries to find Module1 in psscript-production repository instead of psmodule-production.

PS C:\> Install-Script Script1 -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://internalrepo/api/nuget/psscript-production' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://internalrepo/api/nuget/psscript-production/FindPackagesById()?id='Script1'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'Script1'.
VERBOSE: Performing the operation "Install-Script" on target "Version '1.0.0' of script 'Script1'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified script will be installed in 'C:\Program Files\WindowsPowerShell\Scripts' and its dependent modules will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading script 'Script1' with version '1.0.0' from the repository 'https://internalrepo/api/nuget/psscript-production'.
VERBOSE: Searching repository 'https://internalrepo/api/nuget/psscript-production/FindPackagesById()?id='Script1'' for ''.
VERBOSE: Searching repository 'https://internalrepo/api/nuget/psscript-production/FindPackagesById()?id='Module1'' for ''.
PackageManagement\Install-Package : Unable to find dependent script(s) (Module1)
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:9637 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Module1:String) [Install-Package], Exception
    + FullyQualifiedErrorId : UnableToFindDependencyPackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.36470
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.2.4      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     2.0.4      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     2.0.3      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     2.0.1      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
nuget                    2.8.5.208
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            2.0.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Command, Ac...
PowerShellGet            2.0.3.0
PowerShellGet            2.0.1.0
PowerShellGet            1.0.0.1
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions