Sponsor: Using RabbitMQ or Azure Service Bus in your .NET systems? Well, you could just use their SDKs and roll your own serialization, routing, outbox, retries, and telemetry. I mean, seriously, how hard could it be?
I have a tiny library that I wanted to convert to .NET Standard Library. After all was said and done, I figured it might be useful to even point out some minor things I had to deal with along the way. So here’s a mini guide on converting a library to netstandard..csproj conversion
First was I was going to convert the older csproj to the new style used for NetStandard and NetCoreApp. You have few different options here:- Create a new NetStandard Library project and copy all the files over.
- Rewrite the existing csproj file
- Use a conversion tool (CsprojToVs2017)
Package References
All your package references are now in the csproj and no longer in the packages.config. Which is glorious. This means just looking at your existing packages.config and adding the relevant <PackageReference> to your csproj.AssemblyInfo
All the assembly info is now also in the .csproj instead of being in a Properties/AssemblyInfo.cs file. This is easily translated over as well.Slim .csproj
The end result is a much smaller csproj file. Prior the file was 126 lines, and now after conversion is 18.xUnit Tests
I could not get the Visual Studio Test Runner or by callingdotnet test
to recognize the tests that are inside a netstandard library. Because of this I changed my test project to be a netcoreapp1.1
, which then worked.
NuSpec
If you are building a NuGet package, the files to be included in your nuspec file will likely have to change since the output of your assemblies will be prefixed with theTargetFramework
. In my case this now resulted in the assemblies being outputted to: bin\Release\netstandard1.6\Nancy.Gzip.dll
AppVeyor
There were a couple of changes I need to make in AppVeyor as well. First I needed to change my build worker image to Visual Studio 2017. This can be found in Settings > Environment, if you’re using the UI.
dotnet test
