Search code examples
c#visual-studio-2013sgen

SGEN doesn't work after upgrading from VS2012 to VS2013


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


Solution

  • 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