Not able to use Windows Script Host Object Model in .net 3.5 project
See the question and my original answer on StackOverflowVisual Studio uses a SDK tool named TlbImp.exe to build COM references import files. The MsBuild task that does that is named ResolveComReference. This task uses an algorithm that tries to find the proper TlbImp version on the machine that builds the project.
In your case as we see it from msbuild diagnostics, it uses the TlbImp from "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools
". Unfortunately, this TlbImp builds CLR 4 assemblies. So you need to use another TlbImp. On my machine, it uses it from "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin
" which builds CLR 2 assembly. You probably don't have that TlbImp installed on your build machine so the algorithm redirects silently to the newer one (sounds like a bug, I think it should report the problem, but I'm unsure).
To fix this, you can install an older version of Visual Studio or Windows SDK and it should work magically, or you can configure your project to use a proper TlbImp V3.5 if you have it on your machine somewhere (if you don't have it, then you must install something).
Here is how to modify the MsBuild project from Visual Studio:
- right click on the project node, Unload Project
- right click on the project node and Edit Project
- add the following line to your msbuild project file
- right click on the project node and Reload project
- rebuild
...
<PropertyGroup>
... other properties ...
... <ResolveComReferenceToolPath should point to a directory that contains TLBIMP V3.5
<ResolveComReferenceToolPath>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin</ResolveComReferenceToolPath>
</PropertyGroup>
...