如何运行.Net Core dll?

编程入门 行业动态 更新时间:2024-10-11 23:18:58
本文介绍了如何运行.Net Core dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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 命令行实用程序运行 dll dotnet 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:关键词]

本文发布于:2023-04-14 16:47:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/847168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Net   Core   dll

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!