2

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".

constructor
  • 1,412
  • 1
  • 17
  • 34
  • 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 Dec 10 '13 at 15:04
  • 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. project – constructor Dec 10 '13 at 15:21
  • You have the screwed-up machine, it thus makes sense for **you** to search the registry for "netfx 4.0 tools". – Hans Passant Dec 10 '13 at 15:25
  • if removing/installing VS2013 will solve the issue? – constructor Dec 12 '13 at 14:03

2 Answers2

7

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

constructor
  • 1,412
  • 1
  • 17
  • 34
1

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)"

Hypnovirus
  • 1,555
  • 1
  • 10
  • 21
  • Ok, I understand the workaround. But I want to know if VS2013 has bug and, probably, Microsoft released or is going to release patch? – constructor Dec 12 '13 at 14:02
  • I am not sure this is a bug. The problem seems to be that our solutions are dependant on a specific folder name outside of the solution directory. Any dependency outside of source control is going to risk being at least somewhat brittle. The best change I could hope for from MS would be a checkbox on build properties for "After Build, Generate XML serialization assembly" – Hypnovirus Dec 12 '13 at 15:04
  • In case it matters in your research about the issue in VS2013, I experienced it in Premium v12.0.21005.1 REL – Hypnovirus Dec 12 '13 at 15:09