发布.NET Core应用程序时,它会输出运行时目录,其中包含以下子目录:
When I publish my .NET Core app, it outputs a runtimes directory with the following sub-directories:
- publish/runtimes/ - debian.8-x64/ - fedora.23-x64/ - fedora.24-x64/ - opensuse.13.2-x64/ - opensuse.42.1-x64/ - osx/ - osx.10.10-x64/ - rhel.7-x64/ - ubuntu.14.04-x64/ - ubuntu.16.04-x64/ - ubuntu.16.10-x64/ - unix/ - win/在CI / CD服务器上,我使用以下命令发布应用程序:
On my CI/CD server I publish my applications with this command:
dotnet publish -c Release -o ..\publish我在项目文件中的发布设置如下:
My publish settings in the project file are the following:
- 目标框架:netcoreapp2。 1
- 部署模式:框架相关
- 目标运行时:win-x64
我只打算在Windows 2上发布此应用程序016服务器,因此不需要OSX / Linux / Unix 运行时文件夹。在某些情况下,这些运行时文件夹包含已知的易受攻击的 dlls ,这会导致错误的OSA扫描误报。
I only plan to publish this application on Windows 2016 Server so the OSX/Linux/Unix runtimes folders are not necessary. Worse in several cases these runtimes folders contain known vulnerable dlls which lead to false positive OSA scans.
是否可以将项目配置为仅输出 win 运行时文件夹?
Is there a way to configure the project to only output the win runtime folder?
更新
我尝试了@ahsteele的建议,将RID添加到我的csproj文件中的输出与如果我没有指定RID。
I have tried the suggestions by @ahsteele and the output of adding the RIDs to my csproj files is the same as if I did not specify the RIDs.
当我运行CI / CD命令示例
When I run CI/CD command example
dotnet publish -c Release -r win10-x86 -o ..\publish我相信创建一个独立的部署。当我的发布目录从55MB变为120MB,从237个文件变为482个文件。
I believe it creates a self-contained deployment. As my publish directory goes from being 55MB to 120MB and from 237 files to 482 files.
更新2
我尝试为发布步骤指定启动项目,并且它构建的运行时目录更加紧凑。
I have tried specifying my startup project for the publish step and it builds the run time directories to be more compact.
这是build命令我正在运行:
Here is the build command I am running:
dotnet publish .\startupProject.csproj -c Release -o ..\publish这是输出:
- publish/runtimes/ - unix/ - win/我的解决方案中的某些项目确实指定了netstandard2.0,有些项目指定了netcoreapp2.0。如果您未指定目标框架或特定的csproj文件,Microsoft是否会在任何地方进行文档编制,它将为您提供所有可能的运行时的所有目标框架?
Some of the projects in my solution do specify netstandard2.0 and some specify netcoreapp2.0. Does Microsoft document anywhere that if you don't specify a target framework or a specific csproj file, it will give you all of the target frameworks for all of the possible runtimes?
推荐答案您应该可以使用 dotnet发布 -r 开关。从 .NET Core RID目录-Windows RID Windows 10 / Windows Server 2016 RID为:
You should be able to specify your runtime with the dotnet publish -r switch. From the .NET Core RID Catalog - Windows RIDs the Windows 10 / Windows Server 2016 RIDs are:
- win10-x64
- win10- x86
- win10-arm
- win10-arm64
- win10-x64
- win10-x86
- win10-arm
- win10-arm64
表示您的CI / CD命令可以指定运行时:
Meaning that your CI/CD command can specify the runtime:
dotnet publish -c Release -r win10-x86 -o ..\publish或者,可以在 < RuntimeIdentifier> 元素:
Alternatively a single RID can be set in the <RuntimeIdentifier> element of your project file:
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>可以在项目文件的 < RuntimeIdentifiers> 元素:
Multiple RIDs can be defined as a semicolon-delimited list in the project file's <RuntimeIdentifiers> element:
<RuntimeIdentifiers>win10-x64;win10-x86</RuntimeIdentifiers>更多推荐
发布时,如何定位特定的.NET Core运行时?
发布评论