【问题标题】:Visual studio doesn't let compile "Sgen could not be run"Visual Studio 不允许编译“Sgen 无法运行”
【发布时间】:2018-04-13 01:43:50
【问题描述】:

得到错误:

"The specified task executable "sgen.exe" could not be run. The filename or extension is too long F:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets   3408"

和警告:

"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.   DAYAnalytics    F:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 3408"

在 Microsoft.Common.CurrentVersion.targets 的这一部分:

<SGen
    BuildAssemblyName="$(TargetFileName)"
    BuildAssemblyPath="$(IntermediateOutputPath)"
    References="@(ReferencePath)"
    ShouldGenerateSerializer="$(SGenShouldGenerateSerializer)"
    UseProxyTypes="$(SGenUseProxyTypes)"
    UseKeep="$(SGenUseKeep)"
    KeyContainer="$(KeyContainerName)"
    KeyFile="$(KeyOriginatorFile)"
    DelaySign="$(DelaySign)"
    ToolPath="$(SGenToolPath)"
    SdkToolsPath="$(TargetFrameworkSDKToolsDirectory)"
    EnvironmentVariables="$(SGenEnvironment)"
    MSBuildArchitecture="$(SGenMSBuildArchitecture)"
    SerializationAssembly="$(IntermediateOutputPath)$(_SGenDllName)"
    Platform="$(SGenPlatformTarget)"
    Types="$(SGenSerializationTypes)">

解释很简单,但我不明白如何解决它。 如何减少命令行长度?

【问题讨论】:

    标签: visual-studio visual-studio-2017 sgen


    【解决方案1】:

    将构建选项中的“生成序列化程序集”选项设置为“自动”或“关闭”,除非您需要它们(即您大量使用 XmlSerializer),在这种情况下您会找到更多信息这里:Generating an Xml Serialization assembly as part of my build

    【讨论】:

      猜你喜欢
      • 2012-01-03
      • 1970-01-01
      • 2017-10-01
      • 2021-03-28
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      • 2021-05-26
      • 1970-01-01
      相关资源
      最近更新 更多