回到目录

立刻几乎天对PS情有独忠,被它们的强大作用所希引,它好长足布置,快速发布,将有有关的动作一样不行的成就,挺便宜,类似于前期的bat文件,也如linux平台的bash脚本,但功能及,比前双方都如高博,下面我们看一下拿某解决方案下之持有品种一律次于publish的过程,我们以ps脚本来实现之。

# 作者:仓储大叔
# 功能:发布项目到指定的地方
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\LindCore.Manager";Prj="LindCore.Manager.csproj";Name="web"},
    @{Path="$rootPath\src\LindCore.Test";Prj="LindCore.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" -ForegroundColor Yellow
    dotnet restore $projectPathAndFile
    dotnet build $projectPath
    dotnet publish $projectPath -o $outPath
}

只顾:如果你只是将过平台项目发到obj\publish文件夹的语句,那wwwroot这些文件夹不会见生成,而设犯到外磁盘,将见面转变这些静态的文书,这点而专注!

过平台项目,需要在project.json里把运行时都助长,否则你的类保能在脚下平台运行

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

感谢各位json对.net core的支持!

回到目录

相关文章

网站地图xml地图