I have the follow set of projects in my solution:
1) A .NET framework (4.7.1) project that produces an assembly. "Project A"
2) A ASP.NET core MVC based web api project based on .NET Core 2.1. "Project B"
Project B references Project A, building the solution via Visual Studio 2017 does not lead to any issues. However if I try and build the solution via msbuild using the following command, I am unable to compile Project B:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" D:\Stuff\MySolution.sln" /p:Platform=x64 /p:Configuration=Debug /v:m /clp:Summary
Errors in D:\Stuff\ProjectB\ProjectB.csproj
Unable to resolve 'D:\Stuff\ProjectA\ProjectA.csproj for '.NETCoreApp,Version=v2.1'
Unable to resolve 'D:\Stuff\ProjectA\ProjectA.csproj for '.NETCoreApp,Version=v2.1 (win-x64)'
ProjectB's property group looks like this:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<ProjectGuid>{D41E3CAE-2EE3-4BED-8965-50AF8C243A20}</ProjectGuid>
<RootNamespace>com.ProjectB</RootNamespace>
<AssemblyName>com.ProjectB</AssemblyName>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
And also has the following PackageReference:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0"/>
</ItemGroup>
It is as if MSBuild is trying to apply the target framework defined in ProjectB to ProjectA, however as mentioned before this does not happen in Visual Studio.