WSL icon indicating copy to clipboard operation
WSL copied to clipboard

[WSL 2] The hostname could not be parsed. (Unable to load .csproj from inside WSL)

Open rasolo opened this issue 7 years ago • 29 comments

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_command is failing, then run strace -o some_command.strace -f some_command some_args, and link the contents of some_command.strace in 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

rasolo avatar Jul 16 '19 16:07 rasolo

~~This problem is solved in build version: Microsoft Windows [Version 10.0.18936.1000]~~

rasolo avatar Jul 18 '19 08:07 rasolo

~~It works for a Web forms project but not for ASP.NET web project.~~

rasolo avatar Jul 21 '19 14:07 rasolo

If I open the .sln without mapped network drive, I will receive the "The hostname could not be parsed." error. If I map the network drive, Visual Studio can not find WSL

rasolo avatar Jul 21 '19 15:07 rasolo

"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.

rasolo avatar Jul 21 '19 17:07 rasolo

I was able to reproduce this issue, we're tracking it! Thanks for filing.

craigloewen-msft avatar Jul 22 '19 17:07 craigloewen-msft

Not sure i'm competent enought here, the workaround is to map the drive from wsl to windows ? or the other way ?

I would very much love to know if/how i can do that so i would be able to add it to the ~/.zshrc (if it's on wsl side)

tebeco avatar Aug 07 '19 15:08 tebeco

Not sure i'm competent enought here, the workaround is to map the drive from wsl to windows ? or the other way ?

I would very much love to know if/how i can do that so i would be able to add it to the ~/.zshrc (if it's on wsl side)

What I did was this: Open WSL interface. Write cd and enter (to go to root) Explorer.exe to open folder in file explorer. Click on Wsl in file explorer Right click the Ubuntu folder and click "Map to network drive".

This made it possible to open the project in Jetbrains Rider IDE but it took like 20 minutes for Rider to compile so it doesn't really work to use it like that, hence "workaround"

rasolo avatar Aug 09 '19 17:08 rasolo

@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

mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-2.2.401-linux-x64.tar.gz -C $HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

then update my .zshrc with

export PATH=$PATH:$HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet

tebeco avatar Aug 09 '19 21:08 tebeco

I was able to reproduce this issue, we're tracking it! Thanks for filing.

Hi Craig, @craigloewen-msft Do you know the progress of this? Do you know an ETA for when this will work?

Thanks

rasolo avatar Sep 15 '19 13:09 rasolo

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.

craigloewen-msft avatar Sep 17 '19 00:09 craigloewen-msft

By mapping the network drive I am able to open the project inside Visual Studio. Building is slow, as expected, but otherwise everything else seems functional.

summatix avatar May 05 '20 18:05 summatix

Is there any new information on this issue? Or a link to a public issue for the Visual Studio team?

TheLordDrake avatar Aug 04 '20 02:08 TheLordDrake

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.

drwatson85 avatar Aug 31 '20 11:08 drwatson85

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

tebeco avatar Aug 31 '20 11:08 tebeco

October 2020, I still unable to load projects from WSl2, with the latest VS version and the .NET Core Debugging with WSL 2 extension installed too, any hint or help would be appreciated. image

josemojena avatar Oct 14 '20 15:10 josemojena

@tebeco's workaround works as a temporary solution for me

rawrspace avatar Feb 19 '21 13:02 rawrspace

which msg are you referring to as a workaround ?

the remote dev pack is the official set of extensions for docker / ssh / wsl etc... it's not supposed to be a workaround ^^

tebeco avatar Feb 19 '21 13:02 tebeco

My mistake I tagged the wrong user, I meant to reference @drwatson85's symlink solution.

I wanted my repos to be located on the linux filesystem but still be able to open them in visual studio. That solution worked for me for now.

I am still having issues running Azure Functions this way but at least I can have all my source code in one places and still use Visual Studio when VS Code is not enough.

rawrspace avatar Feb 19 '21 14:02 rawrspace

@rawrspace @josemojena @drwatson85 @summatix

image

Vs 2019 16.9 Preview 5 ==> .Net Core Debugging in WSL 2

(thx @andreandersen / @jcotton42 for pointing that up)

tebeco avatar Feb 24 '21 20:02 tebeco

I installed vs 2019 16.9 preview 5 but when opening a project that is on the linux filesystem I still receive an error when opening a database .sqlproj file:

image

It looks like opening a normal console .csproj worked though but when trying to run it I got: image

Are you not seeing these issues?

rawrspace avatar Feb 24 '21 20:02 rawrspace