通过Windows Power Shell发布ASP .NET Core应用

时间:2018-07-08 20:52:32

标签: asp.net powershell asp.net-core

如何通过Windows Power Shell正确发布ASP .NET Core应用程序?

Write-Host ==== START PUBLISHING APP ==== -ForegroundColor Red
$msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
$options = "/p:DeployOnBuild=true /p:PublishProfile='FolderProfile'"
$apiproj = $BackEndPath + "\DCMT.WebApi.csproj"

# Publish the WebApi to Server...
$build = $msbuild + " $apiproj " + $options
Invoke-Expression $build

执行该命令给我一个错误

error MSB4040: No target element in the project.

1 个答案:

答案 0 :(得分:0)

# Publish the WebApi to Server...
$pathToCompile = "C:\DCMT\DCMT-INTERNS-SOURCE\DCMT-BackEnd\DCMT.WebApi\DCMT.WebApi\DCMT.WebApi.csproj"
dotnet publish $pathToCompile /p:PublishDir="C:\DCMT\DCMT-INTERNS"

我将命令更改为如下所示,并且可以正常工作! :D