I have a solution with multiple projects. I want to obtain (in artifacts) project UserUi.csproj
, which is an ASP.NET MVC app (with references to other libraries inside the solution), ready to be copied to a server.
By running this yml:
trigger:
- master
pool:
vmImage: "windows-latest"
variables:
solution: "**/*.sln"
buildPlatform: "Any CPU"
buildConfiguration: "Release"
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: "$(solution)"
- task: VSBuild@1
inputs:
solution: "$(solution)"
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)UserUi"'
platform: "$(buildPlatform)"
configuration: "$(buildConfiguration)"
- task: VSTest@2
inputs:
platform: "$(buildPlatform)"
configuration: "$(buildConfiguration)"
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)UserUi'
ArtifactName: 'drop'
publishLocation: 'Container'
I’m getting weird "deploy" files, and UserUi.deploy.zip
file which contains proper files, but in a path:
UserUi.zipContentD_Ca1s4. SampleLayerUserUiobjReleasePackagePackageTmp
Why is that? How can I get just one zip (or normal folder) with PackageTmp contents inside?
I will need to publish this (copy to specified folder) artifacts by using Azure agent installed on server, but with this structure I can’t.
2
Answers
I can reproduce the same situation when using the VSBuild and same arguments.
To meet your requirement, you can add the following vsbuild argument to directly put the outputs to artifacts folder:
YAML sample:
In this case, the PackageTmp contents inside will show in a normal folder.
For example:
If you need to package all files, you can use Archive files task to zip the files.
For more detailed info, you can refer to this doc: Deloy Web App
Try simplifying your VSBuild task. Then use a CopyFiles task to organize only the files you want to deploy from your build. Here is a generic example:
This one builds only one web project out of my whole solution. But you could build the whole solution too.
Or, you can also try applying only one of your
msbuildargs
at a time and viewing the output to see if you can eliminate the one making the crazy file structures.You can also add the
publishLocation
attribute to your PublishArtifacts step to write thePathtoPublish
contents directly to another file location without having to retrieve them from your artifacts.