DotNetCore cross-platform ~ Design of release script PowerShell,

Source: Internet
Author: User

DotNetCore cross-platform ~ Design of release script PowerShell,

These days, I have a strong liking for PS, and I hope it will be inspired by its powerful functions. It can be quickly deployed and released, and some associated actions can be completed at a time, which is very convenient, similar to the early bat files and bash scripts on the linux platform, the functions are much stronger than those of the previous two, next, let's take a look at the publish process for all projects in a solution, which we implemented using the ps script.

# Author: warehouse uncle # function: release a project to a specified location. Param ([string] $ rootPath) $ scriptPath = Split-Path $ script: MyInvocation. myCommand. pathWrite-Host "Current script directory is $ scriptPath"-ForegroundColor Yellowif ([string]: IsNullOrEmpty ($ rootPath) {$ rootPath = "$ scriptPath \.. "} Write-Host" Root path used is $ rootPath "-ForegroundColor Yellow $ projectPaths =@{ Path =" $ rootPath \ src \ lincore. manager "; Prj =" lincore. manager. csproj "; Name =" web "}, @ {Path =" $ rootPath \ src \ lincore. test "; Prj =" lincore. test. csproj "; Name =" console "} $ projectPaths | foreach {$ projectPath =$ _. path $ projectFile =$ _. prj $ name = $ _. name # $ outPath = $ _. path + "\ obj \ publish" $ outPath = "d: \ publish \ "+ $ name $ projectPathAndFile =" $ projectPath \ $ projectFile "Write-Host" Deleting old publish files in $ outPath "-ForegroundColor Yellow remove-item-path $ outPath- force-Recurse-ErrorAction SilentlyContinue Write-Host "Publishing $ projectPath to $ outPath"-export Yellow dotnet restore $ projectPathAndFile dotnet build $ projectPath dotnet publish $ projectPath-o $ outPath}

Note: If you only send cross-platform projects to the obj \ publish folder, The wwwroot folder will not be generated, and the static files will be generated if it is sent to other disks!

For cross-platform projects, you need to add the runtime in project. json. Otherwise, your project can be run on the current platform.

  "runtimes": {    "win7-x64": {},    "linux-x64": {},    "osx-x64": {}  },

Thank you for your support for. net core!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.