2
votes

When I compile my c# solution under VS2013 (Version 12.0.21005.1 REL) it cannot build part of projects with error message:

Error 32 The command "“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bin\NETFX 4.0 Tools\sgen.exe” /a:"Project.dll" /f /v" exited with code 3. Project

Post build event: “$(FrameworkSDKDir)\Bin\NETFX 4.0 Tools\sgen.exe” /a:"$(TargetPath)" /f /v

Indeed, folder "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bin\NETFX 4.0 Tools" doesn't exists: "\Bin" contains folder "NETFX 4.5.1 Tools" only.

Target framework of project: ".NET Framework 4".

2
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools registry keys, I think. Very unhealthy, sounds like you had a preview installed and not properly uninstalled.Hans Passant
it didn't solve my issue: Error 64 The command "“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\\Bin\NETFX 4.0 Tools\sgen.exe” /a:"project.dll" /f" exited with code 3. projectconstructor
You have the screwed-up machine, it thus makes sense for you to search the registry for "netfx 4.0 tools".Hans Passant
if removing/installing VS2013 will solve the issue?constructor

2 Answers

7
votes

solution (by Microsoft):

It is best practice to use the $(SDK40ToolsPath) property to get the .NET SDK binaries path rather than manually building the path with the $(FrameworkSDKDir) property. Using “$(SDK40ToolsPath)sgen.exe” should work in Visual Studio 2013 and earlier versions.

$(FrameworkSDKDir) value in VS macros (post build event) references invalid path

1
votes

I experienced this error today. The project I am working on is currently being maintained in VS2012. On my new install, I have VS2013 (installed first) and VS2012. I got this error building in VS2013.

The problem was the folder where sgen.exe was being run from doesn't exist on my machine. On my machine, I have $(FrameworkSDKDir)\Bin\NETFX 4.5.1 Tools\ but not $(FrameworkSDKDir)\Bin\NETFX 4.0 Tools\ folder.

To resolve the issue, I created a NETFX 4.0 Tools\ in the parent source control director and checked it in. This way, the reference is no longer dependant on each user's machine. My post build is now "$SolutionDir\..\..\NETFX 4.0 Tools\sgen.exe" /force "$(TargetPath)"