I have a .net 4.5 project with a lot of nuget packages and I upgraded it to 4.7.2. To resolve some specific update problems with packages(like requireReinstallation="true"
in packages.config
) I upgraded related packages. Now I have upgraded packages and some new packages like
`<package id="System.AppContext" version="4.1.0" targetFramework="net472" />`
........(some other)
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="net472" />
At this moment, I can build it, but when I try to do it with Generate serialization assembly
option I got an error in teamcity (and locally) like
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sgen.exe /assembly:C:\buildAgent\work\6b1c1da90609c252\Site\obj\TeamCity\Site.dll /proxytypes
/reference:C:\buildAgent\work\6b1c1da90609c252\packages\AjaxMin.4.48.4489.28432\lib\net20\AjaxMin.dll
[SGen] C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(3463, 5): warning MSB6002: The command-line for the "SGen" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "SGen" into multiple calls with fewer parameters per call.
[SGen] C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(3463, 5): error MSB6003: The specified task executable "sgen.exe" could not be run. The filename or extension is too long
Of course I can disable Generate serialization assembly
but I don't want.
I think the problem in too big amount of arguments in command line. After I upgraded the project the total amount of dependencies reached the limit.
How can I resolve this issue? breaking down the call to "SGen" into multiple calls with fewer parameters per call
(how?) or something else
When you build a C# project in Visual Studio and get the error Error MSB6003 The specified task executable "sgen.exe" could not be run. System.ComponentModel.Win32Exception (0x80004005): The filename or extension is too long you can fix it by going to the properties of the C# project, and on the Build tab set the Generate serialization assembly to off.
Apply this setting to both the Debug and Release configuration, otherwise it works locally (Debug), but fails on your build server (Release).
See XML Serializer Generator Tool (Sgen.exe) for more information on the tooling.