@nkolev92 edit:
When I added netcoreapp2.0 as a target for my console application, it failed at runtime because it couldn't find an assembly that was a transitive dependency of one of my package references. When I add the package reference explicitly, it works fine. I inspected the VSMefSample.deps.json file and found that there is no mention of the transitive dependency until I add it as a direct dependency.
It would seem then, that dotnet restore (or equivalent in VS) is not fully restoring transitive dependencies when it tries to see through net45 packages to adapt them to work on netcoreapp2.0.
Repro
git clone https://github.com/AArnott/VSMefSample
cd VSMefSample
git checkout ce6bef7cc49d0c0c15b2da322ef2a78b86e6d178
cd VSMefSample
dotnet restore
dotnet run -f netcoreapp2.0
Expected
dotnet run -f netcoreapp2.0
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Tree
Apple (IsJuicy: True)
Apple (IsJuicy: False)
Pear (IsDelicious: True)
Actual
dotnet run -f netcoreapp2.0
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
C:\Users\andarno\source\repos\VSMefSample\VSMefSample\VSMefSample.csproj : warning NU1701: Package 'Microsoft.VisualStudio.Composition 15.3.38' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Validation, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
at VSMefSample.Program.Main(String[] args)
Version info
dotnet --info
.NET Command Line Tools (2.0.2-vspre-006949)
Product Information:
Version: 2.0.2-vspre-006949
Commit SHA-1 hash: 23fc6ec23d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.2-vspre-006949\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
@nkolev92 edit:
When I added netcoreapp2.0 as a target for my console application, it failed at runtime because it couldn't find an assembly that was a transitive dependency of one of my package references. When I add the package reference explicitly, it works fine. I inspected the VSMefSample.deps.json file and found that there is no mention of the transitive dependency until I add it as a direct dependency.
It would seem then, that
dotnet restore(or equivalent in VS) is not fully restoring transitive dependencies when it tries to see through net45 packages to adapt them to work on netcoreapp2.0.Repro
Expected
Actual
Version info