.net core 没有运行时定义的.NET核心自包含部署会产生什么?

.net core 没有运行时定义的.NET核心自包含部署会产生什么?,.net-core,.net Core,我有一个项目,其csproj类似于: <PropertyGroup> <OutputType>Exe</OutputType> <TargetFrameworks>netstandard2.0;netcoreapp1.1</TargetFrameworks> <AssemblyName>ConsoleApp</AssemblyName> <PackageId>ConsoleApp<

我有一个项目,其csproj类似于:

<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFrameworks>netstandard2.0;netcoreapp1.1</TargetFrameworks>
  <AssemblyName>ConsoleApp</AssemblyName>
  <PackageId>ConsoleApp</PackageId>
  <Version>1.0.0.1</Version>
  <RootNamespace>ConsoleApp</RootNamespace>
  <RuntimeIdentifiers>win10-x64;android.21;android.21-arm64;osx.10.12;rhel7.4;centos.7-x64;debian.8-x64;ubuntu.16.10-x64;fedora.26-x64;opensuse.42.1-x64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup Condition=" '$(_ShortFrameworkIdentifier)' == 'netstandard' ">   
  <PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="1.1.1" />
  <PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="1.1.0" />
</ItemGroup>

Exe
netstandard2.0;netcoreapp1.1
控制台
控制台
1.0.0.1
控制台
win10-x64;6.21;android.21-arm64;osx.10.12;rhel7.4;centos.7-x64;debian.8-x64;ubuntu.16.10-x64;fedora.26-x64;opensuse.42.1-x64
如果我运行
dotnet publish-c Release-f netstandard2.0
并且没有指定运行时,我会在以下位置获得输出:
。\bin\Release\netstandard2.0\publish
,它看起来像是一个自包含的部署,但主“可执行文件”是一个dll(与定义运行时相反,我会得到一个exe或一个没有扩展名的文件)还有一个名为runtimes的文件夹,看起来它有一些针对不同操作系统(如unix、osx、rhel,如System.Security.Cryptography.Algorithms等)的特定于运行时的库


这种类型的出版实际上产生了什么?这组文件在任何方面都有用吗?

如果您将即将推出的工具用于
netstandard2.0
,这将不会生成可用的部署,因为对于2.0,所有包(
NETStandard.Library
Microsoft.NETCore.App
)都是扁平的,没有引用单个组件

当以
netstandard1.6
为目标时,您可以通过这种方式获得“占用空间小”的应用程序的原因主要是由于构建
Microsoft.NETCore.App
的方式的副作用(以netstandard版本为目标,以及为运行时引入实现的单个组件)


发布主入口点的逻辑与从组件解析的组件相关联。对于netcoreapp1.*,重命名了一个
dotnet.exe
/
dotnet
可执行文件,对于2.0+来说,它是
apphost.exe
/
apphost
,它被重命名,并且嵌入了
dll
文件的名称。

您可以使用dotnet运行它。与运行Java或Python程序的方式相比,构建面向.NET标准2.0的控制台应用程序的理性是什么?显然你不必这么做。@LexLi,你是在问为什么要使用.netstandard2.0 vs.netstandard1.6或vs.netcoreapp1.1吗?对于.NET核心控制台应用程序,你应该只针对netcoreappXX。为什么要使用netstandardXX?要使用“小型”SCD部署模型,您需要以netstandardx.x为目标,如Microsoft的文档所示:我完全能够使用
dotnet publish-c Release-f netstandard2.0-r win10-x64以及依赖于框架的netcoreapp部署来创建“小型”SCD。这一切都很好,我只是想知道当输出类型被定义为exe而不是库时,不使用
-r myruntime
支持该命令的目的是什么?结果文件集未使用
dotnet myapp
运行,并导致错误:遇到致命错误。在“..\bin\Release\netstandard2.0\publish”中找不到执行应用程序所需的库“hostpolicy.dll”。是否使用已发布的工具或了解
netstandard2.0
的2.0预览?当前的(1.0.3或今天的1.0.4)CLI将退回到netstandard1.6行为,用于这些包。我使用的是1.0.3。如果我将csproj更改为netstandard1.6,则
。\bin\Release\netstandard1.6\publish
目录中的输出与您所说的完全相同。但我仍然不确定这些文件集合“代表”了什么,或者它们是否基本上是无用的,如果输出类型设置为
exe
时没有定义运行时,我们就不能运行
dotnet publish-f netstandardx.x