.NET Core CLI构建Console应用程序
- 在应用程序的目录下, 用
dotnet build, 此命令包括 Restore NuGet 包
- 编译结果在
bin/debug/[netcore2.0|net47]文件夹
- 对于
.netcore而言,是一个DLL, 它有一个对System.Console程序集的依赖项
- 对于
.net 4.7而言,是一个EXE,它在mscorlib程序集中找到Console类
- 构建release版本,要多加一个参数
--configuration Release(简写为-c Release)
- 使用的c#版本:
- 默认情况下,使用编译器的最新主版本 c#7.0
- 需要启用新版本的c#时,需要在
csproj文件中指定
- 使用的框架:
- 如果
csproj面向多个框架,需要通过--framework参数告诉dotnet run使用哪个框架来运行程序
- 这个框架必须提前在
csproj中配置过
- 在生产环境下,不用
dotnet run运行应用程序,而可以使用dotnet 加上库名称
dotnet build
dotnet build --configuration Release
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
dotnet run
dotnet run --framework netcoreapp2.0
dotnet bin/debug/netcoreapp2.0/HelloWorld.dll