问题描述
限时送ChatGPT账号..我已经在 Mac 上使用 dnu build
命令构建了我的控制台应用程序.输出为 MyApp.dll
.
I've build my console application using dnu build
command on my Mac. The output is MyApp.dll
.
由于它不是 MyApp.exe
,我如何在 Windows 甚至 Mac 上执行它?
As it is not MyApp.exe
, how can I execute it on windows, or even on Mac?
代码是:
using System;
class Program
{
public static void Main()
{
Console.WriteLine("Hello from Mac");
}
}
推荐答案
将此添加到您的 project.json 文件中:
Add this to your project.json file:
"compilationOptions": {
"emitEntryPoint": true
},
它将在 Windows 上生成 MyApp.exe(在 bin/Debug 中)或其他平台上的可执行文件.
It will generate the MyApp.exe on Windows (in bin/Debug) or the executable files on other platforms.
30/01/2017
这已经不够了.您现在可以按照 这里.
It is not enough anymore. You now have the possibility between Framework-dependent deployment and Self-contained deployment as described here.
简称:
依赖于框架的部署( core 存在于目标系统上)
Framework-dependent deployment ( core is present on the target system)
使用 dotnet 命令行实用程序运行 dlldotnet MyApp.dll
自包含部署(包括 core运行时在内的所有组件都包含在应用程序中)
Self-contained deployment (all components including core runtime are included in application)
从 project.json 中删除"type": "platform"
将运行时部分添加到 project.json 使用目标操作系统构建dotnet build -r win7-x64
运行生成的MyApp.exe
project.json 文件:
project.json file:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1"
}
}
}
},
"imports": "dnxcore50",
"runtimes": { "win7-x64": {} }
}
这篇关于如何运行.Net Core dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论