VS 2017 Error: The specified task executable "sgen.exe" could not be run. The filename or extension is too long.

OK, I admit this error tripped me off.

If it were a file I created, I would have simply moved things around to reduce the filename length. But the error was coming from Visual Studio, specifically, from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets.

And, sgen: what's that?

It turns out sgen is just an XML serializer generator - something I clearly don't use or need. The .targets file above contained a task referencing Sgen. So, what now: comment it out?

No!

There's an easier solution:

  1. In Solution Explorer, right-click on the project throwing the error; then click on Properties.
  2. In the window that opens, click on the Build tab by the left.
  3. Locate the Generate serialization assembly option.
  4. Set it to OFF or AUTO.

That's it.


Content originally appeared in my first blog on software

Did you find this useful? Did I miss anything? Please share your thoughts. I'll appreciate your feedback.

comments powered by Disqus