VS2022中发布.NET 8 Runtime相关问题咨询
我此前使用VS2022基于.NET 6.0构建C#应用,发布为可移植应用时,publish目录下会包含Runtime文件,确保应用能在未预装.NET 6.0 Runtime的系统中运行,且已用当前.NET 8项目使用的同版本VS2022验证过该流程。
但近期使用最新版VS2022构建基于.NET 8.0的C#应用,发布后publish目录下却没有Runtime文件,查阅资料后未找到相关解释。我是否遗漏了.NET 8 Runtime发布的相关设置?或是.NET 8 Runtime发布机制有变更?(注:此处的“发布”指「生成」菜单中的「发布」命令)
更新1
发现部署模式设置为Framework Dependent(依赖框架),将其改为*Self-Contained(自包含)*后,publish目录下出现大量MS DLL文件。但与.NET 6.0相比,.NET 8.0存在以下差异:
- publish目录下不再有
runtime子目录; - publish目录下包含约185个DLL文件及1个
createdump程序,而.NET 6.0发布仅新增约15个DLL。
我将此前仅用于读写本地CSV文件的.NET 6.0程序升级为.NET 8.0版本,发布目录却从新增约15个Windows/.NET DLL变为新增185+个DLL,其中包含加密、网络及Web相关资源,我认为这属于.NET 8.0的冗余问题。现在疑惑:我的应用发布操作是否正确?
更新2
.NET 6.0应用发布目录下的文件(不含应用自身文件)结构如下:
blah\blah\Publish\ | Microsoft.Extensions.Configuration.Abstractions.dll | Microsoft.Extensions.Configuration.dll | Microsoft.Extensions.Configuration.FileExtensions.dll | Microsoft.Extensions.Configuration.Json.dll | Microsoft.Extensions.FileProviders.Abstractions.dll | Microsoft.Extensions.FileProviders.Physical.dll | Microsoft.Extensions.FileSystemGlobbing.dll | Microsoft.Extensions.Primitives.dll | Microsoft.IO.RecyclableMemoryStream.dll | Microsoft.Win32.SystemEvents.dll | System.Drawing.Common.dll | System.Security.Cryptography.Pkcs.dll | System.Xml.XPath.XmlDocument.dll | \---runtimes +---unix | \---lib | \---netcoreapp3.0 | System.Drawing.Common.dll | \---win \---lib \---netcoreapp3.0 Microsoft.Win32.SystemEvents.dll System.Drawing.Common.dll System.Security.Cryptography.Pkcs.dll
仅将程序从.NET 6.0升级为.NET 8.0并重新发布后,发布文件如下(所有文件均在同一目录,无任何子目录):
Blah\Blah\Publish\ clretwrc.dll clrgc.dll clrjit.dll coreclr.dll createdump.exe hostfxr.dll hostpolicy.dll Microsoft.CSharp.dll Microsoft.DiaSymReader.Native.x86.dll Microsoft.Extensions.Configuration.Abstractions.dll Microsoft.Extensions.Configuration.dll Microsoft.Extensions.Configuration.FileExtensions.dll Microsoft.Extensions.Configuration.Json.dll Microsoft.Extensions.FileProviders.Abstractions.dll Microsoft.Extensions.FileProviders.Physical.dll Microsoft.Extensions.FileSystemGlobbing.dll Microsoft.Extensions.Primitives.dll Microsoft.IO.RecyclableMemoryStream.dll Microsoft.VisualBasic.Core.dll Microsoft.VisualBasic.dll Microsoft.Win32.Primitives.dll Microsoft.Win32.Registry.dll Microsoft.Win32.SystemEvents.dll mscordaccore.dll mscordaccore_x86_x86_8.0.324.11423.dll mscordbi.dll mscorlib.dll mscorrc.dll msquic.dll netstandard.dll System.AppContext.dll System.Buffers.dll System.Collections.Concurrent.dll System.Collections.dll System.Collections.Immutable.dll System.Collections.NonGeneric.dll System.Collections.Specialized.dll System.ComponentModel.Annotations.dll System.ComponentModel.DataAnnotations.dll System.ComponentModel.dll System.ComponentModel.EventBasedAsync.dll System.ComponentModel.Primitives.dll System.ComponentModel.TypeConverter.dll System.Configuration.dll System.Console.dll System.Core.dll System.Data.Common.dll System.Data.DataSetExtensions.dll System.Data.dll System.Diagnostics.Contracts.dll System.Diagnostics.Debug.dll System.Diagnostics.DiagnosticSource.dll System.Diagnostics.FileVersionInfo.dll System.Diagnostics.Process.dll System.Diagnostics.StackTrace.dll System.Diagnostics.TextWriterTraceListener.dll System.Diagnostics.Tools.dll System.Diagnostics.TraceSource.dll System.Diagnostics.Tracing.dll System.dll System.Drawing.Common.dll System.Drawing.dll System.Drawing.Primitives.dll System.Dynamic.Runtime.dll System.Formats.Asn1.dll System.Formats.Tar.dll System.Globalization.Calendars.dll System.Globalization.dll System.Globalization.Extensions.dll System.IO.Compression.Brotli.dll System.IO.Compression.dll System.IO.Compression.FileSystem.dll System.IO.Compression.Native.dll System.IO.Compression.ZipFile.dll System.IO.dll System.IO.FileSystem.AccessControl.dll System.IO.FileSystem.dll System.IO.FileSystem.DriveInfo.dll System.IO.FileSystem.Primitives.dll System.IO.FileSystem.Watcher.dll System.IO.IsolatedStorage.dll System.IO.MemoryMappedFiles.dll System.IO.Pipes.AccessControl.dll System.IO.Pipes.dll System.IO.UnmanagedMemoryStream.dll System.Linq.dll System.Linq.Expressions.dll System.Linq.Parallel.dll System.Linq.Queryable.dll System.Memory.dll System.Net.dll System.Net.Http.dll System.Net.Http.Json.dll System.Net.HttpListener.dll System.Net.Mail.dll System.Net.NameResolution.dll System.Net.NetworkInformation.dll System.Net.Ping.dll System.Net.Primitives.dll System.Net.Quic.dll System.Net.Requests.dll System.Net.Security.dll System.Net.ServicePoint.dll System.Net.Sockets.dll System.Net.WebClient.dll System.Net.WebHeaderCollection.dll System.Net.WebProxy.dll System.Net.WebSockets.Client.dll System.Net.WebSockets.dll System.Numerics.dll System.Numerics.Vectors.dll System.ObjectModel.dll System.Private.CoreLib.dll System.Private.DataContractSerialization.dll System.Private.Uri.dll System.Private.Xml.dll System.Private.Xml.Linq.dll System.Reflection.DispatchProxy.dll System.Reflection.dll System.Reflection.Emit.dll System.Reflection.Emit.ILGeneration.dll System.Reflection.Emit.Lightweight.dll System.Reflection.Extensions.dll System.Reflection.Metadata.dll System.Reflection.Primitives.dll System.Reflection.TypeExtensions.dll System.Resources.Reader.dll System.Resources.ResourceManager.dll System.Resources.Writer.dll System.Runtime.CompilerServices.Unsafe.dll System.Runtime.CompilerServices.VisualC.dll System.Runtime.dll System.Runtime.Extensions.dll System.Runtime.Handles.dll System.Runtime.InteropServices.dll System.Runtime.InteropServices.JavaScript.dll System.Runtime.InteropServices.RuntimeInformation.dll System.Runtime.Intrinsics.dll System.Runtime.Loader.dll System.Runtime.Numerics.dll System.Runtime.Serialization.dll System.Runtime.Serialization.Formatters.dll System.Runtime.Serialization.Json.dll System.Runtime.Serialization.Primitives.dll System.Runtime.Serialization.Xml.dll System.Security.AccessControl.dll System.Security.Claims.dll System.Security.Cryptography.Algorithms.dll System.Security.Cryptography.Cng.dll System.Security.Cryptography.Csp.dll System.Security.Cryptography.dll System.Security.Cryptography.Encoding.dll System.Security.Cryptography.OpenSsl.dll System.Security.Cryptography.Pkcs.dll System.Security.Cryptography.Primitives.dll System.Security.Cryptography.X509Certificates.dll System.Security.dll System.Security.Principal.dll System.Security.Principal.Windows.dll System.Security.SecureString.dll System.ServiceModel.Web.dll System.ServiceProcess.dll System.Text.Encoding.CodePages.dll System.Text.Encoding.dll System.Text.Encoding.Extensions.dll System.Text.Encodings.Web.dll System.Text.Json.dll System.Text.RegularExpressions.dll System.Threading.Channels.dll System.Threading.dll System.Threading.Overlapped.dll System.Threading.Tasks.Dataflow.dll System.Threading.Tasks.dll System.Threading.Tasks.Extensions.dll System.Threading.Tasks.Parallel.dll System.Threading.Thread.dll System.Threading.ThreadPool.dll System.Threading.Timer.dll System.Transactions.dll System.Transactions.Local.dll System.ValueTuple.dll System.Web.dll System.Web.HttpUtility.dll System.Windows.dll System.Xml.dll System.Xml.Linq.dll System.Xml.ReaderWriter.dll System.Xml.Serialization.dll System.Xml.XDocument.dll System.Xml.XmlDocument.dll System.Xml.XmlSerializer.dll System.Xml.XPath.dll System.Xml.XPath.XDocument.dll System.Xml.XPath.XmlDocument.dll WindowsBase.dll
我对此感到担忧,因为下一步要为新应用制作安装程序,而安装程序应仅包含实际所需的文件。
内容的提问来源于stack exchange,提问作者Peter M

