Craftsman at work

I'm Artur Karbone, coding software architect and independent IT consultant and this is my blog about craftsmanship, architecture, distributive systems, management and much more.

.NET Core : Solution's CLI Commands

Recently I had to grok a concept in C# for a line of business application. Only Mac with VS Code was at my disposal.

Usually, a typical LOB application consists out of many projects in a solution, like domain, implementation, content delivery, etc. However, it turned out that at the moment of writing VS Code didn't have either a built-in support or a plugin to create a .NET Core solution and attach some projects to it.

Using .NET Core CLI is a pretty standard case for me, but again I haven't seen a feature, to manage sln files via CLI.

I googled and found this interesting proposal to support tooling described above at GitHub. Turned out that it has been even implemented and available in the recent SDK.

So here is a practical case: Imagine a typical solution layout where sln file is located in some root folder and projects are located under src and test folders. Then from the root folder run something like this:

dotnet new sln  
dotnet sln add ./src/Insurance.Domain/Insurance.Domain.csproj  
dotnet sln add ./test/Insurance.Domain.Tests/Insurance.Domain.Tests.csproj

You can list available projects in the solution by running

dotnet sln list  

It's really good that solution management is implemented at SDK level. The fact that you can build multiple projects from CLI with just a single command is pretty convenient as well (previously you hand to navigate through all the projects and build them separately).

dotnet restore InsuranceCompany.sln  
dotnet build InsuranceCompany.sln  

This feature will definitely simplify my existing CI/CD pipelines. Going to refactor them and leverage these latest SDK features.

comments powered by Disqus