Visual Studio Code configuration question

Hi

I’m using the guide “.NET Core Development and Debugging on Torizon Using Visual Studio Code” on the Toradex website. I do have some questions:

1: "Copy content of the template folder in this repository to the .vscode subfolder of your project,…"

Can’t compute. I have no idea which template folder and where it is?
The created project has none of the above folders. The VS Code did install of the “C# support for Visual Studio Code” by itself and is shown as installed extensions.

2: Get the IP of the target device

My device is connected to the company network. I have no idea of the assigned IP for my device.
So it may be nice to show the IP somewere on the login screen?

Thomas

Greetings @TJO,

  1. The repository being referenced is the Github repository that was mentioned at the start of the article here: https://github.com/toradex/dot-net-core . This repository contains the template folder that is being mentioned in this step.
  2. You can obtain the IP address from your Torizon device by running the following command on the device’s command line: hostname -i.

I hope this helps clear things up.

Best Regards,
Jeremias

Hi

Yes, this did help clearify it. But where must the dot-net-core repositoty be copied to? I guess the stuff inside the ‘containers’ must be needed when building the containers?

task builddebugcontainer:

Executing task: pushd . && cd %templatepath%\dotnetcoredbg && docker build -t dotnetcoredbg:latest . && popd <

 Executing task: pushd . && cd %templatepath%\dotnetcoredbg && docker build  -t dotnetcoredbg:latest . && popd <

At line:1 char:9
+ pushd . && cd %templatepath%\dotnetcoredbg && docker build -t dotnetc ...
+         ~~
The token '&&' is not a valid statement separator in this version.
At line:1 char:44
+ pushd . && cd %templatepath%\dotnetcoredbg && docker build -t dotnetc ...

Hi

Yes repository should be cloned in your Visual Studio Code project folder such that the file paths in /template work. You could also modify the default file paths in /template if you so wish.

As for the error, I believe this is an issue with your default shell. The && syntax seems to be valid in command prompt but not powershell. The following article describes how to change what shell these commands get run in: https://code.visualstudio.com/docs/editor/integrated-terminal

Best Regards,
Jeremias

Hi,

Now I get his error:
“Get https://mcr.microsoft.com/v2/: dial tcp 52.236.186.73:443: connect: connection refused”

I have followed this guide multiple times:
https://developer.toradex.com/knowledge-base/net-core-development-and-debugging-on-torizon-using-visual-studio-code

Maybe something is missing in this guide? Or it assume the reader not to be a noob?
It may be easiere using Linux, but that is not an option I have.

I’m on the brink to give up…

I may add I use version 1.41.1 (user setup) of Visual Studio Code on Windows 10

File and folder structure I use:

  • WorkingRoot
  • dotnetcoreapp
  • containers
  • template
    
  • aspdotnetcoreapp
    
  • MyProject
    
  •       .vscode
    
  •              *.json
    
  •        *.cs
    
  •        MyProject.csproj

Now the issue seems to be your development PC can’t pull the container image from Microsoft’s container registry.

For reference the first line of this file: https://github.com/toradex/dot-net-core/blob/master/containers/dotnetcoredbg/Dockerfile

Is where the container image for the build is fetched from.

Do you have an unusual/restrictive network setup on your development PC/office?

A possible workaround would be to add a proxy for Docker and try the connection again. Though I am unsure on how to do this in a Windows environment.

Hi

I dont know if we have an unusal restrictive network setup. I guess it is not different than other big companies. But it is not something I can change.

Adding a proxy may work. I dont know how it is done and I guess if I ask IT they say it is not allowed. I probally dont have the priviliges to do so anyway.

So i guess Im stuck and the Torizon/.NET Core seems to be a dead end.

Thomas

Have you gone through the getting started guide for Torizon? Just curious as there are steps there that have you setup Docker on your PC and pull some basic containers.

It’d be valuable to know if your environment can pull from the Docker Hub registry but not from Microsoft’s registry.

Hi,

I just tried the get starting guide.
I tried on my PC and on the Torizon. It seems I’m not allowed to get the containers from docker…

On PC:
T:>docker pull hello-world
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp 34.197.189.129:443: connect: connection refused

On Torizon SSH
Last login: Thu Jan 1 00:00:33 1970
colibri-imx6-05175073:~$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp 52.201.142.14:443: connect: connection refused.
See ‘docker run --help’.
colibri-imx6-05175073:~$ ^C
colibri-imx6-05175073:~$

I don’t see an easy way around this if your network doesn’t have access to standard Docker registries. As TorizonCore by design is centered around the usage of containers.

