On day to day basis we need to install some content packages from one environment to another. For that we are using SPE module and the below script to install the package zip. But it usually fails due to the below mentioned error.

Install-Package : The type initializer for 'Sitecore.Install.Serialization.IOUtils' threw an
At line:5 char:3
+         Install-Package -Path C:\Sitecore\build\DEV2_robots_file_cont ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], TypeInitializationException
    + FullyQualifiedErrorId : System.TypeInitializationException,Spe.Commands.Packages.InstallPac

We have already googled around but could not find any solution for the error. This is what we have tried till now:

  1. Verified the powershell version and the SPE version. (Both are similar)
PS C:\BuildAgent\work\c64f5a4228e7f408\WebDeploy> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.3866
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.3866
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3

PS C:\BuildAgent\work\c64f5a4228e7f408\WebDeploy> Import-Module -Name SPE
PS C:\BuildAgent\work\c64f5a4228e7f408\WebDeploy> Get-Module -Name SPE

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     5.1.0      SPE                                 {ConvertFrom-CliXml, ConvertTo-CliXml, Invoke-GenericMethod, Invoke-RemoteScript...}
  1. Checked and tried replacing Mvp.Xml.dll from local to the environment. It also did not work.

Below is the code which we are using.

    Import-Module -Name SPE
$session = New-ScriptSession -Username speremoting -Password spe -ConnectionUri https://<env_url>
Write-Host $session
Invoke-RemoteScript -Session $session -ScriptBlock {
        # This may make the code easier to maintain.
        Install-Package -Path C:\Sitecore\build\ZIPNAME -InstallMode Merge -MergeMode Merge
Stop-ScriptSession -Session $session
  1. Also tested with help of the below link (but did not work): https://gist.github.com/michaellwest/14e9ef98f9e8b450c1b39813d13cbc50#file-speremoting-simpleremoteinstall-ps1

NOTE: When the above error come. These are the steps we do and the script starts working again.

  1. Restart IIS of the environment.
  2. Go on the Package installation page on CM and click on Upload package. If the dialog box opens the script works.

Please direct me to fix this issue, as we need a solution for this. Or if there is some other script which we can try.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.