How do I pass OutDir value in azure-pipelines.yml for the VSBuild task? - azure-pipelines-build-task

This is how the task step looks. I am not able to get the output files into the $(Build.ArtifactStagingDirectory) directory.
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArguments: '/p:OutDir="$(Build.ArtifactStagingDirectory)"'
I'm wondering if the msbuildArguments parameter is in the right format.

- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: "/p:OutDir=$(Build.ArtifactStagingDirectory)"
Apparently, its msbuildArgs and not msbuildArguments.

Related

How to deploy code without zip file and inner folders azure devops

I'm new to Azure DevOps and trying to configure CI/CD pipelines. Here are the steps that I followed.
Created VM and setup IIS
Created pipeline on Azure devops with Github source code. Here is yml file.
azure-pipelines.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=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
inputs:
contents: 'build/**'
targetFolder: '$(Build.ArtifactStagingDirectory)'
cleanTargetFolder: true
- task: PublishBuildArtifacts#1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
Created and configure Deployment groups, and setup agent with auth token
Build and deployment works fine, but there are 2 problems
Build generates artifacts with zip file.
zip file has lot more inner folder where actual executable files are located.
You could use IISWebAppDeploymentOnMachineGroup#0 - IIS web app deploy v0 task in your release pipeline.
Using predefined variable to locate the .zip
$(System.DefaultWorkingDirectory)\**\*.zip
This task supports the .zip file extract.

Azure pipeline For Multiple Projects

I have a solution with an web api project and a blazor webassembly project. If I create a pipeline to create an artifact for release, it all works great untill I visit the domain where I can only visit my blazor webassembly project. How am I able to access the api?
azure pipeline:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# trigger:
# - master
pool:
vmImage: 'windows-2022'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'BackEndRelease'
steps:
- task: UseDotNet#2
displayName: Use .NET 6.0
inputs:
packageType: 'sdk'
version: '6.0.x'
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
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)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
I use the artifact to create a release pipeline.
I even created my own build configuration (BackEndRelease) where I unchecked the blazor project, but it doesn't change anything.
Based on your requirement, you need to specify the API project in Solution file.
You can add msbuild argument in the VSBuild task.
Here are the steps:
1.Check the target Project name in Solution file.
For example:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{497AD76F-222C-4BEB-BDCB-401B0E80B5CE}"
2.Add the target argument in VSbuild. /t:test
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site" /t:test'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

Does the stage keyword define a Build or Deploy pipeline in Azure DevOps in YAML file

I would like to know if if we consider this block of YAML code if this is already considered a Build and Release pipeline...or we need to define stages to characterise that. This below code works but you don't see the individual stages when you run this. However it does Build and Deploy to Azure in this case. So that's why I ask. I am looking for correct terminology. Is this a Build and Release pipeline or you can't say that and only if I define the stages Build and Release it is one.
Hope this is clear.
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
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=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
appType: 'webApp'
WebAppName:
packageForLinux: '$(System.ArtifactsDirectory)/drop/*.zip'
In YAML, there's no distinction. A pipeline is a pipeline. If it contains stuff that results in software being released, feel free to call it a release pipeline if you want.

Produced artifact has too many layers of folders

I have the following pipeline that builds a ASP.NET Core 5 Web project, but the artifact produced has the following structure
ProjectName.zip
Content
D_C
a
1
s
ProjectName
obj
release
package
PackageTmp
(Finally The actual content) as it should be
archive.xml
parameters.xml
systeminfo.xml
I simply want my zip to be the content of packagetmp without any parent folders
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: ''myfeed'
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
displayName: "Upload Artifacts"
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
You can change the msbuildArgs as below to generate the artifacts as files instead of a zip file. And then you can use Archive files task to zip the artifacts. See below:
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)" /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
The msbuildArgs in above example will output the artifacts to folder $(build.artifactstagingdirectory) unzipped.
Then after VSBuild Task. You can add Archive files task to zip the artifacts:
- task: ArchiveFiles#2
displayName: 'Archive task'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/Temp/ProjectName.zip'
Above example will zip the artifacts in $(Build.ArtifactStagingDirectory), and save the zip file in $(Build.ArtifactStagingDirectory)/Temp/ProjectName.zip
Then in the PublishBuildArtifacts task. Set the PathtoPublish to folder $(Build.ArtifactStagingDirectory)/Temp
- task: PublishBuildArtifacts#1
displayName: "Upload Artifacts"
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Temp'
You should get a zip file with the content of packagetmp only.

Azure Devops : ##[error]Error: No package found with specified pattern: d:\a\r1\a\**\*.zip

I have tried to Deploy an ARM template from GitHub with Azure DevOps Pipeline (CI/CD). when i click the deploy button I get the following error.
https://developercommunity.visualstudio.com/content/problem/349729/error-no-package-found-with-specified-pattern-dar1.html
##[error]Error: No package found with specified pattern: d:\a\r1\a***.zip
I did as per the suggestion in the following link but doesnt work for me . Added - task: PublishBuildArtifacts#1 to last line of the azure-pipelines.yml file
azure-pipelines.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=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
Screenshot
basically this means your package is not being created or is being created in path you are not scanning; try this:
- task: PublishBuildArtifacts#1
inputs:
#pathtoPublish: '$(Build.ArtifactStagingDirectory)'
Azure Devops : ##[error]Error: No package found with specified pattern: d:\a\r1\a***.zip
If you are using "Azure App Service Deploy" task, set the "Package or folder" path to: $(System.DefaultWorkingDirectory)\<YourBuildPipelineName>\<Artifact name>\WebApp.zip.
You can get the path from the log in the Download Artifacts in your release pipeline:
For example:
The value should be in the yellow area.
Alternatively, you can select the .zip file by the option ...:
Hope this helps.

Resources