boxstarter icon indicating copy to clipboard operation
boxstarter copied to clipboard

Usage of boxstarter from network share failed

Open SheGe opened this issue 7 years ago • 4 comments

Hi,

Usage of boxstarter from network share from the latest Win 10 Pro failed probably because the problems with loading the *.dll files from Network Share.

Add-Type : Could not load file or assembly
'file://\\***\BoxShare/boxstarter.chocolatey/chocolatey/log4net.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At \\***\BoxShare\Boxstarter.Chocolatey\invoke-chocolatey.ps1:15 char:13
+             Add-Type -Path $_
+             ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

Steps to reproduce:

  1. Using the script below install latest boxstarter on network share host system (xxx), the command found in documentation here

    . { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
    
  2. From network share host system execute this command to create the network share, the command found in documentation here

    Set-BoxstarterShare BoxShare
    
  3. ~~Create the file with content as follow in this location $env:TEMP\install.ps1 on the fresh Win 10 VM:~~ Usage of the powershell script is not allowed, because Read Only permission on the share - usage of existing package is required

    Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions
    
  4. From the same Win 10 VM execute the command below from powershell console running as administrator:

    & \\xxx\BoxShare\BoxStarter MyPackage
    

Full console output:

Boxstarter: Installing package C:\Users\Admin\AppData\Local\Temp\install.ps1
Boxstarter Version 2.11.0
(c) 2018 Chocolatey Software, Inc, 2012 - 2018 Matt Wrock. https://boxstarter.org

Please type CTRL+C or close this window to exit Boxstarter if you do not want to risk a reboot during this Boxstarter install.

Boxstarter may need to reboot your system.
Please provide your password so that Boxstarter may automatically log you on.
Your password will be securely stored and encrypted.
Autologon Password: ******************
Boxstarter: Successfully authenticated password.
Boxstarter: Disabling Automatic Updates from Windows Update
Boxstarter: Restore Automatic Updates from Windows Update
Add-Type : Could not load file or assembly
'file://\\xxx\BoxShare/boxstarter.chocolatey/chocolatey/log4net.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At \\xxx\BoxShare\Boxstarter.Chocolatey\invoke-chocolatey.ps1:15 char:13
+             Add-Type -Path $_
+             ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

Do you have any suggestions how resolve this issue?

Thanks

SheGe avatar Jul 31 '18 08:07 SheGe

I think this might be the same problem as #324

flcdrg avatar Jul 31 '18 09:07 flcdrg

Might be, but from my understanding of this issue this can be related to .NET itself as described: here, more about loading resources from remote sources in Microsoft Documentation. Changing these files temporary - like auto login, or Windows Updates should help.

SheGe avatar Jul 31 '18 11:07 SheGe

Can you confirm if file://\xxx\BoxShare/boxstarter.chocolatey/chocolatey/log4net.dll exists?

If it doesn't, then I think this is #324. If not, then it probably is different.

flcdrg avatar Aug 01 '18 00:08 flcdrg

Yes, all files exist. Today I've investigated this more and the problem seems to be related to the way how assemblies are loading in invoke-chocolatey.ps1 script. Setting the environment variable [Environment]::SetEnvironmentVariable("TestingBoxstarter", $true) before triggering boxstarter resolved my issue.

if($env:TestingBoxstarter) {
    Write-BoxstarterMessage "loading choco bytes" -Verbose
    [System.Reflection.Assembly]::Load([io.file]::ReadAllBytes($_))
}
else {
    Write-BoxstarterMessage "loading choco from path" -Verbose
    Add-Type -Path $_
}

SheGe avatar Aug 01 '18 07:08 SheGe