Do I use the .NET CLI if I want to create an ASP.NET Core 1.0 app that uses the .NET Framework? Is .NET CLI only for the new .NET Core library or both Core and .NET 4.6?
You can use dotnet cli
for full framework apps and libraries as well. You just need to use the appropriate framework tag - for example "net46"
to target .NET 4.6. You can target multiple frameworks, too:
For example, from my Noda Time library:
"frameworks": {
"net45": {
"frameworkAssemblies": {
"System.Xml": "",
"System.Numerics": ""
}
},
"netstandard1.1": {
"buildOptions": {
"define": [ "PCL" ]
},
"dependencies": {
"System.Diagnostics.Debug": "4.0.11",
"System.Globalization": "4.0.11",
"System.Linq": "4.1.0",
"System.Resources.ResourceManager": "4.0.1",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.Numerics": "4.0.1",
"System.Runtime.Serialization.Xml": "4.1.1",
"System.Threading": "4.0.11",
"System.Xml.XmlSerializer": "4.0.11"
}
}
}
The PCL
preprocessor symbol will be renamed to "DOTNET_CORE" or similar at some point - it's only there because I have a bunch of code that uses it for conditional compilation back when I used to target portable class libraries.
You can still also target portable class libraries, by the way... so a single package can target many different versions.
Do I use the CLI if I want to create an ASP.NET Core 1.0 app that uses the .NET Framework?
The .NET CLI is for either, the distinction is actually made in the project.json
file. For example you can use the following command to compile/build the ASP.NET Core application while the application is actually targeting the full-framework:
dotnet build
Here is what an example project.json
would look like targeting .NET 4.6.
{
"frameworks": {
"net46": { }
}
}
For more details I always encourage people to refer to the documentation found here. Likewise, since this is open-source (which is amazing) you can look at the source to understand how it is that this is intended to be used.
CLI is just tooling. What your application will use to run is not coupled to tooling (i.e. as long as the tooling is able to create the correct application for your target framework it does not matter how tooling runs). Rather, in your project.json
file you specify the target framework in form of target framwork moniker (e.g. net451
for .NET Framework 4.5.1 or netcoreapp1.0
for .NET Core apps etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With