内容简介:PowerShell和Bash的介绍
PowerShell是运行在windows平台的脚本,而Bash是运行在 linux 平台的脚本
现在bash能做的事情,PowerShell也能做,PowerShell的强大之处是它可以管理windows服务器(特别是域domain),现在的开源PowerShell 也可以管理Linux和Mac(通过PSRP)。
下面是在 eShopOnContainers 上的一个例子,分别用ps和bash实现了程序的部署
#!/bin/bash declare -a projectList=( '../src/Services/Catalog/Catalog.API' '../src/Services/Basket/Basket.API' '../src/Services/Ordering/Ordering.API' '../src/Services/Identity/Identity.API' '../src/Web/WebMVC' '../src/Web/WebSPA' '../src/Web/WebStatus' ) # Build SPA app # pushd $(pwd)../src/Web/WebSPA # npm run build:prod for project in "${projectList[@]}" do echo -e "\e[33mWorking on $(pwd)/$project" echo -e "\e[33m\tRemoving old publish output" pushd $(pwd)/$project rm -rf obj/Docker/publish echo -e "\e[33m\tRestoring project" dotnet restore echo -e "\e[33m\tBuilding and publishing projects" dotnet publish -o obj/Docker/publish popd done # remove old docker images: images=$(docker images --filter=reference="eshop/*" -q) if [ -n "$images" ]; then docker rm $(docker ps -a -q) -f echo "Deleting eShop images in local Docker repo" echo $images docker rmi $(docker images --filter=reference="eshop/*" -q) -f fi # No need to build the images, docker build or docker compose will # do that using the images and containers defined in the docker-compose.yml file.
powershell代码如下
Param([string] $rootPath) $scriptPath = Split-Path $script:MyInvocation.MyCommand.Path Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow if ([string]::IsNullOrEmpty($rootPath)) { $rootPath = "$scriptPath\.." } Write-Host "Root path used is $rootPath" -ForegroundColor Yellow $projectPaths = @{Path="$rootPath\src\Web\WebMVC";Prj="WebMVC.csproj"}, @{Path="$rootPath\src\Web\WebSPA";Prj="WebSPA.csproj"}, @{Path="$rootPath\src\Services\Identity\Identity.API";Prj="Identity.API.csproj"}, @{Path="$rootPath\src\Services\Catalog\Catalog.API";Prj="Catalog.API.csproj"}, @{Path="$rootPath\src\Services\Ordering\Ordering.API";Prj="Ordering.API.csproj"}, @{Path="$rootPath\src\Services\Basket\Basket.API";Prj="Basket.API.csproj"} @{Path="$rootPath\src\Web\WebStatus";Prj="WebStatus.csproj"} $projectPaths | foreach { $projectPath = $_.Path $projectFile = $_.Prj $outPath = $_.Path + "\obj\Docker\publish" $projectPathAndFile = "$projectPath\$projectFile" Write-Host "Deleting old publish files in $outPath" -ForegroundColor Yellow remove-item -path $outPath -Force -Recurse -ErrorAction SilentlyContinue Write-Host "Publishing $projectPathAndFile to $outPath" -ForegroundColor Yellow dotnet restore $projectPathAndFile dotnet build $projectPathAndFile dotnet publish $projectPathAndFile -o $outPath } ######################################################################################## # Delete old eShop Docker images ######################################################################################## $imagesToDelete = docker images --filter=reference="eshop/*" -q If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."} Else { # Delete all containers Write-Host "Deleting all containers in local Docker Host" docker rm $(docker ps -a -q) -f # Delete all eshop images Write-Host "Deleting eShop images in local Docker repo" Write-Host $imagesToDelete docker rmi $(docker images --filter=reference="eshop/*" -q) -f } # WE DON'T NEED DOCKER BUILD AS WE CAN RUN "DOCKER-COMPOSE BUILD" OR "DOCKER-COMPOSE UP" AND IT WILL BUILD ALL THE IMAGES IN THE .YML FOR US
自己感觉,这两个东西在以后的程序部署上都会发挥各自强大的力量!
以上所述就是小编给大家介绍的《PowerShell和Bash的介绍》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- ASP.NET Core模块化前后端分离快速开发框架介绍之3、数据访问模块介绍
- 简编漫画介绍WebAssembly
- CGroup 介绍
- CGroup 介绍
- vue初步介绍
- Microbit MicroPython 介绍
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
网络机器人Java编程指南
美 Heaton J. / 电子工业出版社 / 2002-7 / 44.00元
这是一本研究如何实现具有Web访问能力的网络机器人的书。该书从Internet编程的基本原理出发,深入浅出、循序渐进地阐述了网络机器人程序Spider、Bot、Aggregator的实现技术,并分析了每种程序的优点及适用场合。本书提供了大量的有效源代码,并对这些代码进行了详细的分析。通过本书的介绍,你可以很方便地利用这些技术,设计并实现网络蜘蛛或网络信息搜索器等机器人程序。 适合于具有一起来看看 《网络机器人Java编程指南》 这本书的介绍吧!