Showing posts with label visual studio. Show all posts
Showing posts with label visual studio. Show all posts

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, August 13, 2013

How to create your own ssl certificate

Developers have to use Digital Certificates very often. We can use self signed certificates to our development process rather than buying certificates from certificate authorities.

There are few simple steps to create our own certificates using visual studio.

Step 1

Open visual studio command prompt as administrator. You can get cmd as administrator by right click on short cut exists in visual studio tools and select run as administrator. (Not native windows command prompt)

Step 2:

Change the directory to where you want to create certificates. And type following command.



  • -sv yourprivatekeyfile.pvk is the name of the file containing the private key.
  • -n "cert name" is the name that will appear on the certificate (and in the certificate store).
  • yourcertfile.cer is the name of the certificate file.
  • -b mm/dd/yyyy is the date when the certificate becomes valid.
  • -e mm/dd/yyyy is the date when the certificate expires.
  • -r indicates that this will be a self-signed certificate.


Step 3:

Then you'll be prompted to enter the password for private key.


Step 4:

After you enter password you'll be prompted to enter password for sign certificate.


Step 5: 

This is the final step. Enter following command in cmd


Then it'll be prompted to enter private key password. Enter password and that's it.


  • -pvk yourprivatekeyfile.pvk is the private key file that you created
  • -spc yourcertfile.cer is the certificate file you created
  • -pfx yourpfxfile.pfx is the name of the .pfx file that will be created
You can see your certificates in hard disk