Unable to Publish the project from Azure DEVOPS - azure

I am new for azure devops and learning purpose create new basic account from azure. I created new projects and did require changes. This project publishing the code into azure VM and it's giving error in final step.
Step: IIS Web App Deploy
Error: No package found with specified pattern.Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
YAML for Release:
steps:
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'IIS Web App Manage'
inputs:
IISDeploymentType: '$(Parameters.IISDeploymentType)'
ActionIISWebsite: '$(Parameters.ActionIISWebsite)'
WebsiteName: '$(Parameters.WebsiteName)'
WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\DD'
AddBinding: '$(Parameters.AddBinding)'
Bindings: '$(Parameters.Bindings)'
CreateOrUpdateAppPoolForWebsite: true
AppPoolNameForWebsite: DD
ParentWebsiteNameForVD: '$(Parameters.WebsiteName)'
VirtualPathForVD: '$(Parameters.VirtualPathForApplication)'
ParentWebsiteNameForApplication: '$(Parameters.WebsiteName)'
VirtualPathForApplication: '$(Parameters.VirtualPathForApplication)'
AppPoolName: '$(Parameters.AppPoolName)
steps:
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
Package: '$(System.DefaultWorkingDirectory)/_ABC.API/drop/*.zip'
RemoveAdditionalFilesFlag: true
TakeAppOfflineFlag: true
XmlVariableSubstitution: True
Build YAML:
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:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
inputs:
SourceFolder: '$(agent.builddirectory)'
Contents: |
|
**\*.runsettings
**\*FunctionalTest*\**\bin\$(BuildConfiguration)\**
TargetFolder: '''$(build.artifactstagingdirectory)\FunctionalTests'''
- task: PublishBuildArtifacts#1
inputs:
artifactName: 'drop'
pathToPublish: '$(build.artifactStagingDirectory)'
Error Logs:
2020-04-19T10:02:47.0130907Z ##[section]Starting: IIS Web App Deploy
2020-04-19T10:02:47.0236460Z ==============================================================================
2020-04-19T10:02:47.0236816Z Task : IIS web app deploy
2020-04-19T10:02:47.0237124Z Description : Deploy a website or web application using Web Deploy
2020-04-19T10:02:47.0237414Z Version : 0.156.9
2020-04-19T10:02:47.0237649Z Author : Microsoft Corporation
2020-04-19T10:02:47.0238051Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-deployment-on-machine-group
2020-04-19T10:02:47.0238500Z ==============================================================================
2020-04-19T10:02:47.8446908Z ##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
2020-04-19T10:02:47.8471615Z ##[section]Finishing: IIS Web App Deploy
Please help to find the issue

Trying to change the section Package to use the path from pathToPublish by default it was System.DefaultWorkingDirectory.
- task: PublishBuildArtifacts#1
inputs:
artifactName: 'drop'
pathToPublish: '$(build.artifactStagingDirectory)'
Change in IISWebAppDeploymentOnMachineGroup task:
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
Package: '$(build.artifactStagingDirectory)/*.zip'
RemoveAdditionalFilesFlag: true
TakeAppOfflineFlag: true
XmlVariableSubstitution: True
Build.ArtifactStagingDirectory :
The local path on the agent where any artifacts are copied to before being pushed to their destination. For example: c:\agent_work\1\a
System.DefaultWorkingDirectory :
The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s
For this ,please refer to predefined variables.

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.

Error at executing Azure Pipeline for a .Net Desktop App - Azure DevOps

I'm creating my first Pipeline to build a .NET Desktop application. I have added the needed task to my YML file but I'm getting the following error, regarding an assembly that may be missing or not found.
Error Message: "The type or namespace name 'AxAcroPDFLibre' could not be found..."
This is the complete code of my YML file:
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
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)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(system.defaultworkingdirectory)'
Contents: '**/bin/**'
TargetFolder: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
I found this similar question here on StackOverflow, but I have checked my nugget package command and I have it in the build file.
At the end of the process, the job fails.
Right now that's all I've tried since I'm documenting myself on Azure DevOps Pipelines. If you have any recommendations I will appreciate them.

Cannot publish dotnet core web api app to Azure AppService

