[英]The “GenerateBindingRedirects” task failed unexpectedly. The specified path, file name, or both are too long
The "GenerateBindingRedirects" task failed unexpectedly. “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
Easiest solution is to: 最简单的解决方案是:
.csproj
file of the project that's giving you the issue. 卸载提供问题的项目的.csproj
文件。 Add this at the end of the .csproj
file 在.csproj
文件的末尾添加它
<Target Name="WorkaroundAppConfigPathTooLong" BeforeTargets="GenerateBindingRedirects"> <PropertyGroup> <_GenerateBindingRedirectsIntermediateAppConfig>$(IntermediateOutputPath)$(TargetFileName).config</_GenerateBindingRedirectsIntermediateAppConfig> </PropertyGroup> </Target>
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. 您基本上要求Visual Studio减少中间应用程序配置文件的路径长度,这会给您带来问题。
This issue is related specifically to GenerateBindingRedirects, and is being tracked here: https://github.com/Microsoft/msbuild/issues/1786 此问题与GenerateBindingRedirects有关,现在正在跟踪: https : //github.com/Microsoft/msbuild/issues/1786
It looks like this exception can be triggered with project names even a third of MAX_PATH. 看起来这个异常可以用项目名称触发,甚至是MAX_PATH的三分之一。 I have a project with a 55-character name. 我有一个55个字符的项目。 According to the issue linked above, that project name is appended three times, and added to the full project location, to create the name of a config file. 根据上面链接的问题,该项目名称被附加三次,并添加到完整的项目位置,以创建配置文件的名称。
For me the solution was to make sure the path to my solution was less than about 70 characters. 对我来说,解决方案是确保我的解决方案的路径少于大约70个字符。
This issue happens when you have any folder path inside of you application which has more 259 characters. 当您的应用程序中有任何文件夹路径有259个字符时,会发生此问题。
I had this issue in my .Net Core 1.0 app . 我在.Net Core 1.0应用程序中遇到了这个问题。 Thing is, I started designing the UI using a lite server from NODEJS also with some other .JS library packs, this was only for quick launch and it wouldn't go to any other environment than my PC. 事实上 ,我开始使用来自NODEJS的lite服务器以及其他一些.JS库包来设计UI ,这只是为了快速启动而且不会发送到除我的PC之外的任何其他环境。 So, I was using NPM to install those libraries + the lite server components into my wwwroot . 所以,我正在使用NPM将这些库+ lite服务器组件安装到我的wwwroot中 。 When installing the packs through NPM, it created a folder named node_modules and a bunch of other sub-folders tree. 通过NPM安装包时,它创建了一个名为node_modules的文件夹和一堆其他子文件夹树。
Because of this bunch of large path folders, I was getting this error. 由于这一堆大型路径文件夹,我收到了这个错误。 The problem is not in your namespace fully qualified name, the problem is the folders your project has. 问题不在您的命名空间完全限定名称,问题是您的项目具有的文件夹。
I removed the node_module folder from my project and it compiled fine. 我从我的项目中删除了node_module文件夹,它编译得很好。 Another thing, when compiling through the console with dotnet build
, I wasn't getting any error, only when through IDE. 另一件事,当通过使用dotnet build
的控制台进行编译时,我没有得到任何错误,只有通过IDE。
I had some issues to remove node_module from my PC as windows was throwing the same exception, and actually this is a very known exception for windows users. 我有一些问题要从我的PC中删除node_module,因为Windows抛出相同的异常,实际上这是Windows用户的一个众所周知的例外。 I got this many times when doing other things with long folder paths. 在使用长文件夹路径执行其他操作时,我多次使用此功能。
Anyways, I tried del folder_path
command, Remove-Item folder_path
either of them didn't work, I founded out that NPM has a package named rimraf which does the job, also there is another tool named 7zip (I didn't test that) which supposed to do the same. 无论如何,我尝试了del folder_path
命令, Remove-Item folder_path
其中任何一个都不起作用,我发现NPM有一个名为rimraf的软件包可以完成这项工作,还有另一个名为7zip的工具(我没有测试过)应该做同样的事。
So, using NPM, run -> npm install -g rimraf
than rimraf folder_path
and happy days :) 所以,使用NPM,运行 - > npm install -g rimraf
比rimraf folder_path
和happy days :)
Hope it helps! 希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.