I have multi project solution that includes an ASP.NET Web API project and all projects were originally built in >NET Framework 4.7.2. One of the class library projects in the solution I changed to a multi target:
<TargetFrameworks>net472;netstandard2.1</TargetFrameworks>
I worked through everything (specifying different nuget packages for target frameworks and #if NET472_OR_GREATER statements throughout code) and was able to get it to build. With the if statements and target nuget packages, the project is exactly the same for net472 (differences only for netstandard) as it was before the multi target.
I have changed the project references in the .csproj file for all the other projects that reference this project like this:
<ProjectReference Include="..\MyProject\MyProject.csproj">
<SetTargetFramework>TargetFramework=net472</SetTargetFramework>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
Yet, when I run the Web API project (which builds successfully), I get the error:
Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
What am I doing wrong? The Web API project should not need .NET Standard 2.1, right?