简体   繁体   English

如何确定.net应用程序是否是“核心”应用程序?

[英]how to determine if a .net app is a “core” app?

I need to update a new .NET app and I think it was mentioned that it was .NET Core. 我需要更新一个新的.NET应用程序,我认为有人提到它是.NET Core。 How can I examine the solution properties to determine if it is in fact a "core" app? 如何检查解决方案属性以确定它是否实际上是一个“核心”应用程序?

The web project has a System.Core reference but I googled this and it seems that System.Core.dll has been a part of the .NET framework since at least .NET f/w 3.5. Web项目有一个System.Core引用,但我搜索了这个,似乎System.Core.dll已经成为.NET框架的一部分,因为至少.NET f / w 3.5。

The app has a package.json file but the existence of that file in a sln does not necessarily guarantee that the app is a .NET core app. 该应用程序有一个package.json文件,但在sln中存在该文件并不一定保证该应用程序是.NET核心应用程序。 I've also read that a .NET core app can run on different .NET framework versions. 我还读到.NET核心应用程序可以在不同的.NET框架版本上运行。

So how can I determine if a .NET app is indeed a "Core" app? 那么如何确定.NET应用程序是否确实是“核心”应用程序? In other words, what makes a Core app a Core app? 换句话说,什么使Core应用程序成为Core应用程序?

Updated for .NET Core >= 2.x and/or VS2017 已针对.NET Core> = 2.x和/或VS2017进行了更新

In VS2017 .NET Core projects use the .csproj structure again. 在VS2017中,.NET Core项目再次使用.csproj结构。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreappx.y</TargetFramework>
  </PropertyGroup>

or 要么

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandardx.y</TargetFramework>
  </PropertyGroup>

Old Answer for .NET Core 1.x and VS2015 .NET Core 1.x和VS2015的旧答案

There are some indicators to it. 有一些指标。

The existence project.json suggest it's one of the newer project forms (be aware though that project.json will go away with .NET Core/.NET Core Tools for VS with Version 1.1). 存在project.json建议它是较新的项目形式之一(请注意,虽然project.json将使用版本1.1的.NET核心/ .NET核心工具for VS)。

Inside it, you'll have a frameworks section, like 在它里面,你会有一个框架部分,比如

"frameworks": {
  "net45": {
    "frameworkAssemblies": {
      "System.Runtime.Serialization": "4.0.0.0"
    }
  },
  "netstandard1.0": {
    "imports": [ "dnxcore50", "portable-net45+win8" ],
    "dependencies": {
    }
  },
  "netstandard1.3": {
    "imports": [ "dnxcore50", "portable-net45+win8" ],
    "dependencies": {
      "System.Runtime.Serialization.Formatters": "4.0.0-rc3-24212-01"
    }
  }
}

In case of applications (ASP.NET Core Web Project or new project.json based console applications), netstandard1.x will be named netcoreapp1.0 . 对于应用程序(ASP.NET Core Web Project或基于new project.json的控制台应用程序), netstandard1.x将命名为netcoreapp1.0

If there is more than one entry, the application or library targets multiple platforms (and will build multiple binary files in separate folders). 如果有多个条目,则应用程序或库将以多个平台为目标(并将在单独的文件夹中构建多个二进制文件)。

Update 更新

Of course I forgot another indicator. 当然我忘了另一个指标。 .NET Core application do reference Microsoft.NETCore.App (either as "type": "platform" for portable apps or without it for self-contained apps). .NET Core应用程序确实引用了Microsoft.NETCore.App (对于便携式应用程序,可以是"type": "platform" ,也可以不是自包含应用程序)。 netstandard1.x (class libraries) do reference NETStandard.Library . netstandard1.x (类库)确实引用了NETStandard.Library

.NET Core applications are based on System.Runtime which is a part of .NET Framework 4.5 and newer and used for Windows (and Windows Phone) 8.0/8.1/10 applications, hence portable-net45+win81 packages are compatible with .NET Core too. .NET Core应用程序基于System.Runtime ,它是.NET Framework 4.5及更新版本的一部分,用于Windows(和Windows Phone)8.0 / 8.1 / 10应用程序,因此portable-net45+win81软件包与.NET Core兼容太。

That being said, ASP.NET Core is a webstack which can run on both, full .NET Framework (4.5 or higher) and on .NET Core. 话虽如此,ASP.NET Core是一个可以在完整的.NET Framework(4.5或更高版本)和.NET Core上运行的webstack。 So just having a ASP.NET Core application do not tell much about the platform it aims. 因此,拥有一个ASP.NET核心应用程序并不能说明它所针对的平台。

It is quite easy to determine Asp.net Core application. 确定Asp.net Core应用程序非常容易。

There are some identifiers to it. 它有一些标识符。 There are few file in a project that helps to determine Core Project 项目中的文件很少,有助于确定核心项目

Files like 文件就像

  • project.json project.json
  • appsetting.json appsetting.json
  • startup.cs startup.cs

Inside project.json, it include 在project.json里面,它包括

"dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
"frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

Here by dependencies one can determine about the type of project..NET Core application do reference Microsoft.NETCore.App (either as "type": "platform" for portable apps or without it for self-contained apps). 这里dependencies可以确定项目的类型.NET核心应用程序确实引用了Microsoft.NETCore.App(对于便携式应用程序,可以是“类型”:“平台”,也可以不用于自包含应用程序)。

Asp.net Core Application are platform independent, So a ASP.NET Core application do not express much about the platform . Asp.net核心应用程序是独立于平台的,因此ASP.NET核心应用程序对该平台没有太多表达。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM