"sgen.exe" could not be run in VSBuild on Azure Pipelines

782 views Asked by At

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.

0

There are 0 answers