2017-01-18 12 views
0

ASP.NET CoreアプリケーションのアーティファクトをAzure Web Serviceに展開するPowerShellスクリプトが必要です。私はそれにそれがスクリーンショットに示されている方法を使用していますASP.NET CoreアーティファクトをAzureに展開するためのPowerShellスクリプト

param($websiteName, $packOutput) 

$website = Get-AzureWebsite -Name $websiteName 

Stop-AzureWebsite -Name $websiteName 

# get the scm url to use with MSDeploy. By default this will be the second in the array 
$msdeployurl = $website.EnabledHostNames[1] 

$publishProperties = @{'WebPublishMethod'='MSDeploy'; 
         'MSDeployServiceUrl'=$msdeployurl; 
         'DeployIisAppPath'=$website.Name; 
         'Username'=$website.PublishingUsername; 
         'Password'=$website.PublishingPassword 
         } 

$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\1.2.0\default-publish.ps1" 

. $publishScript -publishProperties $publishProperties -packOutput $packOutput 

Start-AzureWebsite -Name $websiteName 

:インターネットを検索する私はこのスクリプトを見つけることができた enter image description here

しかし...何も場合msdeployコマンド実行の結果として起こりません。エラーは発生せず、データは展開されません。

PowerShellでASP.NET Core成果物を展開する正しい方法は何ですか?

答えて

0

Visual Studioは、Webサイトに展開するためのWindows PowerShellパブリッシュスクリプトを生成する可能性があります。公開スクリプトは次のようになります。

スクリプトを

[cmdletbinding(SupportsShouldProcess=$true)] 
param([email protected]{}, $packOutput, $pubProfilePath) 

# to learn more about this file visit https://go.microsoft.com/fwlink/?LinkId=524327 

try{ 
    if ($publishProperties['ProjectGuid'] -eq $null){ 
     $publishProperties['ProjectGuid'] = 'xxxxxxxx-0260-4800-b864-e9afa92d7fc2' 
    } 

    $publishModulePath = Join-Path (Split-Path $MyInvocation.MyCommand.Path) 'publish-module.psm1' 
    Import-Module $publishModulePath -DisableNameChecking -Force 

    # call Publish-AspNet to perform the publish operation 
    Publish-AspNet -publishProperties $publishProperties -packOutput $packOutput -pubProfilePath $pubProfilePath 
} 
catch{ 
    "An error occurred during publish.`n{0}" -f $_.Exception.Message | Write-Error 
} 

を公開し、スクリプトで使用される機能が含まれているモジュールを公開します。 Webサイトに展開するためのパブリッシュスクリプトの詳細については、this documentationを参照してください。

+1

私はVSがスクリプトを生成することを知っていますが、私はそれらを動作させることはできません。 VSスクリプト './DemoDeploy - Web Publish-publish.ps1 -packOutput" Webサイトの成果物へのパス "-pubProfilePath" VSによって生成されたプロファイルへのパス "で次のコマンドを試しました。結果は上のスクリーンショットとほぼ同じです。私は以前に提供されたリンクを見てきましたが、それも私を助けませんでした。私はjsonファイルが生成されていることを確認していませんが(ドキュメントで使用しています)、VS ps1スクリプトは例で使用するパラメータを持っていないようです。動作する使用例を教えてください。 – pasul

関連する問題