3

I created two projects using Visual Studio 2015 RC

  1. a class library MyLib which its target framework is .NET Framework 4.5.1
  2. an ASP.NET 5 project MyWebApp which references MyLib in project.json:

    "frameworks": { "dnx451": { "dependencies": { "Lib01": "1.0.0-*" } }, }

When I trying to build MyWebApp, an warning occurs:

MSB3274: The primary reference "C:\MyWebApp\src\MyLib\bin\Debug\MyLib.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.5.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".

The warning will disappear if I change the target framework of MyLib to 4.5.

It seems like the MyWebApp is targeting .net framework 4.5 rather than 4.5.1? How to make MyWebApp references a library targeting .net 4.5.1?

Smartkid
  • 1,772
  • 2
  • 25
  • 34

1 Answers1

0

This warning doesn't seem to mean much. It it still visible even if .net version of web project is set to be greater than library's e.g.

"net46": {                
  "dependencies": {
    "Lib01": "1.0.0-*"
  }
}

Another interesting thing that it's possible to have library build against .NET Framework 4.6 (latest) and still build/run and use classes from within dnx451 project (I've passed readonly Queue available only in 4.6 as IReadOnlyCollection from lib to web application).

Besides that as far as I know .net 4.5.1 has not introduced changes for API and it's not very easy to test difference between 4.5 and 4.5.1

And finally if you want to get rid of warning you can create vNext type class library (Package) and then refer it from ASP.NET 5 Application, so your class library could use dnx451 the same as web app.

Andriy Horen
  • 2,861
  • 4
  • 18
  • 38
  • so the warning can be safely ignored? – Smartkid Jun 06 '15 at 08:57
  • I think yes, as far as you can use it, however It's reasonable to switch to the new asp.net 5 type of libraries, here is few good points why [Why create an ASP.NET 5 Class Library project?](http://stackoverflow.com/questions/28034174/why-create-an-asp-net-5-class-library-project) – Andriy Horen Jun 06 '15 at 09:10
  • Is there a away to suppress this warning when building the ASP.NET 5 project? I found nothing related to suppress warnings in https://github.com/aspnet/Home/wiki/Project.json-file – Smartkid Jun 10 '15 at 09:25