Thursday, December 31, 2020

Run Docker With Visual Studio in Corporate Machine with VPN or Firewall

I was trying to run some API using docker with visual studio docker tools. 

Idea behind that is I will able to attach docker process to visual studio and do some tweaks very easily using visual studio docker tools. (Haha I am lazy).

But unfortunately, my company laptop is heavily protected with no Administrator, a bunch of security tools, and a VPN also. 

Some errors I got with various tries.

Debugger path 'C:\User\...\vs2017u5' for DockerFile is invalid. 

One or more errors occurred.

Failed to launch debug adapter. Additional information may be avaliable in the output window.

Building the project is successful but errors out on launch.

The program '' has exited with code -1 (0xffffffff).

\vsdbg\vs2017u5' for Dockerfile.... Container.targets Dockerfile is invalid

In order to work this normally, there is a power shell script provided by Microsoft to download software, .NET Core Debugger from Microsoft, aka vsdbg.

https://aka.ms/getvsdbgsh

This will download a zip file and will be created in the below directory with debugger files. 

C:\Users\Chathuranga\vsdbg\vs2017u5.


With the firewall and VPN, my laptop couldn't be able to do this in a proper way. 


Time to read what is inside of getvsdbg.sh.


You will find a method like this download_and_extract()

This method constructs the download URL.


url="https://vsdebugger.azureedge.net/vsdbg-${target}/${vsdbgCompressedFile}"


Time to determine parameters.


Check this method in SH file, 


set_vsdbg_version

        latest)

            __VsDbgVersion=16.8.11013.1

            ;;

        vs2019)

            __VsDbgVersion=16.8.11013.1

            ;;

        vsfm-8)

            __VsDbgVersion=16.8.11013.1

            ;;

        vs2017u5)

            __VsDbgVersion=16.8.11013.1

            ;;

        vs2017u1)

            __VsDbgVersion="15.1.10630.1"


Decide what is the version you want from this. 


I selected 16.8.11013.1 because I have vs 2109 16.8.3


Next, decide which vsdbg configuration you want. 

ex: debian.8-x64, linux-musl-x64, linux-x64.


In this case, I selected linux-x64, the reason is I wanted to debug. 

If you just want to run then select linux-musl-x64, it is the runtime


The final URL will be like below

https://vsdebugger.azureedge.net/vsdbg-16-8-11013-1/vsdbg-linux-x64.zip


Download this and extract it to C:\Users\XXX\vsdbg\vs2017u5.

Create vsdbg folder if it does not exist. and keep in mind that do not extract to a subfolder.


Ok, that is it. Enjoy debugging.

Tuesday, December 8, 2020

How to build .NETCORE app using docker and get output

Below is the docker file that I am going to use for build. Then using below shell file, you can build and take out .dlls. how to run it $./dockerBuild.sh