更新时间:2023-02-19 19:30:40
出于调试目的,您可以可以使用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).
仅限Pre-.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