I have nearly the most simple Pipeline/Release for a .Net 8 project.
The .zip file has a Content/D_C/a/1/s/
and since it's deploying to a linux container it doesn't attempt to unwrap this. I tried changing my build host to ubuntu-24.04 but it said that I don't have mono installed. I think that might be the actual issue I need to solve. I can't see anywhere I'm targeting .Net Framework in my core app. All my projects target net8.0 only. So why would it want mono? But either way, this should work building with a Windows VM; right?
This somewhat describes my issue: Azure web app get deployed but wrong content in wwwroot folder
I can reproduce the same issue when using the VSBuild task template default argument.
For example:
- task: VSBuild@1
displayName: 'Build solution'
inputs:
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
To remove additional folder path in the zip package, we need to change the VSbuild task argument:
VSbuild Argument sample:
/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactStagingDirectory)\\"
Build Pipeline sample:
steps:
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: '**\*.sln'
- task: VSBuild@1
displayName: 'Build solution'
inputs:
msbuildArgs: '/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactStagingDirectory)\\"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: ArchiveFiles@2
displayName: 'Archive $(build.artifactStagingDirectory)'
inputs:
rootFolderOrFile: '$(build.artifactStagingDirectory)'
includeRootFolder: false
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
We can use archive files task to zip all output files.
In this case, it will not contains additional folder path in the zip file.
Result:
Then when we deploy the package to Web App, the files will be deployed to wwwroot/
folder.
For more detailed info, you can refer to this doc: Deploy Web App
Web packages created via the MSBuild task (with default arguments) have a nested folder structure that can be deployed correctly only by Web Deploy.