I've suddenly got a problem with a script that has been running without problems previously
$sln = 'D:\[...]\[...].sln'
Add-Type -Path (${env:ProgramFiles(x86)} + '\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Microsoft.Build.dll')
$slnFile = [Microsoft.Build.Construction.SolutionFile]::Parse($sln)
The Add-Type
seems to work without an error, but the next line keeps throwing an error
Unable to find type [Microsoft.Build.Construction.SolutionFile].
At D:\[...]\[scriptname].ps1:7 char:13
+ $slnFile = [Microsoft.Build.Construction.SolutionFile]::Parse($sl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Build...on.SolutionFile:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
The script was based on several examples
- https://stackoverflow.com/a/49600306
- https://stackoverflow.com/a/41753608
- Where solution build order is saved
And it worked in the past. I'm still pointing to the same old Microsoft.Build.dll assembly. Can anybody explain to me what's changed?