diff --git a/Install-Dependencies.ps1 b/Install-Dependencies.ps1 index 701478c..9189a0c 100644 --- a/Install-Dependencies.ps1 +++ b/Install-Dependencies.ps1 @@ -7,6 +7,13 @@ Installs prerequisites for SharePoint XLS Converter application # Enable TLS 1.2 for secure connections [Net.ServicePointManager]::SecurityProtocol = [enum]::Parse([Net.SecurityProtocolType], "Tls12") +# Verify .NET Framework 4.6+ is installed +if (-not (Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' | Get-ItemPropertyValue -Name Release | ForEach-Object { $_ -ge 394802 })) { + Write-Host "ERROR: Requires .NET Framework 4.6.2 or newer!" -ForegroundColor Red + Write-Host "Download from: https://dotnet.microsoft.com/download/dotnet-framework" -ForegroundColor Yellow + exit 1 +} + Write-Host "Installing required modules..." -ForegroundColor Cyan # Install Microsoft.Graph modules @@ -40,15 +47,16 @@ try { } # Install OpenXML SDK package - $openXmlPackage = Install-Package DocumentFormat.OpenXml -Source https://www.nuget.org/api/v2/ -Force -SkipDependencies - $dllPath = Join-Path $openXmlPackage.PackageSource "lib\net46\DocumentFormat.OpenXml.dll" - - if (Test-Path $dllPath) { + $openXmlPackage = Install-Package DocumentFormat.OpenXml -ProviderName NuGet -Force -SkipDependencies + $packagePath = Join-Path $env:USERPROFILE ".nuget\packages\DocumentFormat.OpenXml" + $dllPath = Resolve-Path (Join-Path $packagePath "*\lib\net*\DocumentFormat.OpenXml.dll") -ErrorAction SilentlyContinue | Select-Object -First 1 + + if ($dllPath -and (Test-Path $dllPath)) { Add-Type -Path $dllPath Write-Host "DocumentFormat.OpenXml assembly loaded successfully" -ForegroundColor Green } else { - throw "OpenXML DLL not found at $dllPath" + throw "OpenXML DLL not found in NuGet packages. Tried path: $packagePath" } } catch {