在Linux上使用Visual Studio进行ASP.NET开发的推荐配置
随着.NET Core的发布,ASP.NET开发已经不再局限于Windows平台,现在,我们可以在Linux上使用Visual Studio进行ASP.NET开发,本文将介绍在Linux上使用Visual Studio进行ASP.NET开发的推荐配置。
安装Linux系统
我们需要在计算机上安装一个Linux发行版,推荐的发行版有:Ubuntu、Debian、Fedora等,这些发行版都有详细的安装教程,可以在网上找到。
安装.NET Core SDK
1、打开终端,输入以下命令下载.NET Core SDK安装包:
wget https://packages.microsoft.com/config/ubuntu/18.04/packagesmicrosoftprod.deb O packagesmicrosoftprod.deb
2、安装下载好的安装包:
sudo dpkg i packagesmicrosoftprod.deb
3、更新软件包列表:
sudo aptget update
4、安装.NET Core SDK:
sudo aptget install y apttransporthttps && sudo aptget update && sudo aptget install y dotnetsdk3.1
安装Visual Studio Code
1、访问Visual Studio Code官网(https://code.visualstudio.com/)下载适用于Linux的安装包。
2、解压下载好的安装包:
tar xvf code_*.tar.gz
3、进入解压后的目录:
cd code*
4、添加可执行权限:
chmod +x code
5、运行Visual Studio Code:
./code
安装C#插件和ASP.NET Core插件
1、打开Visual Studio Code,点击左侧的扩展图标,搜索“C#”,找到“C# by Microsoft”插件,点击安装。
2、同样的方式,搜索“ASP.NET Core”,找到“ASP.NET Core C# Snippets”插件,点击安装。
创建ASP.NET Core项目
1、打开终端,输入以下命令创建一个新的ASP.NET Core项目:
dotnet new webapp o MyWebApp runtime ubuntu.18.04x64 norestore u Microsoft.AspNetCore.Mvc.RazorPages::VERSION=3.1.0 force framework netcoreapp3.1 output MyWebAppProjectFolderName name MyWebAppProjectName content "Pages/Index.html" "Pages/About.html" "Pages/Contact.html" "Pages/Error.html" "Pages/Shared/_Layout.cshtml" "Pages/Shared/_ViewImports.cshtml" "Pages/Shared/_ValidationScriptsPartial.cshtml" "Pages/Shared/_ViewStart.cshtml" "wwwroot/css" "wwwroot/js" "wwwroot/lib" "wwwroot/images" "wwwroot/favicon.ico" nugetpackageid Microsoft.AspNetCore.StaticFiles nugetpackageversion 3.1.0 uselaunchprofile true norestore v m p wwwroot n MyWebAppProjectName d "/Pages/MyWebAppProjectFolderName" f netcoreapp3.1 c Release o MyWebAppProjectFolderName force u Microsoft.AspNetCore.Mvc.RazorPages::VERSION=3.1.0 force framework netcoreapp3.1 output MyWebAppProjectFolderName name MyWebAppProjectName content "Pages/Index.html" "Pages/About.html" "Pages/Contact.html" "Pages/Error.html" "Pages/Shared/_Layout.cshtml" "Pages/Shared/_ViewImports.cshtml" "Pages/Shared/_ValidationScriptsPartial.cshtml" "Pages/Shared/_ViewStart.cshtml" "wwwroot/css" "wwwroot/js" "wwwroot/lib" "wwwroot/images" "wwwroot/favicon.ico" nugetpackageid Microsoft.AspNetCore.StaticFiles nugetpackageversion 3.1.0 uselaunchprofile true norestore v m p wwwroot n MyWebAppProjectName d "/Pages/MyWebAppProjectFolderName" f netcoreapp3.1 c Release o MyWebAppProjectFolderName force u Microsoft.AspNetCore.Mvc.RazorPages::VERSION=3.1.0 force framework netcoreapp3.1 output MyWebAppProjectFolderName name MyWebAppProjectName content "Pages/Index.html" "Pages/About.html" "Pages/Contact.html" "Pages/Error.html" "Pages/Shared/_Layout.cshtml" "Pages/Shared/_ViewImports.cshtml" "Pages/Shared/_ValidationScriptsPartial.cshtml" "Pages/Shared/_ViewStart.cshtml" "wwwroot/css" "wwwroot/js" "wwwroot/lib" "wwwroot/images" "wwwroot/favicon.ico" nugetpackageid Microsoft.AspNetCore.StaticFiles nugetpackageversion 3.1.0 uselaunchprofile true norestore v m p wwwroot n MyWebAppProjectName d "/Pages/MyWebAppProjectFolderName" f netcoreapp3.1 c Release o MyWebAppProjectFolderName force u Microsoft.AspNetCore.Mvc.RazorPages::VERSION=3.1.0 force framework netcoreapp3.1 output MyWebAppProjectFolderName name MyWebAppProjectName content "Pages/Index.html" "Pages/About.html" "Pages/Contact.html" "Pages/Error.html" "Pages/Shared/_Layout.cshtml" "Pages/Shared/_ViewImports
最新评论
本站CDN与莫名CDN同款、亚太CDN、速度还不错,值得推荐。
感谢推荐我们公司产品、有什么活动会第一时间公布!
我在用这类站群服务器、还可以. 用很多年了。