dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.21k stars 9.95k forks source link

how to choose frameworks and what frameworks should be imported in a framework? #1619

Closed anobaka closed 8 years ago

anobaka commented 8 years ago
  1. what's the differences importing 'net45' and 'portable-net45+win81' in frameworks?when and what version should I import?will adding imports:["net45"] in netcoreapp1.0 bring all dependencies of .netframework4.5? Is there a performance cost?
  2. is dnx still used in asp.net core? I created .net core class library project and in its project.json I found 'imports:"dnxcore50"'
  3. If there are over 90% of my company's projects are using netcoreapp1.0 or netstandard1.6, what am I supposed to do while a foundation project(used by many other projects) reference an old version library that is incompatible with netcodeapp.10/netstandard1.6?
  4. Can framework netcoreapp1.0 importing net452 run in docker?

Thanks a lot.

davidfowl commented 8 years ago

what's the differences importing 'net45' and 'portable-net45+win81' in frameworks?when and what version should I import?

The idea behind imports is to ignore the compat rules older libraries that cannot be recompiled to see if it can work in a .NET Core project. Some portable class libraries profiles will just work but net45 (.NET Framework) class libraries will not work.

will adding imports:["net45"] in netcoreapp1.0 bring all dependencies of .netframework4.5? Is there a performance cost?

There's no performance cost but it wont work. netcoreapp1.0 is the .NET Core framework target and net45 isn't compatible. There are only a few things safe to import (portable-* frameworks for example) and even those should only be added when required.

is dnx still used in asp.net core? I created .net core class library project and in its project.json I found 'imports:"dnxcore50"'

Nope, that's legacy to let older libraries work with the latest netcoreapp1.0 target. We've changed the target framework many times over the last 2.5 years so this was a compatibility thing. dnxcore will be completely gone by the next release.

If there are over 90% of my company's projects are using netcoreapp1.0 or netstandard1.6, what am I supposed to do while a foundation project(used by many other projects) reference an old version library that is incompatible with netcodeapp.10/netstandard1.6?

I'm not sure what a foundation project is? I'm assuming it's some core component that's shared throughout the company? The general guidance is that class libraries should use the netstandard target framework and .NET Core applications should be netcoreapp target framework.

If you have lots of foundation projects that are targeting .NET Framework, then they either need to be ported to .NET Core (and netstandard) or you'll need to keep using .NET Framework. There's no way to make that work, even with imports. Imports will help the package install, but it won't make it function.

Can framework netcoreapp1.0 importing net452 run in docker?

It can't run on anything.

anobaka commented 8 years ago

@davidfowl, I really appreciate it, it helps me a lot ! But there is something still confusing me:

netcoreapp1.0 is the .NET Core framework target and net45 isn't compatible. There are only a few things safe to import (portable-* frameworks for example) and even those should only be added when required.

Does it mean all versions of .NetFramework could not be imported in netcoreapp1.0? I found a sheet about .NET Platforms Support in https://docs.microsoft.com/zh-cn/dotnet/articles/standard/library#net-platforms-support, it seems like I can import net463 in netcoreapp1.0, am I right?

And I'm not sure about what frameworks(netxxx, portable-*, etc) I can import in netcoreapp1.0 or other framework versions, is there a full documentation about it?

davidfowl commented 8 years ago

Does it mean all versions of .NetFramework could not be imported in netcoreapp1.0?

That's correct.

I found a sheet about .NET Platforms Support in https://docs.microsoft.com/zh-cn/dotnet/articles/standard/library#net-platforms-support, it seems like I can import net463 in netcoreapp1.0, am I right?

No, you're misinterpreting that table. Think about it this way, you have 2 classes that both implement the same interface:

interface INetStandard
{
    void StandardApi();
}
public class NetFramework463 : INetStandard
{
    void NetFrameworkApi();
}
public class NetCoreApp : INetStandard
{
    void NetCoreApi();
}

Trying to import NETFramework463 to NETCoreApp is like trying to do a cast an object of type NETFramework463 to an object of type NETCoreApp. That doesn't work even though they share the same INetStandard interface.

anobaka commented 8 years ago

@davidfowl get it, thank you very much !