Unable to find type [Microsoft.Build.Construction.SolutionFile]

425 views Asked by At

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

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?

0

There are 0 answers