Question

I want to run a prebuild target which I'm coding up in a csproj. This needs to run tlbimp to produce a dll my project references.

I'm trying to exec tlbimp, but am getting errors that it can't be found. Is there an msbuild variable or environment variable I can use to deduce the path to it?

Was it helpful?

Solution 2

There might not be a direct variable, but you can use some built-in variables to construct the path. As on my machine, I have tlbim.exe in multiple locations:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\TlbImp.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\TlbImp.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\TlbImp.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64\TlbImp.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\TlbImp.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64\TlbImp.exe
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\TlbImp.exe
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\TlbImp.exe

And I can use my desired Tlbim.exe using Windows default environment variables for "C:\Program files" folder as:

"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64\Tlbimp.exe"

In Msbuild projects, you will have to use $(var) instead of %var%, so it should be like:

"$(ProgramFiles(x86))\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64\Tlbimp.exe"

Hope you got the idea...

OTHER TIPS

With MSBuild 12 (VS2013),

$(TargetFrameworkSDKToolsDirectory)

points to

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\

i.e. tlbimp.exe is at

"$(TargetFrameworkSDKToolsDirectory)tlbimp.exe"

(Where is this defined?)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top