Introduction to Visual Studio
Visual Studio is already installed on the Windows 10 development machine,
but when it is reverted, all previously written code will be lost.
To solve this issue, we’ll create a Kali Samba share for our code
to save our code between system reverts.
To set up Samba on Kali, we’ll install it with apt,
make a backup of its configuration file, smb.conf,
and create a fresh configuration file.
We’ll create the new simple SMB configuration
containing the path to the directory we wish to share.
Next, we need to create a samba user that can access the share,
and then start the required services.
Finally, we’ll create the shared folder,
and open up the permissions for Visual Studio.
With everything set up, we’ll turn to our Windows 10 development machine.
First, we’ll open the new share in File Explorer.
When prompted, we’ll enter the username
and password of the newly created SMB user,
and select the option to store the credentials.
Now that our environment is set up, let’s create a new “Hello World” project.
We’ll launch Visual Studio from the taskbar,
and choose Create a new project from the splash screen.
Next, we’ll set the Language drop down menu to C#
and select Console App (.NET Framework).
After selecting the project type and clicking next,
we must set the Location of the project.
In our case, we’ll use the visualstudio folder on our network share.
For the remaining options, we’ll accept the default values and click Create.
It may take some time to create the project.
Once Visual Studio opens,
we’ll find that we’ve created both a solution and a project.
The solution is a parent unit that may contain multiple projects.
Let’s take a moment to examine the basic workspace configuration.
The first window to make note of is the Solution Explorer
on the far right side,
which can be thought of as the file and property explorer
for the solution’s contents.
Here we can see the source code file related to the current project,
which in our case is named
Program.cs.
On the left side of the workspace,
we can inspect the contents of the file selected in the Solution Explorer.
By default, this view will show the contents of Program.cs,
which contains the code for a typical C# console application.
Let’s highlight significant parts of the code.
The first five lines import the codebase from the .NET framework.
Next,
the Main method defines the entry point of our application
when it is compiled.
Let’s add a line of code inside the Main method
to create our simple application.
We will use the Console.WriteLine method to print some text to the console
when the application is executed.
With our code added, we can save the changes.
Next, we’ll modify the default solution settings before we compile our code.
We’ll switch from Debug to Release mode
to remove the debugging information that could
trigger some security scanning software.
We can now compile our application
by navigating to Build > Build Solution.
Whether the compilation succeeds or fails,
we can view the output in the Output window at the bottom of Visual Studio.
Fortunately, our code compiled without any issues.
The compilation output also tells us the path to the newly compiled executable.
We can now open a command prompt,
and enter this path to execute our new program.
After a few seconds, we are presented with “Hello World”.