当我使用 .NET Core 3.1 sdk 构建我的 .NET Core 控制台应用程序时,它会同时生成 .exe 和 .dll 作为输出。当我使用 .NET Core 2.1 时,它只生成 .dll 作为输出。有没有办法限制 .NET Core 3.1 sdk 只生成 .dll 作为输出?
最佳答案
您可以使用 UseAppHost
来控制它MSBuild 设置:
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>
如果您想在从命令行构建时禁用它,而不是在 .csproj 中设置它,请将属性作为参数传递。例如:
dotnet build /p:UseAppHost=false
关于c# - 有没有办法限制 .NET Core 项目在使用 .NET Core 3.1 sdk 时只生成 .dll 作为输出文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61612362/