Friday, May 22, 2020

.NET Core–Generate documentation

Although I try to make my API’s as descriptive as possible, sometimes good documentation can still make a difference.

One way to enable documentation generation is through Visual Studio:

  • Right click on your project and select Properties.
  • On the Properties window go to the Build tab.
  • Check the XML documentation file checkbox
  • Don’t forget to save these changes.

As a result the following is added to your csproj file:

There are a few things I don’t like about this:

  • First a condition is applied to the PropertyGroup which doesn’t seem necessary
  • Second an absolute path is used to define where to generate the documentation XML

So I would recommend no longer to use this approach. What you can do instead is directly manipulate the csproj file and add the following line to a PropertyGroup:

Wednesday, May 20, 2020

Git sparse checkout

With the growing usage of mono-repositories the standard git checkout or git status no longer work and become frustrating slow. A solution would be to use Git LFS(Large File Storage) but not all repositories have this extension installed.

An alternative solution can be provided through the (new) git sparse-checkout command.

To restrict your working directory to a set of directories, run the following commands:

  1. git sparse-checkout init
  2. git sparse-checkout set <dir1> <dir2> ...

If you get stuck, run git sparse-checkout disable to return to a full working directory.

Remark: this feature is part of git 2.25. So if the command is not recognized check your git version and update first.

More information:

Tuesday, May 19, 2020

Azure Pipelines- Error executing dotnet restore task

When trying to execute dotnet restore during a build it failed with the following error message:

2020-05-12T18:14:36.8332220Z C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(536,5): error :   The '@' character, hexadecimal value 0x40, cannot be included in a name. Line 6, position 35. [D:\b\4\agent\_work\200\s\IAM.Core\IAM.Core.csproj]

2020-05-12T18:14:36.8820520Z      2>Done Building Project "D:\b\4\agent\_work\200\s\IAM.Core\IAM.Core.csproj" (_GenerateRestoreGraphProjectEntry target(s)) -- FAILED.

2020-05-12T18:14:36.9152564Z      1>Project "D:\b\4\agent\_work\200\s\IAM.Core.Tests\VLM.IAM.Core.Tests.csproj" (1) is building "D:\b\4\agent\_work\200\s\IAM.Core.Tests\IAM.Core.Tests.csproj" (1:5) on node 1 (_GenerateRestoreGraphProjectEntry target(s)).

2020-05-12T18:14:36.9162330Z      1>C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(536,5): error : NuGet.Config is not valid XML. Path: 'D:\b\4\agent\_work\200\Nuget\tempNuGet_60617.config'. [D:\b\4\agent\_work\200\s\IAM.Core.Tests\IAM.Core.Tests.csproj]

2020-05-12T18:14:36.9162330Z C:\Program Files\dotnet\sdk\3.1.201\NuGet.targets(536,5): error :   The '@' character, hexadecimal value 0x40, cannot be included in a name. Line 6, position 35. [D:\b\4\agent\_work\200\s\IAM.Core.Tests\IAM.Core.Tests.csproj]

2020-05-12T18:14:36.9162330Z      1>Done Building Project "D:\b\4\agent\_work\200\s\IAM.Core.Tests\IAM.Core.Tests.csproj" (_GenerateRestoreGraphProjectEntry target(s)) -- FAILED.

2020-05-12T18:14:36.9230692Z      1>Done Building Project "D:\b\4\agent\_work\200\s\IAM.Core.Tests\IAM.Core.Tests.csproj" (Restore target(s)) -- FAILED.


Let’s have a look at our nuget.config file to see what is going wrong:

It turns out that NuGet doesn’t like that you use an ‘@’ sign in the name of the feed.

Renaming solved the problem…

Monday, May 18, 2020

ASP.NET Core–The magic appearance of IMemoryCache

I created a small security library in .NET Core that simplifies the rather complex security setup we have at one of my clients. Inside this library I’m using the IMemoryCache to cache some non-volatile data.

When a colleague tried to use this library he told me that he had to add the following line

This doesn’t seem unexpected but the strange this was that in my example project I nowhere added this!? Time to investigate…

A walk through the ASP.NET Core source code (always a fun experience to discover and learn something new about the framework) learned me the following; when you call AddMvc() or AddResponseCaching() the framework will register for you an IMemoryCache behind the scenes.

If you are using a lower level method like AddControllers() this is not the case.

Learned something? Check!

Friday, May 15, 2020

Lens–The Kubernetes IDE

If you are working with Kubernetes I can recommend Lens,  an open-source and free IDE to take control of your Kubernetes clusters.

Thursday, May 14, 2020

Azure Pipelines–DotNet restore error

After configuring a new build pipeline, the build failed with the following error when trying to execute the dotnet restore build task:

NuGet.targets(124,5): error :  Unable to load the service index for source http://tfs:8080/DefaultCollection/_packaging/Feed/nuget/v3/index.json

NuGet.targets(124,5): error :  No credentials are available in the security package

The strange thing was that the same task worked without a problem on other builds. Only for newly created builds it failed with the error message above.

A workaround that seemed to work was to switch the dotnet build task to the ‘custom’ command. By using the custom command I can add an extra ‘--force’ arguments to the ‘dotnet restore’ command. By adding this extra argument I got rid of the error message above.

Wednesday, May 13, 2020

Azure Charts–Help! Azure is evolving too fast…

As most cloud platforms, Azure is evolving quite fast. This makes it hard to keep up-to-date and know where you need to focus your energy on. Azure Charts can help. It is a web based application which allows you to see what the Azure consists of and how it evolves. I would specifically recommend to take a look at the Learning section to see what new Learning content got published.

More information: