银河麒麟高级服务器操作系统V10使用.NET Core3.1 SDK创建C# webApp


白开水风趣
白开水风趣 2022-09-29 09:28:44 51800
分类专栏: 资讯

前言

1. 查看版本及安装路径

2. 查看支持的模板

二、创建webapp

1. 创建源码目录

2. 创建一个基于ASP.NET Core Web App模板的web应用

3. 进入myWebApp目录,查看生成的文件结构

4. 编译并运行webapp

5. 本地使用麒麟自带的火狐浏览器访问 http://localhost:5000

总结


 


前言

.NET Core3.1安装参考:

银河麒麟高级服务器操作系统V10上安装.NET Core3.1


一、dotnet信息查看

1. 查看版本及安装路径

指令如下:

  1. $ dotnet --info
  2. .-property">NET Core -variable constant_">SDK (reflecting any -variable language_">global.-property">json):
  3. Version: 3.1.402
  4. Commit: 9b5de826fd
  5. Runtime Environment:
  6. -variable constant_">OS Name: kylin
  7. -variable constant_">OS Version: -variable constant_">V10
  8. -variable constant_">OS Platform: Linux
  9. RID: linux-arm64
  10. Base Path: -regexp">/home/greatwall/dotnet/sdk/3.1.402/
  11. Host (useful for support):
  12. Version: 3.1.8
  13. Commit: 9c1330dedd
  14. .-property">NET Core SDKs installed:
  15. 3.1.402 [-regexp">/home/greatwall/dotnet/sdk]
  16. .-property">NET Core runtimes installed:
  17. Microsoft.-property">AspNetCore.-property">App 3.1.8 [-regexp">/home/greatwall/dotnet/shared/Microsoft.-property">AspNetCore.-property">App]
  18. Microsoft.-property">NETCore.-property">App 3.1.8 [-regexp">/home/greatwall/dotnet/shared/Microsoft.-property">NETCore.-property">App]
  19. To install additional .-property">NET Core runtimes or SDKs:
  20. https://aka.ms/dotnet-download

2. 查看支持的模板

  1. $ dotnet new -operator">-l
  2. Usage: new [options]
  3. Options:
  4. -operator">-h, --help Displays help for this command.
  5. -operator">-l, --list Lists templates containing the specified name. If no name is specified, lists all templates.
  6. -operator">-n, --name The name for the output being created. If no name is specified, the name of the current directory is used.
  7. -operator">-o, --output Location to place the generated output.
  8. -operator">-i, --install Installs a source or a template pack.
  9. -operator">-u, --uninstall Uninstalls a source or a template pack.
  10. --nuget-source Specifies a NuGet source to use during install.
  11. --type Filters templates based on available types. Predefined values are "project", "item" or "other".
  12. --dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
  13. --force Forces content to be generated even if it would change existing files.
  14. -operator">-lang, --language Filters templates based on language and specifies the language of the template to create.
  15. --update-check Check the currently installed template packs for updates.
  16. --update-apply Check the currently installed template packs for update, and install the updates.
  17. Templates Short Name Language Tags
  18. ----------------------------------------------------------------------------------------------------------------------------------
  19. Console Application console [C], F, VB Common-operator">/Console
  20. Class library classlib [C], F, VB Common-operator">/Library
  21. WPF Application wpf [C] Common-operator">/WPF
  22. WPF Class library wpflib [C] Common-operator">/WPF
  23. WPF Custom Control Library wpfcustomcontrollib [C] Common-operator">/WPF
  24. WPF User Control Library wpfusercontrollib [C] Common-operator">/WPF
  25. Windows Forms (WinForms) Application winforms [C] Common-operator">/WinForms
  26. Windows Forms (WinForms) Class library winformslib [C] Common-operator">/WinForms
  27. Worker Service worker [C] Common-operator">/Worker-operator">/Web
  28. Unit Test Project mstest [C], F, VB Test-operator">/MSTest
  29. NUnit 3 Test Project nunit [C], F, VB Test-operator">/NUnit
  30. NUnit 3 Test Item nunit-operator">-test [C], F, VB Test-operator">/NUnit
  31. xUnit Test Project xunit [C], F, VB Test-operator">/xUnit
  32. Razor Component razorcomponent [C] Web-operator">/ASP.NET
  33. Razor Page page [C] Web-operator">/ASP.NET
  34. MVC ViewImports viewimports [C] Web-operator">/ASP.NET
  35. MVC ViewStart viewstart [C] Web-operator">/ASP.NET
  36. Blazor Server App blazorserver [C] Web-operator">/Blazor
  37. Blazor WebAssembly App blazorwasm [C] Web-operator">/Blazor-operator">/WebAssembly
  38. ASP.NET Core Empty web [C], F Web-operator">/Empty
  39. ASP.NET Core Web App (Model-operator">-View-operator">-Controller) mvc [C], F Web-operator">/MVC
  40. ASP.NET Core Web App webapp [C] Web-operator">/MVC-operator">/Razor Pages
  41. ASP.NET Core with Angular angular [C] Web-operator">/MVC-operator">/SPA
  42. ASP.NET Core with React.js react [C] Web-operator">/MVC-operator">/SPA
  43. ASP.NET Core with React.js and Redux reactredux [C] Web-operator">/MVC-operator">/SPA
  44. Razor Class Library razorclasslib [C] Web-operator">/Razor-operator">/Library-operator">/Razor Class Library
  45. ASP.NET Core Web API webapi [C], F Web-operator">/WebAPI
  46. ASP.NET Core gRPC Service grpc [C] Web-operator">/gRPC
  47. dotnet gitignore file gitignore Config
  48. global.json file globaljson Config
  49. NuGet Config nugetconfig Config
  50. Dotnet local tool manifest file tool-operator">-manifest Config
  51. Web Config webconfig Config
  52. Solution File sln Solution
  53. Protocol Buffer File proto Web-operator">/gRPC

二、创建webapp

1. 创建源码目录

  1. $ mkdir code/dotnet -p
  2. $ cd code/dotnet/

2. 创建一个基于ASP.NET Core Web App模板的web应用

指令如下:

  1. $ dotnet new webapp -o myWebApp --no-https
  2. The template "ASP.NET Core Web App" was created successfully.
  3. This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/3.1-third-party-notices for details.
  4. Processing post-creation actions...
  5. Running 'dotnet restore' on myWebApp/myWebApp.csproj...
  6. Determining projects to restore...
  7. Restored /home/greatwall/code/dotnet/myWebApp/myWebApp.csproj (in 398 ms).
  8. Restore succeeded.

3. 进入myWebApp目录,查看生成的文件结构

  1. $ cd myWebApp/
  2. $ find
  3. .
  4. ./appsettings.Development.json
  5. ./appsettings.json
  6. ./myWebApp.csproj
  7. ./Program.cs
  8. ./Startup.cs
  9. ./Pages
  10. .-regexp">/Pages/Error.cshtml
  11. .-regexp">/Pages/Error.cshtml.cs
  12. .-regexp">/Pages/Index.cshtml
  13. .-regexp">/Pages/Index.cshtml.cs
  14. .-regexp">/Pages/Privacy.cshtml
  15. .-regexp">/Pages/Privacy.cshtml.cs
  16. .-regexp">/Pages/_ViewImports.cshtml
  17. .-regexp">/Pages/_ViewStart.cshtml
  18. .-regexp">/Pages/Shared
  19. .-regexp">/Pages/Shared/_Layout.cshtml
  20. .-regexp">/Pages/Shared/_ValidationScriptsPartial.cshtml
  21. ./Properties
  22. .-regexp">/Properties/launchSettings.json
  23. ./wwwroot
  24. .-regexp">/wwwroot/favicon.ico
  25. .-regexp">/wwwroot/css
  26. .-regexp">/wwwroot/css/site.css
  27. .-regexp">/wwwroot/js
  28. .-regexp">/wwwroot/js/site.js
  29. .-regexp">/wwwroot/lib
  30. .-regexp">/wwwroot/lib/bootstrap
  31. .-regexp">/wwwroot/lib-regexp">/bootstrap/LICENSE
  32. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist
  33. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist/css
  34. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-grid.css
  35. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-grid.css.map
  36. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-grid.min.css
  37. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-grid.min.css.map
  38. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-reboot.css
  39. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-reboot.css.map
  40. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-reboot.min.css
  41. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap-reboot.min.css.map
  42. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap.css
  43. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap.css.map
  44. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap.min.css
  45. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/css/bootstrap.min.css.map
  46. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist/js
  47. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.bundle.js
  48. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.bundle.js.map
  49. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.bundle.min.js
  50. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.bundle.min.js.map
  51. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.js
  52. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.js.map
  53. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.min.js
  54. .-regexp">/wwwroot/lib-regexp">/bootstrap/dist-regexp">/js/bootstrap.min.js.map
  55. .-regexp">/wwwroot/lib/jquery
  56. .-regexp">/wwwroot/lib-regexp">/jquery/LICENSE.txt
  57. .-regexp">/wwwroot/lib-regexp">/jquery/dist
  58. .-regexp">/wwwroot/lib-regexp">/jquery/dist/jquery.js
  59. .-regexp">/wwwroot/lib-regexp">/jquery/dist/jquery.min.js
  60. .-regexp">/wwwroot/lib-regexp">/jquery/dist/jquery.min.map
  61. .-regexp">/wwwroot/lib/jquery-validation
  62. .-regexp">/wwwroot/lib-regexp">/jquery-validation/LICENSE.md
  63. .-regexp">/wwwroot/lib-regexp">/jquery-validation/dist
  64. .-regexp">/wwwroot/lib-regexp">/jquery-validation/dist/additional-methods.js
  65. .-regexp">/wwwroot/lib-regexp">/jquery-validation/dist/additional-methods.min.js
  66. .-regexp">/wwwroot/lib-regexp">/jquery-validation/dist/jquery.validate.js
  67. .-regexp">/wwwroot/lib-regexp">/jquery-validation/dist/jquery.validate.min.js
  68. .-regexp">/wwwroot/lib/jquery-validation-unobtrusive
  69. .-regexp">/wwwroot/lib-regexp">/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js
  70. .-regexp">/wwwroot/lib-regexp">/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js
  71. .-regexp">/wwwroot/lib-regexp">/jquery-validation-unobtrusive/LICENSE.txt
  72. ./obj
  73. .-regexp">/obj/myWebApp.csproj.nuget.g.props
  74. .-regexp">/obj/myWebApp.csproj.nuget.g.targets
  75. .-regexp">/obj/project.assets.json
  76. .-regexp">/obj/project.nuget.cache
  77. .-regexp">/obj/myWebApp.csproj.nuget.dgspec.json

4. 编译并运行webapp

  1. -variable">$ dotnet run
  2. warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
  3. No XML encryptor configured. Key {ab9f0472-2b78-4463-af8b-ea648e992f0e} may be persisted to storage in unencrypted form.
  4. info: Microsoft.Hosting.Lifetime[0]
  5. Now listening on: http:/-regexp">-regexp">/localhost:5000
  6. -regexp">info: Microsoft.Hosting.Lifetime[0]
  7. -regexp"> Application started. Press Ctrl+C to shut down.
  8. -regexp">info: Microsoft.Hosting.Lifetime[0]
  9. -regexp"> Hosting environment: Development
  10. -regexp">info: Microsoft.Hosting.Lifetime[0]
  11. -regexp"> Content root path: /home-regexp">/greatwall/code-regexp">/dotnet/myWebApp

5. 本地使用麒麟自带的火狐浏览器访问 http://localhost:5000

 


总结

银河麒麟V10上,.NET Core指令操作与Windows平台相同,运行效果没有太大差异

网站声明:如果转载,请联系本站管理员。否则一切后果自行承担。

本文链接:https://www.xckfsq.com/news/show.html?id=10687
赞同 0
评论 0 条
白开水风趣L1
粉丝 0 发表 11 + 关注 私信
上周热门
如何使用 StarRocks 管理和优化数据湖中的数据?  2672
【软件正版化】软件正版化工作要点  2637
统信UOS试玩黑神话:悟空  2532
信刻光盘安全隔离与信息交换系统  2216
镜舟科技与中启乘数科技达成战略合作,共筑数据服务新生态  1092
grub引导程序无法找到指定设备和分区  743
WPS City Talk · 校招西安站来了!  15
金山办公2024算法挑战赛 | 报名截止日期更新  15
看到某国的寻呼机炸了,就问你用某水果手机发抖不?  14
有在找工作的IT人吗?  13
本周热议
我的信创开放社区兼职赚钱历程 40
今天你签到了吗? 27
信创开放社区邀请他人注册的具体步骤如下 15
如何玩转信创开放社区—从小白进阶到专家 15
方德桌面操作系统 14
我有15积分有什么用? 13
用抖音玩法闯信创开放社区——用平台宣传企业产品服务 13
如何让你先人一步获得悬赏问题信息?(创作者必看) 12
2024中国信创产业发展大会暨中国信息科技创新与应用博览会 9
中央国家机关政府采购中心:应当将CPU、操作系统符合安全可靠测评要求纳入采购需求 8

加入交流群

请使用微信扫一扫!