ASP.NET 5 MVC 6: Incorrect Publish-AzureWebsiteProject Directory Structure

When publishing an ASP.NET 5 MVC 6 application to Azure Web App using powershell, it appears that the published folder structure is incorrect.

After publishing, the wwwrootfolder is too deep:

wwwroot dir

If I changed the application virtual directory from site\wwwrootto site\wwwroot\wwwroot, then it will work!

First , I build and publish files using MSBuild:

/t:Build,FileSystemPublish /p:PublishConfiguration=$(BuildConfiguration) /p:PublishOutputPathNoTrailingSlash=$(build.stagingDirectory)

Second , publish to Azure Web App using this script and go through $(build.stagingDirectory)as $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 don’t seem to see where everything goes wrong.

Edit: Using DNX beta6

+4
2

, Publish.zip . , dnu publish, .NET 5.

approot
wwwroot

Publish-AzureWebsiteProject Publish.zip Azure Web App site/wwwroot. , site/wwwroot, /site, Azure Web App.

D:\
  home 
    site
      approot
      wwwroot

- Azure Git FTP Publish-AzureWebsiteProject. , PowerShell. Git, , Project Kudu.

Click with Git

+2

site\wwwroot to site\wwwroot\wwwroot . wwwroot

 site
  wwwroot
   wwwroot
    wwwroot

, site\wwwroot\wwwroot\wwwroot, - . . , -. API :

/    site\wwwroot
/api site\wwwroot\wwwroot

Publish-AzureWebsiteProject \wwwroot, something.com/api

+1

Source: https://habr.com/ru/post/1607689/


All Articles