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.zip\Content\D_C\a\1\s\4. SampleLayer\UserUi\obj\Release\Package\PackageTmp
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.
I can reproduce the same situation when using the VSBuild and same arguments.
How can i just have a one zip (or normal folder) with PackageTmp contents inside?
To meet your requirement, you can add the following vsbuild argument to directly put the outputs to artifacts folder:
/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactStagingDirectory)\\UserUi"
In this case, the PackageTmp contents inside will show in a normal folder.
Update:
i'm getting all of the projects - except the UserUi... i need to have file structure like Bin, Content, fonts, Scripts, Views, favicon.ico, Global.asax, Web.config
To solve this issue, we need to remove the VSBuild argument: /p:DeleteExistingFiles=True
. Then it will add the required files to the artifacts.
VSbuild argument:
/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactStagingDirectory)\\UserUi"
YAML sample:
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:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl="$(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'
Result: it will contain the bin ,fonts, scripts and other files.