Skip to content

2019

How to Generate a Missing project.assets.json in Azure DevOps

We started a few weeks ago to target .Net Standard in our class libraries. While our applications remain for the foreseeable future on the .Net (Full) Framework, we like to start moving code towards .Net Core. Building our solutions in Visual Studio worked without any problems, but as soon as we try to do that in Azure DevOps, we run into this error:

C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file 'c:\agent\_work\95\s\***\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

How to Activate TLS 1.2 on Windows Server 2008 R2 and IIS 7.5

There is always that one machine that you cannot upgrade on a current version because some dependencies outside of your control demand that specific configuration. You may postpone the inevitable, but one day you run out of luck. If your box is a web server, that day will come sooner than you think.

Out of the box, IIS on Windows Server 2008 R2 offers Transport Layer Security only in version 1 (TLS 1.0). That version is outdated and should not be used for securing any HTTPS traffic. Unfortunately, you do not see the version your browser uses to connect to a web server and so it may be that this protocol is still active. If this is the case, your users will not be able to visit your web site when all major browsers block that version at the beginning of 2020.

Little SQL Server Tricks: Creating a Range of Numbers

Some tasks I do in SQL Server would be much simpler if I could get a sequence or a range of numbers. I could create users#1 to user#1000 without any programming – just by using plain old SQL. PostgreSQL offers the generate_series function for such use cases. Unfortunately, there is nothing comparable in SQL Server. All you can find on Google are solutions that are complicated, long and impossible to remember.

Working with Temporary Files in .Net

Working with files in .Net is straightforward. You can use the File or FileInfo classes and call the method with the self-explaining name to create, copy, move or delete files on your system.

However, sometimes all you care about is to write some temporary data to a file. In this case the Path.GetTempFileName() method is exactly what you need. This method creates a uniquely named, zero-byte file in the user's temporary folder and returns the full path of that file.

How to Fix Network Errors with Docker and Windows Containers

Last week I run into this annoying problem when I tired to run the .Net samples for Docker:

Step 7/23 : RUN dotnet restore
> Running in ce2d8740cf2e
Restore completed in 389.74 ms for C:\app\dotnetapp\dotnetapp.csproj.
Restore completed in 220.85 ms for C:\app\utils\utils.csproj.
C:\Program Files\dotnet\sdk\2.2.402\NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\dotnetapp.sln]
C:\Program Files\dotnet\sdk\2.2.402\NuGet.targets(123,5): error : No such host is known [C:\app\dotnetapp.sln]
The command powershell -Command $ErrorActionPreference = Stop; $ProgressPreference = SilentlyContinue; dotnet restore returned a non-zero code: 1

Partial Interfaces in C# - They Exist and There Is a Use Case for Them

Partial classes are a great way to keep (automatically) generated code away from manually written one. All you need to do is to use the partial keyword in front of your class definition and the compiler will combine those partial classes to one single class.

At work, we currently try to figure out a way that would offer us the same flexibility but for interfaces. We have generated classes and can generate an interface for their methods, but we want to be able to extend the functionality with partial classes for the more complex cases. How can we get those methods in the (manually written) partial class in the same interface, without risking those changes to be overwritten with the next run of the generator?

The Most Undervalued Refactoring: Slide Statements

When we refactor our code, we want to make it better. Not just a tiny bit better, a lot better. Therefore, we look at refactorings that change our code in big steps, like extract method or extract class. However, tiny little risk-free steps can bring us to insights that we miss otherwise. Sliding lines of code around is such a tiny little step and often overlooked. What could possibly be gained if a single line of code is moved to another place in the same method? As it turns out, a lot!

How to Force a Group Policy Update on Windows

Group Policy is a feature of the Windows operating system that lets you define company-wide rules that are applied to all accounts and machines in an organisation. For example, your company can use a ruleset in a Group Policy Object (GPO) to prevent you from accepting third-party cookies in your browser or set the location of your home directory to somewhere else than C:\Users\yourname. When everything works as it should, you do not need to know anything about them. However, when things go wrong you better know at least the two commands I explain in this post.

3 Great Resources to Start with Docker (& .Net)

Popular technologies come with an enormous amount of "promotional" material. Docker is no exception to this rule: you find an endless stream of things to read, to watch and to listen to about Docker and containers. With only a limited amount of time at your hand, where should you spend it?

A few weeks ago, I was facing the same problem. I found many things that were not so useful, and I spent far too much time on them. However, at the same time I found the 3 resources I like to share with you today. I hope they can be of great use for you too. I am still new to the topic and appreciate if you post your favourite books, videos and tutorials as a comment to this post.

Different Styles for Examples in BDD

Behavior-driven development (short BDD) is all about examples. They are used to explain what should happen when certain events occur and what exactly the meaning of a certain requirement is. So far all is simple and straight-forward. The challenges come with writing those examples. There are different ways to express the same ideas and not every style works with every audience.