基于.net core 2.2建立的项目。希望发布单个EXE文件。无法发布为单个EXE文件。
我在程序包控制台中尝试了以下命令
dotnet发布-r win-x64 -c版本/ p:PublishSingleFile = true
Restore completed in 995.93 ms for C:\Demo\New
folder\BHHS\Importer\Importer.csproj.
You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
Importer -> C:\Demo\New folder\BHHS\Importer\bin\Release\netcoreapp2.2\win-x64\Importer.dll
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: The "GenerateBundle" task failed unexpectedly.[C:\Demo\New
folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-
013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018:
Microsoft.NET.HostModel.AppHost.PlaceHolderNotFoundInAppHostException:
Exception of type
'Microsoft.NET.HostModel.AppHost.PlaceHolderNotFoundInAppHostException'
was thrown. [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.NET.HostModel.AppHost.BinaryUtils.SearchAndReplace(MemoryMappedViewAccessor accessor, Byte[] searchPattern, Byte[] patternToReplace, Boolean pad0s) [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.NET.HostModel.AppHost.BinaryUtils.SearchAndReplace(String filePath, Byte[] searchPattern, Byte[] patternToReplace, Boolean pad0s) [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.NET.HostModel.AppHost.HostWriter.SetAsBundle(String appHostPath, Int64 bundleHeaderOffset) [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs) [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() in /_/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs:line 36 [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() in /_/src/Tasks/Common/TaskBase.cs:line 38 [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(807,5):
error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\Demo\New folder\BHHS\Importer\Importer.csproj]
答案 0 :(得分:3)
不。仅从.NET Core 3.0起,这是可能的。在此处查看详细信息-https://devblogs.microsoft.com/dotnet/announcing-net-core-3-0-preview-5/
Scott Hanselman也有与此相关的博文-https://www.hanselman.com/blog/MakingATinyNETCore30EntirelySelfcontainedSingleExecutable.aspx