对于此特定项目,Visual Studio Code和OmniSharp有点问题。该项目包含多个组件,其中之一是C#.NET Core 3.1应用程序。每个不同的组件都位于存储库顶层的文件夹中:
myrepository/component1 # this is the C# project
myrepository/component2 # this is another component in a different technology
[...]
myrepository/foo # this contains some folders that are mounted in docker containers
问题是存储库中的“ foo”文件夹。在此文件夹中,有几个安装在Docker容器中的目录。有一个特定的文件夹会导致在其上设置怪异的权限,其结果是只能从根目录访问主机上的该文件夹。
现在的问题是,当OmniSharp无法访问文件夹时,它真的不喜欢它。如果仅在VSCode中打开“ component1”子文件夹,则OmniSharp可以正常工作。如果我在VSCode中打开整个存储库,OmniSharp将无法正常工作,并且无法获得任何可用的IntelliSense,自动完成功能或由其处理的任何其他功能。查看OmniSharp日志,我会看到以下错误消息:
[fail]: OmniSharp.WorkspaceInitializer
The project system 'OmniSharp.Script.ScriptProjectSystem' threw exception during initialization.
System.UnauthorizedaccessException: access to the path '/myrepository/foo/bar' is denied. ---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
据我所知,这是OmniSharp在这种情况下无法正常工作的原因。
我试图找到一种设置来限制OmniSharp只在“ component1”子文件夹中查看,但是我还找不到任何东西。如何更改我的VSCode和/或OmniSharp配置,以使OmniSharp仅在实际的C#文件夹上运行,而不会受到其外部内容的烦扰?