SGEN doesn't work after upgrading from VS2012 to VS2013

3.7k views Asked by At

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

There are 2 answers

0
constructor On BEST ANSWER

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

3
Hypnovirus On

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