Skip to content

Running into Package Problems #87

@mandalorianbob

Description

@mandalorianbob

Hi, I'm trying to use Cake.Powershell with a Powershell module that I download and install via Install-Module from the PSGallery.

I can run these commands in an admin Powershell window, but when I try to run it through the Cake.Powershell module it throws an exception. The commands are:

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Find-Module UnitySetup

The actual calling code is

return context.StartPowershellScript(@"
                Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
                Find-Module UnitySetup",
                new PowershellSettings()
                {
                    Modules = new List<string>() { "PowershellGet"},
                    BypassExecutionPolicy = true,
                    OutputToAppConsole = true
                }).Count > 1;

(I'm just trying to detect if it succesfully finds UnitySetup - installing the package provider probably throws off what gets returned, so I'll probably have to adjust my logic once I get it to stop throwing exceptions)
And the exception I get is:

Unhandled Exception - Message:'The type initializer for 'Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType' threw an exception.' Name:'TypeInitializationException' Stack Trace:' at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.Create(Type tInterface, OrderedDictionary2 instanceMethods, List2 delegateMethods, List1 stubMethods, List2 usedInstances)

Now I see you have Powershell Core enabled only for Linux. I'd just like to ask that if practicable, that there be an option for Windows users to use Powershell Core instead of Powershell. I'm like, 90% sure that this problem would vanish in Powershell Core.

However, do you have any thoughts on what I can do to try to mitigate this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions