• <bdo id='tHbMs'></bdo><ul id='tHbMs'></ul>
    <i id='tHbMs'><tr id='tHbMs'><dt id='tHbMs'><q id='tHbMs'><span id='tHbMs'><b id='tHbMs'><form id='tHbMs'><ins id='tHbMs'></ins><ul id='tHbMs'></ul><sub id='tHbMs'></sub></form><legend id='tHbMs'></legend><bdo id='tHbMs'><pre id='tHbMs'><center id='tHbMs'></center></pre></bdo></b><th id='tHbMs'></th></span></q></dt></tr></i><div id='tHbMs'><tfoot id='tHbMs'></tfoot><dl id='tHbMs'><fieldset id='tHbMs'></fieldset></dl></div>

    1. <small id='tHbMs'></small><noframes id='tHbMs'>

        <legend id='tHbMs'><style id='tHbMs'><dir id='tHbMs'><q id='tHbMs'></q></dir></style></legend>
      1. <tfoot id='tHbMs'></tfoot>
      2. .NET 5 从单个文件发布中排除了一些库

        时间:2023-06-25
          <i id='M14jJ'><tr id='M14jJ'><dt id='M14jJ'><q id='M14jJ'><span id='M14jJ'><b id='M14jJ'><form id='M14jJ'><ins id='M14jJ'></ins><ul id='M14jJ'></ul><sub id='M14jJ'></sub></form><legend id='M14jJ'></legend><bdo id='M14jJ'><pre id='M14jJ'><center id='M14jJ'></center></pre></bdo></b><th id='M14jJ'></th></span></q></dt></tr></i><div id='M14jJ'><tfoot id='M14jJ'></tfoot><dl id='M14jJ'><fieldset id='M14jJ'></fieldset></dl></div>

              • <small id='M14jJ'></small><noframes id='M14jJ'>

                  <bdo id='M14jJ'></bdo><ul id='M14jJ'></ul>
                    <tbody id='M14jJ'></tbody>

                • <legend id='M14jJ'><style id='M14jJ'><dir id='M14jJ'><q id='M14jJ'></q></dir></style></legend>
                • <tfoot id='M14jJ'></tfoot>

                  本文介绍了.NET 5 从单个文件发布中排除了一些库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在使用 .NET 5 发布单个文件可执行文件时遇到了一个小问题.
                  事实上,它并不包括可执行文件中的所有库,而是产生多个文件.

                  I have a little problem with single file executable publish with .NET 5.
                  Infact, it does not include all libraries in the executable file, and produces multiple files.

                  在我的示例中,我使用的是 SQLite (Microsoft.Data.Sqlite) 库,并且在编译后,不包括 e_sqlite3.dll.
                  相反,在输出文件夹中,它会生成两个文件(不包括 pdb 文件):

                  In my example I'm using a library for SQLite (Microsoft.Data.Sqlite) and, after compilation, e_sqlite3.dll is not included.
                  Instead, in the output folder, it produces two files (excluding the pdb file):

                  > e_sqlite3.dll
                  > WpfApp1.exe
                  

                  推荐答案

                  通过阅读 文档

                  默认情况下,单个文件不捆绑本机库.在 Linux 上,我们将运行时预链接到包中,并且仅将应用程序本机库部署到与单文件应用程序相同的目录中.在 Windows 上,我们仅预链接托管代码,运行时和应用程序本机库都部署到与单文件应用程序相同的目录中.这是为了确保良好的调试体验,这需要从单个文件中排除本机文件.有一个选项可以设置标志 IncludeNativeLibrariesForSelfExtract,以在单个文件包中包含本机库,但是当运行单个文件应用程序时,这些文件将被提取到客户端计算机的临时目录中.

                  Single-file doesn't bundle native libraries by default. On Linux, we prelink the runtime into the bundle and only application native libraries are deployed to the same directory as the single-file app. On Windows, we prelink only the hosting code and both the runtime and application native libraries are deployed to the same directory as the single-file app. This is to ensure a good debugging experience, which requires native files to be excluded from the single file. There is an option to set a flag, IncludeNativeLibrariesForSelfExtract, to include native libraries in the single file bundle, but these files will be extracted to a temporary directory in the client machine when the single file application is run.

                  因此(在我的情况下e_sqlite3.dll)默认情况下不包含本机库以确保良好的调试体验.
                  如果您想将它们包含在应用程序可执行文件中,只需将此行添加到项目 (.csproj) 文件中即可.

                  So (in my case e_sqlite3.dll) native libraries are not included by default to ensure a good debugging experience.
                  If you want to include them anyway in the application executable, you can simply add this line to the project (.csproj) file.

                  <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
                  

                  示例:

                  <Project Sdk="Microsoft.NET.Sdk">
                  
                    <PropertyGroup>
                      <OutputType>WinExe</OutputType>
                      <TargetFramework>net5.0-windows</TargetFramework>
                      <UseWPF>true</UseWPF>
                      <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
                      <StartupObject>WpfApp1.App</StartupObject>
                      <Description>WpfApp1</Description>
                    </PropertyGroup>
                  
                  ...
                  
                  </Project>
                  

                  这篇关于.NET 5 从单个文件发布中排除了一些库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:ODP.Net 驱动程序在 .NET Core 5.0 上引发异常 下一篇:是“CLR 集成"吗?在数据库级别或服务器/实例级别启用?

                  相关文章

                    1. <i id='IGg6Z'><tr id='IGg6Z'><dt id='IGg6Z'><q id='IGg6Z'><span id='IGg6Z'><b id='IGg6Z'><form id='IGg6Z'><ins id='IGg6Z'></ins><ul id='IGg6Z'></ul><sub id='IGg6Z'></sub></form><legend id='IGg6Z'></legend><bdo id='IGg6Z'><pre id='IGg6Z'><center id='IGg6Z'></center></pre></bdo></b><th id='IGg6Z'></th></span></q></dt></tr></i><div id='IGg6Z'><tfoot id='IGg6Z'></tfoot><dl id='IGg6Z'><fieldset id='IGg6Z'></fieldset></dl></div>
                        <bdo id='IGg6Z'></bdo><ul id='IGg6Z'></ul>
                    2. <legend id='IGg6Z'><style id='IGg6Z'><dir id='IGg6Z'><q id='IGg6Z'></q></dir></style></legend>
                    3. <tfoot id='IGg6Z'></tfoot>

                      <small id='IGg6Z'></small><noframes id='IGg6Z'>