When publishing a ASP.NET 5 MVC 6 application to an Azure Web App using powershell, it seems that the published folder structure is somehow incorrect.
After the publish, the wwwroot
is one folder too deep:
If I change the application's virtual directory from site\wwwroot
to site\wwwroot\wwwroot
, then it works!
First, I build and file publish using MSBuild:
/t:Build,FileSystemPublish /p:PublishConfiguration=$(BuildConfiguration) /p:PublishOutputPathNoTrailingSlash=$(build.stagingDirectory)
Second, publish to Azure Web App using this script and passing in $(build.stagingDirectory)
as the $packOutput
:
param([String] [Parameter(Mandatory = $true)]$websiteName, [String] [Parameter(Mandatory = $true)]$packOutput)
$SourceFolder = "$packOutput"
[IO.DirectoryInfo] $parentDir = [System.IO.Path]::GetDirectoryName($packOutput)
$DestinationFile = "$parentDir\Publish.zip"
$Compression = "Optimal" # Optimal, Fastest, NoCompression
function Zip-Directory {
Param(
[Parameter(Mandatory=$True)][string]$DestinationFileName,
[Parameter(Mandatory=$True)][string]$SourceDirectory = "",
[Parameter(Mandatory=$False)][string]$CompressionLevel = "Optimal",
[Parameter(Mandatory=$False)][switch]$IncludeParentDir
)
Add-Type -AssemblyName System.IO.Compression.FileSystem
$CompressionLevel = [System.IO.Compression.CompressionLevel]::$CompressionLevel
[System.IO.Compression.ZipFile]::CreateFromDirectory($SourceDirectory, $DestinationFileName, $CompressionLevel, $IncludeParentDir)
}
Zip-Directory -DestinationFileName $DestinationFile `
-SourceDirectory $SourceFolder `
-CompressionLevel $Compression ` #Optional parameter
Move-Item -Path $DestinationFile -Destination $SourceFolder\Publish.zip
Write-Output "Stopping web app..."
Stop-AzureWebsite -Name $websiteName
Write-Output "Publishing web app..."
Publish-AzureWebsiteProject -Name $websiteName -Package $SourceFolder\Publish.zip
Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName
I cannot seem to see where this is all going wrong.
Edit: Using DNX beta6