Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "GenerateBindingRedirects" task failed unexpectedly. The specified path, file name, or both are too long

Tags:

c#

The "GenerateBindingRedirects" task failed unexpectedly.

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
like image 868
Satyam Gupta Avatar asked Apr 15 '16 08:04

Satyam Gupta


1 Answers

Easiest solution is to:

  1. Unload the .csproj file of the project that's giving you the issue.
  2. Add this at the end of the .csproj file

    <Target Name="WorkaroundAppConfigPathTooLong"
      BeforeTargets="GenerateBindingRedirects">
      <PropertyGroup>
        <_GenerateBindingRedirectsIntermediateAppConfig>$(IntermediateOutputPath)$(TargetFileName).config</_GenerateBindingRedirectsIntermediateAppConfig>
      </PropertyGroup>
    </Target>
    
  3. Save and reload the project. Rebuild.

You're basically asking Visual Studio to cut down the path length of the intermediate app config file that's giving you the issue.

like image 110
Prasanth Louis Avatar answered Nov 11 '22 13:11

Prasanth Louis