April 7, 2008

'..resgen.exe' failed to start... The system cannot find the file specified

Do you get an error with nant that looks like this:


[nant] C:\projects\...\Build-Scripts\......nant.build build
Buildfile: file:///C:/projects/.../Build-Scripts/....nant.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: build


build:

[echo] Building '...': build.defines:'DEBUG;TRACE', dir.builddestination:'C:\projects\...\Source\build\...-debug-bin', build.debug:False
[csc] Compiling 17 files to 'C:\projects\...\Source\build\...-debug-bin\....dll'.

BUILD FAILED

'C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\resgen.exe' failed to start.
The system cannot find the file specified



I ran into this because I only installed VS2008 on this machine and a whacky VS2005 shell gets installed by SQL 2005 that has screwed up multiple tools, one of them is nant. To fix nant do the following:
Find NAnt.exe.config in the same directory as nant.exe. Find the element that begins

<framework
name="net-2.0"
...


Within that element you'll find the following:


<project>
<readregistry
property="installRoot"
key="SOFTWARE\Microsoft\.NETFramework\InstallRoot"
hive="LocalMachine" />
<readregistry
property="sdkInstallRoot"
key="SOFTWARE\Microsoft\.NETFramework\sdkInstallRootv2.0"
hive="LocalMachine"
failonerror="false" />
</project>




Note how it looks in the registry for sdkInstallRootv2.0. In my registry that was pointed to a VS2005 directory which doesn't actually have a full SDK. I pointed it to the new SDK paths Microsoft is using, in my case C:\Program Files\Microsoft SDKs\Windows\v6.0A\ , and then my project worked (well at least it got further than it did :) )



I hope this saves somebody some time!

5 comments:

James Gregory said...

Much appreciated, this had me stumped!

Joseph said...

Very helpful.
One slight change I made was to just add an sdkInstallRootv3.5 and then updated the Nant.exe.config. I have risk averse when it comes to changing registry entries.

scott said...

Great idea Joseph! Much cleaner way to solve this.

Zachary Young said...

Thank you very much!

Jason said...

Thanks for this post. I ended up copying resgen.exe from \Microsoft\.NETFramework\sdkInstallRootv2.0\bin to C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin. I don't know if that's the best solution, but the nant build suceeded after doing so. Thanks again!