长春个人网站制作,太原网络营销,公司汇报网站建设方案,网站建设付款页面一、MacOS
笔者笔记本电脑上安装的是macOS High Sierra(10.13)#xff0c;想要尝试一下新版本的.netcore#xff0c;之前系统是10.12时#xff0c;.netcore 3.1刚出来时安装过3.1版本#xff0c;很久没更新了#xff0c;最近.net8出来了#xff0c;想试一下#xff0c;…一、MacOS
笔者笔记本电脑上安装的是macOS High Sierra(10.13)想要尝试一下新版本的.netcore之前系统是10.12时.netcore 3.1刚出来时安装过3.1版本很久没更新了最近.net8出来了想试一下但是需要更新系统于是安装了.netcore7它的支持时间到2024年5月14日。
下载了.netcore7后直接双击安装即可。安装后的路径为/usr/local/share/dotnet
笔者VSCode的版本为1.85.1需要安装C#插件目前最新版本为2.14.8但macOS 10.13目前最高只能安装v1.26.0版本的C#插件不能安装更高的版本否则不能调试。 另外还需要安装一个.NET Install Tool插件 这样就可以在终端使用dotnet命令创建项目了比如创建一个控制台应用
$ dotnet new console
已成功创建模板“控制台应用”。正在处理创建后操作...
正在还原 /Users/witton/Projects/cc/cc.csproj:正在确定要还原的项目…已还原 /Users/witton/Projects/cc/cc.csproj (用时 120 ms)。
已成功还原。此时打开生成的Program.cs并打上断点切换到运行和调试工具栏执行Generate C# Assets for Build and Debug插件会自动生成launch.json和tasks.json两个文件 launch.json
{version: 0.2.0,configurations: [{// Use IntelliSense to find out which attributes exist for C# debugging// Use hover for the description of the existing attributes// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.mdname: .NET Core Launch (console),type: coreclr,request: launch,preLaunchTask: build,// If you have changed target frameworks, make sure to update the program path.program: ${workspaceFolder}/bin/Debug/net7.0/cc.dll,args: [],cwd: ${workspaceFolder},// For more information about the console field, see https://aka.ms/VSCode-CS-LaunchJson-Consoleconsole: internalConsole,stopAtEntry: false},{name: .NET Core Attach,type: coreclr,request: attach}]
}tasks.json:
{version: 2.0.0,tasks: [{label: build,command: dotnet,type: process,args: [build,${workspaceFolder}/cc.csproj,/property:GenerateFullPathstrue,/consoleloggerparameters:NoSummary],problemMatcher: $msCompile},{label: publish,command: dotnet,type: process,args: [publish,${workspaceFolder}/cc.csproj,/property:GenerateFullPathstrue,/consoleloggerparameters:NoSummary],problemMatcher: $msCompile},{label: watch,command: dotnet,type: process,args: [watch,run,--project,${workspaceFolder}/cc.csproj],problemMatcher: $msCompile}]
}此时按F5运行启动调试即可开始调试C#程序 微软开发了一个新的插件C# Dev Kit它提供了更加强大的功能并且可以像VS那样使用解决方案资源管理器来管理项目。该插件需要C#插件为2.0及以上版本但由于笔者的MacOS系统比较老了C#插件2.0及以上版本不能进行调试所以只能使用1.X来将就使用了。
如果是macOS 10.15及以上版本就可以直接安装.net8了VSCode插件也可以直接安装C# Dev Kit以及IntelliCode for C# Dev Kit插件了。但是由于.NET Install Tool插件目前仅支持7.x版本的.net所以还需要安装.net 7的runtime:runtime-7.0.14-macos-x64-installer
安装好后就可以使用F1调出.NET新建项目...命令来新建.net项目了 选择项目模板 比如选择控制台应用创建好项目后可以看到解决方案资源管理器 二、Windows
如果是Windows10则可以直接安装最新的.net 8并且安装上C# Dev Kit以及IntelliCode for C# Dev Kit也不需要像macOS那样还需要安装.net 7的runtime