I tried creating a custom task using .NET 9. The project builds successfully with dotnet build
, but when I try to build it in Visual Studio, it fails with an error:
Could not find file or assembly “System.Runtime, Version=9.0.0.0”
From what I understand, this happens because Visual Studio uses the .NET Framework version of MSBuild, which can’t load .NET Core-built DLLs, while the dotnet
CLI uses the .NET Core version of MSBuild.
Here’s the version difference I found in the Developer command prompt:
> msbuild -version
MSBuild version 17.13.19+0d9f5a35a for .NET Framework
17.13.19.12613
> dotnet msbuild -version
17.13.20.16214
How can I make Visual Studio use the .NET Core version of MSBuild instead?