分享下 publish-win-x64.ps1 文件,publish后直接启动。
dotnet publish -r win-x64 –no-self-contained –no-dependencies -c Release
$timestamp = Get-Date -Format “yyyyMMddHHmmss”
$path = “.\Publish\win-x64-$timestamp”
Remove-Item $path\Bin\ -Recurse -ErrorAction Ignore
Copy-Item .\Bin\win-x64\publish -Destination $path\Bin -Recurse -Force
Remove-Item $path\Config -Recurse -ErrorAction Ignore
Copy-Item .\Config -Destination $path\Config -Recurse -Force
# 启动应用程序
cd $path\Bin
dotnet App.dll –AppType Server –StartConfig “StartConfig/Localhost” –Process 1 –Develop 0 –LogLevel 0 –Console 0
# 等待用户输入以保持窗口打开
Read-Host -Prompt “Press Enter to exit”