Usage of boxstarter from network share failed
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:
-
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 -
From network share host system execute this command to create the network share, the command found in documentation here
Set-BoxstarterShare BoxShare -
~~Create the file with content as follow in this location
$env:TEMP\install.ps1on 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 requiredSet-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -
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
I think this might be the same problem as #324
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.
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.
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 $_
}