“GenerateBindingRedirects”任务意外失败。
System.IO.PathTooLongException: The specified path, file name, or both are too long.
The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.Xml.XmlWriterSettings.CreateWriter(String outputFileName)
at System.Xml.XmlWriter.Create(String outputFileName, XmlWriterSettings settings)
at System.Xml.Linq.XDocument.Save(String fileName, SaveOptions options)
at Microsoft.Build.Tasks.GenerateBindingRedirects.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() Incryptex.OMS.Workflow.MarketData.Service
最佳答案
最简单的解决方案是:
- 卸载出现问题的项目的
.csproj
文件。 在
.csproj
文件末尾添加这个<Target Name="WorkaroundAppConfigPathTooLong" BeforeTargets="GenerateBindingRedirects"> <PropertyGroup> <_GenerateBindingRedirectsIntermediateAppConfig>$(IntermediateOutputPath)$(TargetFileName).config</_GenerateBindingRedirectsIntermediateAppConfig> </PropertyGroup> </Target>
保存并重新加载项目。重建。
您基本上是在要求 Visual Studio 缩短导致问题的中间应用配置文件的路径长度。
关于c# - "GenerateBindingRedirects"任务意外失败。指定的路径、文件名或两者都太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36641775/