Skip to content

Script to help C# (dotnet) development on Linux environment and vscode

License

Notifications You must be signed in to change notification settings

Markojudas/cshelp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

.NET Framework Helper for vscode in a Linux Environment

I have been using a Linode Virtual Machine (Debian 10) for remote work with a ssh connection on vscode. Development for most languages is quite easy and convinient except for C# (.Net Framework). I found myself having to run several commands just to set the environment to start coding. That's the birth of this script.

This script simply makes the creation of a console app and a classlib easier so you can start coding faster. The script assumes the dotnet binary is located "/usr/bin/dotnet". It will then check all the different versions you have and let your choice which one to use.

(update#1) The script now also handles the creation of Unit Tests (using xUnit).

Installation

git clone https://github.com/Markojudas/cshelp.git
cd cshelp/
source csharp.sh

If you wish you could set your ~/.bashrc to source the script at boot.

echo "if [ -f <full_path_to_script>/csharp.sh ]; then 
	. <full_path_to_script>/csharp.sh
fi" >> ~/.bashrc

Usage

The structure after running the commands:

App Structure

Start by creating a Console App
The first command to use (ran in your project folder) will create a new directory (named after the solution) and go into this directory. It will then create the solution and a new console app. It will then build the console app and add it to the solution. At this point you can already begin coding! Open the newly created directory (with the solution name) on vscode and start coding!
Create A Class library
If you need to create a class library, then run the second command (must be ran while in the same directory as the solution file). A classlib will be created (with a stock file called Class1.cs) and it will be added to the solution and project (console app).
I have named the solution App. A directory named App (same as the solution) was created. Inside the directory the console app was created named MyConsoleApp. I have also named the Class Library MyClass inside the App directory.

(update#1)

Create a Unit Test
If you want to create an unit test, then ran the 3rd command. It will be added to the solution and chosen project.

Commands:

First Command

cshelp console App MyConsoleApp

Second Command

cshelp classlib MyClass MyConsoleApp

(update#1)

Third Command

cshelp xunit MyConsoleApp.Tests MyconsoleApp
Keep in mind that each command will search and ask you which .NET version you wish to use

That's it!

Top-Level Statements (update)

If you choose a .NET Framework .NET6 and you have the build 6.0.300 or greater, you'll be able to choose whether or not you want to use Top-Level Statements when creating a new console app.

Collab

Any feedback is appreciated and if you make changes please share.