11

在本地运行构建很好,没有任何问题。当我在 Azure Pipeline 上运行它时,它会出错。

详细的错误信息是

“SGen”任务的命令行太长。超过 32000 个字符的命令行可能会失败。尝试通过将对“SGen”的调用分解为多个调用来减少命令行的长度,每次调用的参数更少。[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):错误MSB6003:指定的任务可执行文件“sgen .exe”无法运行。System.ComponentModel.Win32Exception (0x80004005):文件名或扩展名太长

在此处输入图像描述

VSBuild 在 Azure 管道上

- 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)'

我们做了一些研究。通常出现的是将GenerateSerializationAssemblies设置为AutoOff。我们的项目已经处于Auto状态,因此我们将其设置为Off,但错误仍然存​​在。

有没有办法绕过一些 dll 引用的长路径?像下面这样

  • 参考:“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"

另一种情况是多次调用 sgen.exe,但我们不确定如何执行此操作,因为 sgen.exe 在 VSBuild / msbuild.exe 中被调用。

理想情况下,我们宁愿不必关闭 GenerateXmlSerialization,而是让它正常工作。

4

0 回答 0