更新时间:2023-02-19 19:12:54
出于调试目的,您可以使用 DLL 文件.您可以使用 dotnet ConsoleApp2.dll
运行它.如果你想生成一个EXE文件,你必须生成一个自包含的应用程序.
For debugging purposes, you can use the DLL file. You can run it using dotnet ConsoleApp2.dll
. If you want to generate an EXE file, you have to generate a self-contained application.
要生成自包含应用程序(Windows 中的 EXE),您必须指定目标运行时(特定于您的目标操作系统).
To generate a self-contained application (EXE in Windows), you must specify the target runtime (which is specific to the operating system you target).
仅限 .NET Core 2.0 之前:首先,在 .csproj 文件中添加目标运行时的运行时标识符(支持的 RID 列表):
Pre-.NET Core 2.0 only: First, add the runtime identifier of the target runtimes in the .csproj file (list of supported RIDs):
<PropertyGroup>
<RuntimeIdentifiers>win10-x64;ubuntu.16.10-x64</RuntimeIdentifiers>
</PropertyGroup>
从 .NET Core 2.0 开始不再需要上述步骤.
然后,在发布应用程序时设置所需的运行时:
Then, set the desired runtime when you publish your application:
dotnet publish -c Release -r win10-x64
dotnet publish -c Release -r ubuntu.16.10-x64