Unable to debug WSL2 with VS 2022 - invalid 'cwd' value - .net-core

I am trying to debug from WSL2 using my VS 2022 IDE in Windows, but I get the following error:
The cwd value does indeed look wrong, but how do I fix it?
I am using .netcore 6.0.101, Ubuntu 20.04.3 and Windows 11.
launchSettings.json:
{
"profiles": {
"WSL": {
"commandName": "WSL2",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "local"
},
"applicationUrl": "https://localhost:56962;http://localhost:56963",
"distributionName": "Ubuntu"
}
}
}
PS C:\Users\me> wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
docker-desktop-data Running 2

This has been fixed in 17.4 Preview 5.
The latest Preview releases are available for download here.

I tried to search some useful information for you, somebody said this is permisson issue. But I this below description is correct.
Currently the extension only support opening projects that are stored in the windows disks (it leverages WSLs automount feature).
Related Post:
Debug Your .NET Core Apps in WSL 2 with Visual Studio

In Visual Studio 2022:
Go to the project properties (right click on the project name in the Solution Explorer, then Properties on the pop up menu).
Then, write in the search bar "working directory" and click on "Open debug launch profiles UI" here you'll find the "Working Directory" setting where you should set the wsl2 path you need.

You have this error because Windows doesn't know about linux path used on WSL.
But you can access your WSL2 directories on Windows using \\wsl$ path.
If your WSL2 machine name is Ubuntu, you need to define cwd value with following path:
\\wsl$\Ubuntu\home\<the_rest_of_the_path_you_need>

Related

Jetbains Rider remote debugging ASP.NET Core 6.0 apps through SSH kept failing

I am trying to remote debug via ssh on an ubuntu host at Ali with no success. I'm using the the latest Rider, 2022.1 EAP 10.
The error is:
Debugger worker was not initialized within 100,000 ms
I’m running Ubuntu 20.04 64bit on Ali Cloud. And one side note: for the following steps from Jetbrains documents, I wasn’t able to succeed:
cd /[application path]/WebApplication to go to the application root folder.
chmod +x ./WebApplication to add the executable bit if needed.
ASPNETCORE_URLS=http://0.0.0.0:5000 ./WebApplication to run the application
WebApplication is a directory, the OS kept complaining it's a directory even after chmod+x. I managed to run the self-contained executable.
It is always better to ask such questions in JetBrains public issue tracker.
This problem should already be fixed in the next Rider versions:
https://youtrack.jetbrains.com/issue/RIDER-76083

Invalid runtimeconfig.json error when trying to run netcore app on linux

I have developed .net core console application. It connects with Azure table storage and downloads from azure to a local database. Application is working w/o any issues on a Windows 10 PC. However when I publish it to a PC running Lubuntu and try to run I receive "Invalid runtimeconfig.json error".
Content of runtimeconfig.json is:
{
"runtimeOptions": {
"framework": {
"name": "Microsoft.NETCore.App",
"version": "1.1.2"
}
}
}
and output of dotnet --info is:
NET Command Line Tools (1.0.4)
Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd
Runtime Environment:
OS Name: ubuntu
OS Version: 17.04
OS Platform: Linux
RID: ubuntu.16.10-x64
Base Path: /usr/share/dotnet/sdk/1.0.4
SDK for Linux is the latest version. Anybody have any ideas what might be wrong and how to fix it?
After some trial and error I have resolved the issue. Problem is not really a invalid configuration file. When dotnet runs the dll file it creates a xxxx.runtimeconfig.dev.json, xxxx being the name of dll. However in my case due to missing folder and file access rights in Lubuntu, dotnet was not able to create the runtimeconfig.dev.json file.
I have modified access rights to folder holding my application by executing following terminal command (run this from parent directory of folderholdingmyapp)
chmod -R 1744 folderholdingmyapp

Run .NET Core App via Console in VS2015

In Visual Studio 2015 Community Edition, I run my .NET Core Web API application via console by choosing [AppName] from running profile options on toolbar (Near Little green triangle, dropdown menu) in my previous project. The default options were IIS Express and [AppName], which runs dotnet restore and dotnet run from command prompt.
After I reinstall Windows 10 and therefore VS2015, When I create a new project, I can no longer see default [AppName] option in the dropdown. It has just one option, which is IISExpress.
How can I enable it again? I've also installed dot net core tools for VS2015.
Thanks.
I have found the solution.
In Solution Explorer > YourProject > Properties > launchSettings.json,
You should add this to the in profiles:
"YourProjectName": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
And then you can change starting option:

Trying to set environment in VSCode launch.json on OS X

I'm building an ASP.Net Core RC2 MVC Application on OS X
I don't seem to be able to set my environment for development
I think I should be able to add within my launch.json file:
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
I've tried adding it within the "name": ".NET Core Launch (web)" section. But "env" is not recognised. The version of the launch.json file is set as "version": "0.2.0", The error i get shown in the editor is Property env is not allowed
Has anyone got this working on OS X?
Thanks.
The issue is with OmniSharp for VS Code, as found at Issue #172 on their repo.
If you install their most recent preview release, the environment variable will work as intended. Download the VSIX file, and open it using the Open File dialog in VS Code. When the official release comes out, it will still suggest extension updates as per normal.

How to deploy asp.net application to docker container on Linux server?

I have installed docker engine on a Linux server. On my desktop's Visual Studio 2015, I created an asp.net application. Now I want to publish it to the Linux server and create a docker image.
I followed this step.
I don't have an azure account and I want to use my own Linux server. So next, I clicked the Docker Containers. The interface became:
Then I clicked Custom Docker Host and pressed OK button.
The interface was
Now I input the image name as DockerDemo. Also I type the server url something like tcp://12.16.45.56:8080. Validate connection is okay then go to the next step.
Finally I get this:
However I get an error during publish.
Severity Code Description Project File Line Suppression State
Error An error occured during publish.
The command [docker -H tcp://12.16.45.56:8080 build -t DockerDemo -f "C:\Users\me\AppData\Local\Temp\PublishTemp\DockerDemo63\approot\src\DockerDemo\Dockerfile" "C:\Users\me\AppData\Local\Temp\PublishTemp\DockerDemo63"] exited with code 1: 'docker' is not recognized as an internal or external command,
operable program or batch file.
Please visit http://go.microsoft.com/fwlink/?LinkID=529706 for troubleshooting guide. DockerDemo 0
By the way, the framework I am using is:
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
Thanks for help!
Visual Studio can't find the docker command on your local computer. It needs this as a client to connect to the docker daemon on your Linux server. The easiest way to do this is to install Docker Toolbox from here:
https://www.docker.com/products/docker-toolbox
You may have to uninstall and re-install "Visual Studio 2015 Tools for Docker" or manually add to Powershell's $env:Path if the docker command still can't be found.
Also, your Image Name must not contain uppercase characters. Use dockerdemo rather than DockerDemo.

Resources