In my team, we’ve found ourselves in a bit of a peculiar situation.
In our part of the organization, all the microservices must be based on a common template. It’s kind of scaffolding for a microservice project that supports authentication and integrates with logging and monitoring tools out of the box.
A while ago all the templates were updated to be net core projects, while most of our internal libraries still target .NET Framework.
That alone is not a big problem since net core supports targetting the NET Framework. However, things get tricky when you no longer have Visual Studio and your code depends on certain targeting packs from the MSBuild tools portfolio.
Just targeting NET Framework from Core is very simple
A minimal .net core project file which builds for .net framework can be as simple as this:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net471</TargetFramework> </PropertyGroup> </Project>
If you build this project in Visual Studio, it will use its MSBuild that comes with the installation. Those tools are capable of building both old and new style projects. They can also build for the net framework, standard core targets.
Problems arise when you don’t have Visual Studio anymore
But we no don’t develop in Visual Studio. We still have some lingering licenses, and some teams or individuals stick to VS. Most people, however, code in Rider.
Rider allows you to select the MSBuild version you want to use, and as long as you have VS installed, it will pick build tools from there.
And what, if you don’t?
You can use MSBuild Tools
If you go to visual studio download page, you can find Build Tools for Visual Studio 2019 under Tools for Visual Studio 2019. This allows you to install standalone MSBuild together with whatever targeting packs and build tools you might require.
Note that in order to build your net core projects targetting .NET Framework you will need to select ‘.NET Core build tools‘ from the Workloads tab. And for example if your project is a web application, you need ASP.NET and not ASP.NET Core. Therefore ‘Web development build tools‘ will also be needed.
Then from the Individual components tab, you can also pick the desired targeting pack.
Or maybe you cannot?
Rider team reports on their page that MSBuild tools for Visual Studio come with a license agreement that actually requires a valid Visual Studio license.
For us, for now, it is not a problem, but potentially it might.
On the same page, JetBrains write about their own redistributable of MSBuild that can be used freely. This, however, is just MSBuild executable.
What about all the build tools, tasks and, targets our projects require to build and run?
Maybe it’s ok to install them with Build Tools installer and copy the necessary files to Rider’s MSBuild redistributable? Probably not.
All the more reasons to get off the .NET Framework as soon as possible.