compileOptions.emitEntryPoint是什么意思? [英] What does compilationOptions.emitEntryPoint mean?

查看:181
本文介绍了compileOptions.emitEntryPoint是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需安装rc1工具并创建一个新的Web项目即可查看模板中发生了什么变化.

Just installed the rc1 tools and created a new web project to see what has changed in the template.

我注意到project.json现在包含:

I noticed that project.json now contains:

"compilationOptions": {
    "emitEntryPoint": true
}

但是目前尚不清楚.

有人有主意吗?

推荐答案

如下所述:它似乎是编译器的一个标志,指示该项目是控制台应用程序还是库(即:控制台应用程序)必须包含public static void Main())

As mentioned below: It looks like it is a flag to the compiler to indicate that the project is a console application vs. a library (namely: a console application must contain public static void Main())

您可以从中查看来源.

在新的RC1默认Web应用程序模板中,您会注意到在Startup.cs的底部,有一个新的表达式合并方法用作入口点:

In the new RC1 default web application template, you'll notice at the bottom of Startup.cs there is a new expression bodied method that acts as the entry point:

public static void Main(string[] args) => WebApplication.Run<Startup>(args);

如果删除此方法,然后执行构建(dnu build),则会收到错误消息:

If you remove this method then perform a build (dnu build) you will get an error:

error CS5001: Program does not contain a static 'Main' method suitable for an entry point

但是,如果将emitEntryPoint标志更改为false并尝试再次构建,它将成功.这是因为它正在创建库而不是控制台应用程序.

However, if you change the emitEntryPoint flag to false and attempt to build again, it will succeed. This is because it is creating a library instead of a console app.

这篇关于compileOptions.emitEntryPoint是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