10

Running the build locally is good, no problems whatsoever.. When I did run this on an Azure Pipeline it errors out.

The detailed error message is

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. [D:\a\1\s\eFetch.Web.Core\eFetch.Web.Core.csproj]

##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3645,5): Error MSB6003: The specified task executable "sgen.exe" could not be run. System.ComponentModel.Win32Exception (0x80004005): The filename or extension is too long

enter image description here

VSBuild on Azure Pipeline

- task: VSBuild@1
  inputs:
    solution: '$(agent.builddirectory)\s$(Project1-Folder)$(Project1-Name).csproj'
    msbuildArgs: '/p:OutputPath="$(build.binariesDirectory)$(Project1-Folder)\bin" /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /p:publishUrl="$(build.artifactStagingDirectory)$(Project1-Name)TempFolder"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

We did a bit of research. What usually comes up is setting GenerateSerializationAssemblies to Auto or Off. Our project was already on Auto so we set it to Off but the error persists.

Is there a way to bypass the long paths of some the dll references? Like the following

  • reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Xml.Linq.dll"
  • /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\Facades\System.Xml.ReaderWriter.dll"

Another scenario would be making multiple calls to sgen.exe however we're not sure how to do that since sgen.exe is being called inside VSBuild / msbuild.exe.

Ideally we would prefer not having to turn the GenerateXmlSerialization off and instead just get it working as it should.

Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
99823
  • 2,407
  • 7
  • 38
  • 60
  • Which build agent image are you using in Azure DevOps? Is this a Microsoft cloud-hosted build agent, or a self-hosted build agent? Which OS? – bryanbcook Dec 28 '21 at 22:01
  • We are using Microsoft-hosted agents, with windows-latest image which got Windows Server 2019 – 99823 Dec 29 '21 at 15:15
  • Try turning off the GenerateSerializationAssemblies and modifying the csproj file by adding the target ` ` – amit_g Dec 30 '21 at 05:52
  • hi @amit_g - we would prefer not to turn off the GenerateSerializationAssemblies as it could negatively impact our apps. – 99823 Dec 30 '21 at 20:48
  • The error is due to sgen using all assemblies in a single command line, so this suggestion is to do it one at a time. For that, we are turning off at the project level but adding the Exec to run it for binaries generated by the build. You will have to use the correct path (look it up in the logs) for the sgen.exe. – amit_g Dec 30 '21 at 23:28

0 Answers0