File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -222,13 +222,42 @@ function Write-Trace {
222222 }
223223}
224224
225+ function EnsureAssemblyLoadedByName {
226+ param (
227+ [Parameter (Mandatory )]
228+ [string ] $SimpleName ,
229+
230+ [string ] $Path # optional fallback
231+ )
232+
233+ $loaded = [AppDomain ]::CurrentDomain.GetAssemblies() |
234+ Where-Object { $_.GetName ().Name -eq $SimpleName } |
235+ Select-Object - First 1
236+
237+ if ($loaded ) {
238+ # Already loaded — do nothing and return the loaded assembly
239+ return $loaded
240+ }
241+
242+ if ($Path ) {
243+ # Not loaded — load from path
244+ Add-Type - Path $Path - ErrorAction Stop | Out-Null
245+ return [AppDomain ]::CurrentDomain.GetAssemblies() |
246+ Where-Object { $_.GetName ().Name -eq $SimpleName } |
247+ Select-Object - First 1
248+ }
249+
250+ throw " Assembly '$SimpleName ' is not loaded and no -Path was provided."
251+ }
252+
253+
225254function SatisfiesVersion {
226255 param (
227256 [string ]$version ,
228257 [string ]$versionRange
229258 )
230259
231- Add-Type - Path " $PSScriptRoot /dependencies/NuGet.Versioning.dll"
260+ EnsureAssemblyLoadedByName - SimpleName " NuGet.Versioning " - Path " $PSScriptRoot /dependencies/NuGet.Versioning.dll" | Out-Null
232261
233262 try {
234263 $versionRangeObj = [NuGet.Versioning.VersionRange ]::Parse($versionRange )
You can’t perform that action at this time.
0 commit comments