Skip to content

Instantly share code, notes, and snippets.

@meyu
Last active January 29, 2022 11:26
Show Gist options
  • Save meyu/58ded3cbb663b183629d91aa3071a866 to your computer and use it in GitHub Desktop.
Save meyu/58ded3cbb663b183629d91aa3071a866 to your computer and use it in GitHub Desktop.

安裝作業工具 (若需要)

安裝 Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝 Visual Studio Code

brew install visual-studio-code

安裝 Git

brew install git

安裝及設定 .NET Core 開發環境

安裝 .NET Core SDK

brew cask install dotnet-sdk

安裝相關套件

dotnet tool install -g dotnet-ef &&
dotnet tool install -g dotnet-t4 &&
dotnet tool install -g dotnet-serve &&
dotnet tool install -g dotnet-format &&
dotnet tool install -g dotnet-search &&
dotnet tool install -g dotnet-sql-cache &&
dotnet tool install -g dotnet-aspnet-codegenerator &&
dotnet tool install -g EntityFrameworkCore.Generator &&
dotnet tool install -g Microsoft.Web.LibraryManager.CLI &&
dotnet new -i Microsoft.AspNetCore.SpaTemplates::* 
code --install-extension doggy8088.netcore-extension-pack
code --install-extension ms-azuretools.vscode-docker

設定環境

dotnet dev-certs https --clean && 
dotnet dev-certs https --trust &&
dotnet dev-certs https --check

優化 .NET Core CLI 操作

  • 開啟或製作 Bash 設定檔
    code ~/.bash_profile
  • 複製以下內容至設定檔內
    # bash parameter completion for the dotnet CLI
    _dotnet_bash_complete()
    {
      local word=${COMP_WORDS[COMP_CWORD]}
      local completions
      completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
      if [ $? -ne 0 ]; then
        completions=""
      fi
      COMPREPLY=( $(compgen -W "$completions" -- "$word") )
    }
    complete -f -F _dotnet_bash_complete dotnet

升級及設定 .NET Core 開發環境

檢查

dotnet new --update-check

升級

brew cask install dotnet-sdk &&
dotnet new --update-apply &&
dotnet tool update --global dotnet-ef &&
dotnet tool update --global dotnet-t4 &&
dotnet tool update --global dotnet-serve &&
dotnet tool update --global dotnet-format &&
dotnet tool update --global dotnet-search &&
dotnet tool update --global dotnet-sql-cache &&
dotnet tool update --global dotnet-aspnet-codegenerator &&
dotnet tool update --global EntityFrameworkCore.Generator &&
dotnet tool update --global Microsoft.Web.LibraryManager.CLI

參考資源

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment