-
Notifications
You must be signed in to change notification settings - Fork 7
opustecnica edited this page Oct 31, 2021
·
6 revisions
This tool can run C#
code in the terminal, and is useful for experimenting with C#
syntax and libraries.
dotnet tool install -g dotnet-script
Once installation is complete, we can run it by executing the dotnet-script command
.
We can then type C#
code and see the result in the terminal:
Use Ctrl+C
to exit.
{
"guid": "{eae0e5d6-8091-4a5e-af17-12b57cff0337}",
"name": "C#",
"commandline": "dotnet-script",
"closeOnExit": "always"
}
New-Item -Name "VSCodeIntroSolution" -Path "C:\Temp" -ItemType Directory
Set-Location "C:\Temp\VSCodeIntroSolution"
dotnet new sln -n "VSCodeIntroSolution"
dotnet new console -n "IntroUI"
dotnet new classlib -n "IntroLibrary"
dotnet sln VSCodeIntroSolution.sln add (Get-ChildItem */*.csproj).FullName
dotnet add "C:\Temp\VSCodeIntroSolution\IntroUI\IntroUI.csproj" reference "C:\Temp\VSCodeIntroSolution\IntroLibrary\IntroLibrary.csproj"
Set-Location "C:\Temp\VSCodeIntro\IntroUI\"
code -r .
Set-Location "C:\Temp\VSCodeIntro\"
code -r .
Set-Location "C:\Temp\VSCodeIntro\IntroUI\"
dotnet run
C:\Temp\VSCodeIntro\IntroUI\bin\Debug\netcoreapp3.1\IntroUI.exe
Add-Type -Path C:\Temp\VSCodeIntro\IntroUI\bin\Debug\netcoreapp3.1\IntroLibrary.dll
- To add NUGet package cd into the Library folder and:
dotnet add package xyz
- Check if dotnet psmodule is already installed
dotnet new --list | Select-String psmodule
Install the psmodule template dotnet new -i Microsoft.Powershell.Standard.module.Template
New-Item -Name "PwshModule" -Path "C:\Temp" -ItemType Directory
Set-Location "C:\Temp\PwshModule"
dotnet new psmodule
code -r .
dotnet build
Import-Module "C:\Temp\PwshModule\bin\Debug\netstandard2.0\PwshModule.dll"
Get-Command -Module PwshModule
Test-SampleCmdlet -?
Test-SampleCmdlet -FavoriteNumber 7 -FavoritePet Cat