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).
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
The structure after running the commands:
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! 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)
If you want to create an unit test, then ran the 3rd command. It will be added to the solution and chosen project.Commands:
cshelp console App MyConsoleApp
cshelp classlib MyClass MyConsoleApp
(update#1)
cshelp xunit MyConsoleApp.Tests MyconsoleApp
That's it!
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.
Any feedback is appreciated and if you make changes please share.