# 作者:仓储大叔# 功能:发布项目到指定的地方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\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": {} },
感谢各位对.net core的支持!
以上就是关于脚本PowerShell的设计实例的知识。速戳>>知识兔学习精品课!