使用.NET Core 3.1 sdk构建.NET Core Console应用程序时,它将生成.exe和.dll文件。但是,在使用.NET Core 2.1时,它只会生成.dll文件。有没有办法限制.NET Core 3.1 sdk仅生成.dll文件作为输出?
使用.NET Core 3.1 sdk构建.NET Core Console应用程序时,它将生成.exe和.dll文件。但是,在使用.NET Core 2.1时,它只会生成.dll文件。有没有办法限制.NET Core 3.1 sdk仅生成.dll文件作为输出?
UseAppHost
MSBuild 设置来控制此项:
如果您想在命令行构建时禁用此功能,而不是在 .csproj 中进行设置,请将该属性作为参数传递。例如:The
UseAppHost
property was introduced in the 2.1.400 version of the .NET Core SDK. It controls whether or not a native executable is created for a deployment. A native executable is required for self-contained deployments.In .NET Core 3.0 and later versions, a framework-dependent executable is created by default. Set the
UseAppHost
property tofalse
to disable generation of the executable.
<PropertyGroup> <UseAppHost>false</UseAppHost> </PropertyGroup>
dotnet build /p:UseAppHost=false
.dll
还是.exe
。为什么您要完全删除.exe
呢? - Panagiotis Kanavos
.dll
文件,所以自从 .NET Core 1.0 以来,人们一直在寻找那个.exe
。如果你想避免创建包含dotnet run mydll
调用的.cmd
文件,那么你 需要 它。那个.exe
只是一个引导程序,而不是真正的应用程序。 - Panagiotis Kanavos