I need to build, test, and deploy a .net core web api app. I was hoping that this article titled Build, test, and deploy .NET Core apps would help me build, test, and deploy the app but for some reason I'm just not getting it.
I have a simple .net core 3.1 web api app.
I want to build and publish it to a virtual dir called 'api' on an Azure AppService.
I would prefer to publish using webdeploy but I will use whatever works if that is not possible.
The error I am getting on the AzureRmWebAppDeployment task is:
No package found with specified pattern: D:\a\1\s***.zipCheck if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
What am I missing or doing wrong here?
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
feedsToUse: 'select'
vstsFeed: 'Project/Feed'
includeNuGetOrg: true
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" /p:UseWPP_CopyWebApplication=true /p:OutDir="$(build.artifactstagingdirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI#2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'SubscriptionName'
appType: 'apiApp'
WebAppName: 'MyWebAppName'
VirtualApplication: 'api'
UseWebDeploy: true
You have output the build artifacts to folder $(Build.ArtifactStagingDirectory)(which is folder D:\a\1\a) In your VSBuild task and dotnet publish task. So you need to set the Package parameter to $(Build.ArtifactStagingDirectory)/**/*.zip for AzureRmWebAppDeployment task.
See below:
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'SubscriptionName'
appType: 'apiApp'
WebAppName: 'MyWebAppName'
VirtualApplication: 'api'
UseWebDeploy: true
Package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
If you donot specify the Package parameter for AzureRmWebAppDeployment task. The default value is $(System.DefaultWorkingDirectory)/**/*.zip, which makes AzureRmWebAppDeployment task look for the deployment artifacts in folder $(System.DefaultWorkingDirectory) (which is folder D:\a\1\s in build agent) and its subfolders. Since you output the build artifacts to folder $(Build.ArtifactStagingDirectory), that's why you saw the error No package found with specified pattern: D:\a\1\s***.zip.
See document Azure App Service Deploy task for more information.

YAML IIS web deploy deployment group

I am following the tutorial for the IIS web deploy pipeline according to the docs on IIS Web App Deploy task
If you see the parameter list, there does not seems to have any deployment group parameter. Therefore, how do I know / control in which server that the result of the deployment goes?
- task: IISWebAppDeploymentOnMachineGroup#0
inputs:
webSiteName:
virtualApplication: # Optional
package: '$(System.DefaultWorkingDirectory)\**\*.zip'
setParametersFile: # Optional
removeAdditionalFilesFlag: false # Optional
excludeFilesFromAppDataFlag: false # Optional
takeAppOfflineFlag: false # Optional
additionalArguments: # Optional
xmlTransformation: # Optional
xmlVariableSubstitution: # Optional
jSONFiles: # Optional
I want it to deploy to my "Dev" group as per screenshot below. If YAML can't deploy to deployment group, where is the default deployment location (ie, which computer?)
Let's say that I want to deploy to my PC , how do I direct the deployment to go to my localbox and put it under C:/publish ?
As at June 2020 the YAML-based multistage pipeline does not support deployment groups. However, the YAML-based pipeline has an alternative: Environments.
You can create an Environment manually, under Azure Pipelines > Environments. Once you have created the Environment you can add Resources underneath it. At the moment there are only two types of resources supported: Kubernetes and Virtual Machines. The Virtual Machine resource type is a bit misleading: It can be a virtual machine but it can also be an on-prem physical server. If you're deploying to IIS you'll need to create a Virtual Machine resource.
Creating a Virtual Machine resource under an Environment is very much like adding a target to a Deployment Group: When you add the Virtual Machine resource to the Environment it will generate a PowerShell script that you copy to the target server and run there as administrator. Running that script will create a self-hosted agent on the target server and will register that agent as a Resource under the Environment.
This process is almost identical to the process of adding a target to a Deployment Group.
In the YAML file specify the environment under the deployment job. It's not enough to specify the environment by name. You have to also specify the resourceType for the Environment as well as the name.
Here is my YAML for the build and deployment stages:
trigger:
- master
stages:
- stage: 'Build'
displayName: 'Build the web application'
jobs:
- job: 'Build'
displayName: 'Build job'
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:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: 'Deploy'
displayName: 'Deploy the web application'
dependsOn: Build
jobs:
- deployment: 'DeployToDev'
displayName: 'Deploy the web application to dev environment'
variables:
Parameters.IISDeploymentType: 'IISWebsite'
Parameters.ActionIISWebsite: 'CreateOrUpdateWebsite'
Parameters.WebsiteName: 'Default Web Site'
Parameters.WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\AspNetDemo'
Parameters.AddBinding: false
Parameters.VirtualPathForApplication: '/AspNetDemo'
Parameters.AppPoolName: ''
Parameters.VirtualApplication: 'AspNetDemo'
Parameters.Package: '$(Pipeline.Workspace)\drop\*.zip'
Parameters.RemoveAdditionalFilesFlag: true
Parameters.TakeAppOfflineFlag: true
Parameters.XmlTransformation: true
Parameters.XmlVariableSubstitution: true
environment:
name: Dev
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'IIS Web App Manage'
inputs:
IISDeploymentType: '$(Parameters.IISDeploymentType)'
ActionIISWebsite: '$(Parameters.ActionIISWebsite)'
WebsiteName: '$(Parameters.WebsiteName)'
WebsitePhysicalPath: '$(Parameters.WebsitePhysicalPath)'
AddBinding: $(Parameters.AddBinding)
ParentWebsiteNameForVD: '$(Parameters.WebsiteName)'
VirtualPathForVD: '$(Parameters.VirtualPathForApplication)'
ParentWebsiteNameForApplication: '$(Parameters.WebsiteName)'
VirtualPathForApplication: '$(Parameters.VirtualPathForApplication)'
AppPoolName: '$(Parameters.AppPoolName)'
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
VirtualApplication: '$(Parameters.VirtualApplication)'
Package: '$(Parameters.Package)'
RemoveAdditionalFilesFlag: $(Parameters.RemoveAdditionalFilesFlag)
TakeAppOfflineFlag: $(Parameters.TakeAppOfflineFlag)
XmlTransformation: $(Parameters.XmlTransformation)
XmlVariableSubstitution: $(Parameters.XmlVariableSubstitution)
Note the environment information in the deployment stage, specifying the name (Dev) and the resourceType (VirtualMachine):
environment:
name: Dev
resourceType: VirtualMachine
YAML does not support deployment groups. If you want to use deployment groups, you can't use YAML.
Daniell is right, It seems at this moment YAML can't do the release to deployment group The workaround is as below:
add the following code in the build:
task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Pipeline.Workspace)'
publishLocation: 'pipeline'
task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
and then you can go to the release , use iis web deploy, ensure that the correct artefact is used in step 1 and choose your package folder. You should be able to see the artifact that you built.

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