Daily commands for a .NET Software Engineer

As a Software Engineer commands in a terminal are part of your daily routine and even more when you're setting up CICD pipelines. These commands are very useful when you're running the tests, building your project, deploying (publishing) your web app or simply test your front end NodeJs packages. Unless you're a mouse manic, commands are definitely not part of your routine but still, sometimes you can't run away from them.

With this in mind, I've compiled a couple of useful commands for .NET Engineers that will help you for your daily work or just to take a peak or even set up your pipelines for project automation.


# find which branches contain a commit
git branch --contains <commit>

# revert last commit and keep modified files
git reset --soft HEAD^

# cherry-pick command will allows you to pick any commit from any branch and apply it to any other branch.
git cherry-pick <commit-hash>

.NET Core

# build a projcet with a specific version in release mode
dotnet build src\project\project.csproj -c Release /p:Version=0.0.1

# test a certain project in release mode
dotnet test src\project\project.csproj -c Release

# publish a project into a certain dist folder with certain version, in release mode
dotnet publish src\project -c Release -o ..\dist\ /p:Version=0.0.1

# publish an exe with a single file
dotnet publish src\project -c Release -o ..\dist\ /p:Version=0.0.1 /p:PublishSingleFile=true /p:PublishTrimmed=true /p:PublishReadyToRun=true

# publish a nuget package using dotnet nuget
dotnet nuget push -s http://your.nuget.com/v3/index.json package.version.nupkg -k key

# build a project assembly into a specific folder with a certain version
# useful if you set the project properties to generate a nuget package
dotnet build .\src\Company.Product.Project\ -c Release -o ..\..\dist\ /p:Version=$version


# packs a nuget from a nuspec with a certain version in release mode
nuget pack dist\project.nuspec -Version 0.0.1-alpha-SHA1 -Properties Configuration=Release -OutputDirectory .\dist\

# publish a nuget package using nuget
nuget push package.nupkg -Source http://nuget.rezult.io/v3/index.json

# delete a specific NuGet package version from a source
nuget delete Package.Name 1.2.3 -ApiKey ApiKeyGoesHere -Source http://nuget.rezult.io