AppSelfHostBased in test project causes error


I encountered the same problem as

and can get it to work by changing skd to sdk.web

I have a test project where I create a AppSelfHostBased for integration test and since moving from netcore3.1 to net5 I get in the OneTimeSetUp

System.TypeLoadException : Could not load type ‘Microsoft.Extensions.Primitives.InplaceStringBuilder’ from assembly ‘Microsoft.Extensions.Primitives, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60’.

The template project for ServiceStack works so is there no other solution to change sdk to sdk.web?

You can try explicitly referencing the packages which has the missing types, e.g:

But you could forever be chasing transitive dependencies like this down, when your web integration tests could just be referencing <Project Sdk="Microsoft.NET.Sdk.Web">.

Well I went down the rabbit hole and realised I had a bit more than my services interfaces in the corresponding project. I had a left-over client referencing the http.polly extension :sweat_smile: :sweat_smile:
When I relocated it in an adequate project, all things went back to normal and my test library is back to referencing just sdk.

1 Like