In the future you could set up a local Docker Registry on your PC as described here: https://docs.docker.com/registry/deploying/

However this would still require you to have access to Docker Hub to be able to get the container images as a starting point to begin with.

As I said earlier you may also need to adjust proxy settings if you are behind one in a corporate environment as shown here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon

Hi,

I manage to get a direct line to the ouside world (After arm wrestling with IT) . And manage to get the files for docker.
I got the builddebugcontainer and deploydebugcontainer to run… :slight_smile:

Final part is to debug it.
I need some package to do this ( Like “Microsoft.NETCore.App.Runtime.linux-arm”). But where to install the .NET Core files? In the WSL?

Thomas

I’m glad you were able to progress. Though I apologize I’m not quite sure I understand what you mean here.

Is the system asking for this package when you try to debug your application from Visual Studio Code?

Hi

It happen when I would like to debug it (Hittig F5)

Executing task: C:\Program Files\dotnet\dotnet.exe build C:\work\NETCore\mytestapp/mytestapp.csproj <

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 124,46 ms for C:\work\NETCore\mytestapp\mytestapp.csproj.
mytestapp → C:\work\NETCore\mytestapp\bin\Debug\netcoreapp3.1\mytestapp.dll

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.21

Terminal will be reused by tasks, press any key to close it.

Executing task: C:\Program Files\dotnet\dotnet.exe publish -r linux-arm -o C:\work\NETCore\mytestapp/bin/app C:\work\NETCore\mytestapp/mytestapp.csproj <

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\work\NETCore\mytestapp\mytestapp.csproj : error NU1101: Unable to find package Microsoft.NETCore.App.Runtime.linux-arm. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
C:\work\NETCore\mytestapp\mytestapp.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-arm. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
C:\work\NETCore\mytestapp\mytestapp.csproj : error NU1101: Unable to find package Microsoft.NETCore.App.Host.linux-arm. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
Restore failed in 186,41 ms for C:\work\NETCore\mytestapp\mytestapp.csproj.
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

I see, based on the error message it would seem like you would need to add this package to your .NET project itself as that is where the debug process is looking.

This document shows how to install the latest version of this package: https://www.nuget.org/packages/runtime.linux-arm.Microsoft.NETCore.App

Hi,

I cant install it.

Install-Package : No match was found for the specified search criteria and package name ‘runtime.linux-arm.Microsoft.NETCore.App’. Try Get-PackageSource to see all available registered package sources

I have now used weeks and still not been able to run a “Hallo World” on the Torizon device.!!

I have followed the on-line guides and done stuff not in the guides. Maybe the guides are imcomplete? Maybe it works great on other machine? Maybe it works like a charme when using Linux, but I dont?
Maybe It is because I dont know how Visual Studio Code and WLS works in detail?

I have done .NET and C# development for many years from Visual Studio 2003 to 2017. From .NET 2.0 to 4.7. So I know Visual Studio and .NET.
If I connect a Windows IoT Core device to my PC, I create a project in Visual Studio, build and run it on the device. No command line, no fiddling around with coping files, no installation of different packages, That is ease of use.

Maybe I just wait for the Visual Studio Integration is finished with .NET support to try it out. Any idea when that is scheduled?

Thomas

Apologies for the issues, this case has been elevated to our development team who are working on sorting the issues out with the IDE intergration. Thank you for reporting these issues however as your feedback is important.

In truth the windows integration stuff hasn’t been iterated/tested upon as much as it should have.

At the moment I can not give a definite timeline on when the extension will be fixed. But I will update this thread when I get any more information

Best Regards,
Jeremias

Did you install the .NET SDK on your machine? The files require on the client are already in the container, including the debugger.
You should also build your app without boundling the runtime. The runtime is part of the container and leaving it out of the application will allow the system to load the runtime libs only once if you run multiple applications.
Boundling the runtime is useful if you need to ship your application to run on different environments, but with containers you have full control of the environment, so this is not giving a real advantage.
We are working on a better integration, made with an extension and not just scripts. This will be an official release, we don’t have an exact date yet, but development is almost complete.

Hi,

I looking forward when it is ready,
We are looking into a new hardware platform in the future. And the demads internal are C# and Visual Studio.

Thomas

Yes, The SDK is installed.

I have no idea how and what bounding is. I just followed this guide

https://developer.toradex.com/knowledge-base/net-core-development-and-debugging-on-torizon-using-visual-studio-code

and this guide

https://developer.toradex.com/getting-started

Nothing in there about bounding.

I just wait for new release.

Thomas