WSL: [WSL 2] The hostname could not be parsed. (Unable to load .csproj from inside WSL)
Build number: Microsoft Windows [Version 10.0.18932.1000]
- What you’re doing and what’s happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screen shots if that helps demonstrate the problem.)
Added .NET Framework projects inside the WSL file system per the recommendation for increased speed. Opened the solutions in Visual Studio 2019. Projects does not load. I have mapped my Ubuntu.18.04 to a network drive.
- What’s wrong / what should be happening instead:
The projects in the solution does not load. They should load.
- Strace of the failing command, if applicable: (If
some_commandis failing, then runstrace -o some_command.strace -f some_command some_args, and link the contents ofsome_command.stracein a gist here).
Error message: error : The project file could not be loaded. Invalid URI: The hostname could not be parsed. \wsl$\Ubuntu-18.04\home\rasolo\dev{project}/.csproj.
Someone else opened an identical issue in the VSCode repo here but for .NET Core: https://github.com/OmniSharp/omnisharp-vscode/issues/3099
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 29 (5 by maintainers)
I found a nice workaround:
Create a soft symlink to the target directory e.g.: mklink /D D:\shareLink \wsl$\etc
Then create a symlink junction to the soft symlink: mklink /J D:\junctionLink D:\shareLink
You can now open D:\junctionLink\etc in VS and it should load everything as usual. Speed should be fine aswell. @rasolo @TheLordDrake @summatix Let me know if it works for you.
Are you able to use Visual Studio when opening your project from
\\wsl.localhost\instead of\\wsl$\? It seems that\\wsl.localhost\is available in Windows 11 with wsl2.The issues that you are running into might be related to the fact that
\\wsl$\is not a valid URI due to the dollar sign, and a bunch of VS features internally uses URIs to identify files.I was able to reproduce this issue, we’re tracking it! Thanks for filing.
I too am having this issue. The article describes how to debug code running in WSL. What I am looking to do (not sure if pha377 is doing the same thing) is to run the IDE in windows, debug the code running in windows, but just use the files in WSL file system. So my project files and source are all in WSL 2.
Please check the instructions at this docs page to see how to debug .NET apps with Visual Studio and WSL: https://docs.microsoft.com/en-us/visualstudio/debugger/debug-dotnet-core-in-wsl-2?view=vs-2022
And here’s also the guide for C++.
Does using this guide help unblock you??
would this official extension work ? https://marketplace.visualstudio.com/items?itemName=ms-azuretools.Dot-Net-Core-Debugging-With-Wsl2
It’s a preview one, but I suppose that will somehow be the target
Currently the Visual Studio team is investigating how they can enable Visual Studio to open project files inside of the Linux root file system in WSL, I’m not aware of an ETA yet.
In the meantime, using VSCode with the Remote Extension may go a long way to resolving this problem for you.
@rasolo wow thx a lot i feel dumb now i though it was on the linux side 😉
i ended up doing the other way around i forgot i could just use the tar package , following zip install for linux
then update my
.zshrcwith“Workaround”: Map WSL to Network drive and then open the solution file with JetBrains Rider. BUT it is excruciatingly slow to restore nuget packages and compile so it is not really worth it.