We are planning to migrate our current CICD setup which includes Jira and Jenkins, to Azure DevOps but we need suggestion how we can tackle below scenario in Azure DevOps:
We have multiple artifacts in Jira ticket( which can varies from 10 to 200). When we move the ticket to different column in kanban board it triggers jenkins deployment job which deploys all these artifacts at once as one release
But we are not able to find how we can achieve this in azure releases, as it only allows one artifacts in one release. How can we deploy multiple artifacts like above in a release
You could simplify it so instead of deleting the content how about put each artifact in a sub folder of the $(Build.ArtifactStagingDirectory) So by just appending /Api or /App I could create specific publish folders that I could then push onto the azure pipeline.
You can then have as many artifacts as you need.
The important parts to take from this are that publishWebProjects needs to be set to false or it defaults to true and then ignores the projects line below, and the output path puts the content in a sub folder.
# This need to be false in order for the specific project to be published
publishWebProjects: False
projects: '**/DevOpsApp.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/App'
and pathtoPublish need to then point to the sub folder
pathtoPublish: '$(Build.ArtifactStagingDirectory)/App'
Full example file below:
steps:
- task: DotNetCoreCLI#2
displayName: 'Build'
inputs:
command: 'build'
projects: '**/DevOpsApi.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration)'
testRunTitle: 'Unit Tests'
# Publish the artifact
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
# This need to be false in order for the specific project to be published
publishWebProjects: False
projects: '**/DevOpsApi.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/Api'
zipAfterPublish: True
# Publish the artifact for the pipelines to use
- task: PublishBuildArtifacts#1
displayName: 'Publishing WebAPI Artifact'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/Api'
artifactName: 'TestWebApi-Wip'
Related
I have an ASP.NET Core project in Azure DevOps repository and it gets built OK using the DevOps build pipeline. However, the release over that builds always fails with this 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.
More Details:
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- release/*
pool:
vmImage: 'windows-2022'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
projectName: '**/F11.Web.csproj'
runtime: 'win-x64'
steps:
- task: UseDotNet#2
displayName: 'Use .NET 5 SDK (preview)'
inputs:
packageType: 'sdk'
version: '5.0.100-rc.1.20452.10'
vsVersion: '16.8.0'
includePreviewVersions: true
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
projects: '$(projectName)'
feedsToUse: 'select'
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: '$(projectName)'
arguments: '--no-restore'
- task: DotNetCoreCLI#2
displayName: Test
inputs:
command: test
projects: '$(projectName)'
arguments: '-l "console;verbosity=detailed"'
- task: DotNetCoreCLI#2
displayName: 'Publish WebApi'
inputs:
command: publish
publishWebProjects: false
projects: '$(projectName)'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) --runtime -r $(runtime)'
- task: CopyFiles#2
inputs:
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifactName: 'PublishBuildArtifact'
Azure DevOps pipeline release Error: No package found with specified pattern:
First, you could make sure you have generated the artifact for your build pipeline, check it from the build history in the build pipeline.
Second, when you using the release pipeline to deploy the artifact, you need make sure you have select the correct build pipeline.
Third, set the correct configuration for the task IIS web app deploy:
If above not help you, please share the configuration for the task IIS web app deploy with image in your question.
Visual Studio 2019
.NET 5 WebApplication
Azure Devops Build Pipeline
Disclaimer: I initially wrote this question for the MS Developer Community, but quickly realized I do not have weeks to spend on this so I came to the experts over here on Stack. I have researched this issue through and through... I have tried so many different combinations of the publish command and arguments without ANY success.
I am building a .NET 5 web application. It has a few packages that it uses that are custom nuget packages. These packages are deployed to and live within the Azure Organization Feed. Using the YAML below I can Restore, and Build and these packages get “pulled down”. However, when I try to use the publish command, the DLL’s for the nuget packages never make their way to the published website.
YAML:
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'x64'
ASPNETCORE_ENVIRONMENT: 'Staging'
steps:
- task: UseDotNet#2
displayName: 'Install .NET Core SDK 5.0.100'
inputs:
version: 5.0.100
performMultiLevelLookup: true
includePreviewVersions: true
- task: DotNetCoreCLI#2
displayName: '.NET Restore Packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
vstsFeed: '9ae2db37-long-private-guid'
- task: DotNetCoreCLI#2
displayName: '.NET Build Projects'
inputs:
command: 'build'
publishWebProjects: False
projects: '**/*.csproj'
arguments: '-c Staging --output $(Build.ArtifactStagingDirectory)'
#I expect that the next section would include DLL from nuget feeds, but it does not.
- task: DotNetCoreCLI#2
displayName: '.NET Publish Staging'
inputs:
publishWebProjects: true
command: 'publish'
feedsToUse: 'select'
vstsFeed: '9ae2db37-long-private-guid'
arguments: '-c Staging --runtime win-x64 --verbosity Detailed --output $(Build.ArtifactStagingDirectory)/Staging'
projects: '**/*.csproj'
zipAfterPublish: false
- task: PublishBuildArtifacts#1
displayName: 'Creating Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Staging'
ArtifactName: 'drop'
publishLocation: 'Container'
I did read something about “copytolocal” this solved an issue for me before, but that option is not present in Visual Studio 2019 (Version 16.11.15). If I right click the package there is no way to instruct it.
The only way I have found to get this to work is to create a build task, it pulls the packages, then I publish, but manually copy the DLLs from build that are missing from publish. There HAS to be a better way.
I have searched around for a while, but not been able to find a good way to create a "installation bundle" for web service to run on IIS.
My problem is that we need to manually copy files to the on premises servers due to security, and thus not allowed to automate this job. But as far as I can see all the IIS Deployment templates uses Deployment group to distribute the releases to registered servers.
Is there a way to create a Release pipeline for IIS that produce a zip file/artifact that can be downloaded manually from DevOps or from a drop folder instead?
I have made one Release pipeline using tasks CopyFiles#2, FileTransform#1 and UniversalPackages#0 to copy the build artifact, transform the appsettings.json file and publish the package, but this does not add the nesessary files for IIS, such as the web.config file.
Thanx for any responses :-)
This is the build pipeline yml file:
trigger:
- release*
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: build
projects: '**/*.sln'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: 'dotnet test'
inputs:
command: test
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration) --no-restore --collect "Code coverage"'
testRunTitle: 'Unit and Integrtion Tests'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: true
arguments: '--configuration $(buildConfiguration) --output $(build.artifactStagingDirectory)'
zipAfterPublish: true
- task: PublishPipelineArtifact#1
displayName: 'publish pipeline artifact'
inputs:
targetPath: '$(build.artifactStagingDirectory)'
artifactName: 'WebAPI'
And the Release pipeline:
Release pipeline
You could directly use a release pipeline which associated with a build pipeline.
Add the related build pipeline under Artifacts, also, remember to add the Publish build artifacts Task under the build pipeline, which will help the release catch the final zip folder.
Then, you could create a Release under Stages, use Manage IISWebsite Task and Deploy IIS Webiste/App Task.
That is enough.
After som twists and turns I ended up with this solution, using a template yml file for Dev and Release.
If anyone have any suggestions for improvments, please comment below.
Hope this can be of help :-)
Pipelines:
azure-pipelines-build-template.yml:
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
artifactPath: '$(build.artifactStagingDirectory)'
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet build solution'
inputs:
command: build
projects: '**/*.sln'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: 'dotnet test solution'
inputs:
command: test
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration) --no-restore'
testRunTitle: 'Unit and Integrtion Tests'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish to pipeline'
inputs:
command: publish
publishWebProjects: true
arguments: '--configuration $(buildConfiguration) --output $(artifactPath)'
zipAfterPublish: true
- task: PublishPipelineArtifact#1
displayName: 'publish pipeline artifact Flyttavle'
inputs:
targetPath: '$(artifactPath)'
artifactName: 'WebAPI'
azure-pipelines-dev-build.yml:
trigger:
- dev
pool:
vmImage: 'windows-latest'
extends:
template: azure-pipelines-build-template.yml
azure-pipelines-release-build.yml:
trigger:
- release*
pool:
vmImage: 'windows-latest'
extends:
template: azure-pipelines-build-template.yml
Releases:
I have created 4 releases, Azure_Dev_Deploy and Azure_Release_Deploy which deploys to Azure, and On_Prem_Prod_Deploy and On_Prem_Test_Deploy that creates packages to download for on premise deployment.
Dev_Deploy and Release_Deploy:
Difference here are:
Trigger is set up for changes respectively on dev and release branches
Deployment points to the app service in Azure for respectively dev and release app services
Variables points to Variable groups respectively for dev and release variable substitutions (defined in Library)
Release Pipeline and Tasks for Dev_Deploy and Release_Deploy
(same setup for both, but picture shows the Dev deployment)
And the yaml view of the task:
Deploy Azure App Service:
steps:
- task: AzureRmWebAppDeployment#4
displayName: 'Deploy Azure App Service'
inputs:
azureSubscription: '$(Parameters.ConnectedServiceName)'
appType: '$(Parameters.WebAppKind)'
WebAppName: '$(Parameters.WebAppName)'
packageForLinux: '$(System.DefaultWorkingDirectory)/_BEDevBuild/WebAPI.zip'
JSONFiles: '**/appsettings*.json'
On_Prem_Test_Deploy and On_Prem_Prod_Deploy:
Difference here are:
Creates Artifacts respectively for on-prem-test and on-prem-prod
Variables points to Variable groups respectively for on-prem-test and on-prem-prod variable substitutions (defined in Library)
Release Pipeline and Tasks for On_Prem_Test_Deploy and On_Prem_Prod_Deploy
(same setup for both, but picture shows the Test deployment)
And the yaml view of the tasks:
File Transform:
steps:
- task: FileTransform#1
displayName: 'File Transform: on-prem/prod'
inputs:
folderPath: '$(System.ArtifactsDirectory)/_BEReleaseBuild/*.zip'
fileType: json
targetFiles: '**/appsettings*.json'
Universal publish:
steps:
- task: UniversalPackages#0
displayName: 'Universal publish'
inputs:
command: publish
publishDirectory: '$(System.ArtifactsDirectory)/_BEReleaseBuild'
vstsFeedPublish: '********-****-****-****-************/********-****-****-****-************'
vstsFeedPackagePublish: 'on-prem-prod'
packagePublishDescription: 'Package for on premise production'
Download Artifacts:
Then to download the artifacts in the Artifacts feed, I use the following statement from Powershell locally.
PS! As for today it is not possible to download from a REST call for the universal package which ruined my grand plan of creating a download link in the Wiki, but hopefully this will be supported in the future.
on-prem-test:
az artifacts universal download --organization "https://dev.azure.com/[my org name]/" --project "[DevOps project id]" --scope project --feed "on-premise" --name "on-prem-test" --version "*" --path .
on-prem-prod:
az artifacts universal download --organization "https://dev.azure.com/[my org name]/" --project "[DevOps project id]" --scope project --feed "on-premise" --name "on-prem-prod" --version "*" --path .
Tip on parameters:
--version "*" will allways get latest version in the feed for the given package name
--path . downloads the package to where you execute the command in Powershell
We created a build pipeline yaml for our blazor webassembly project that includes a publish task. For some reason only the wwwroot folder items get generated into the drop folder, and all the other binaries that are normally located outside of the wwwroot folder are not generated for some reason.
Here is part of the yaml file that builds and publishes. Is it setup incorrectly to get all the files generated and published, or is it just that it will only give us the static files being a webassembly project?
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)"'
zipAfterPublish: false
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
Also, since we are finding that Blazor webassembly has an issue using the Azure configuration settings for a web service, we are needing to have the publish process manipulate the web.config file so we can set the ASPNETCORE_ENVIRONMENT of the build and deploy. Everything I have found so far does not work when run in the DevOps build pipeline, as they are meant for dotnet scripts.
Does anyone know how this can be done? We have tried to add site /p:EnvironmentName=Development to the --output argument of the publish task, but it says it cannot run on multiple projects, even though we set the projects argument to just the one (it is not shown above as we put it back to normal for now).
Thank you,
Chris Calvert
Did you try this?
task: DotNetCoreCLI#2
displayName: Publish
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(buildConfiguration) --output "$(build.artifactstagingdirectory)" /p:EnvironmentName=Development'
zipAfterPublish: True
Did any got a working Build Definition in Azure DevOps working for nopCommerce 4.xx working? If so will you please share the YAML-file. I tried several possible solutions, but I don't get it work.
I used the default ASP.NET Core template from Azure Devops. See below YAML
content: resources:
- repo: self queue: name: Hosted Ubuntu 1604
steps:
- task: DotNetCoreCLI#2 displayName: Restore inputs:
command: restore
projects: '$(Parameters.RestoreBuildProjects)'
- task: DotNetCoreCLI#2 displayName: Build inputs:
projects: '$(Parameters.RestoreBuildProjects)'
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI#2 displayName: Test inputs:
command: test
projects: '$(Parameters.TestProjects)'
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI#2 displayName: Publish inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
zipAfterPublish: True
- task: PublishBuildArtifacts#1 displayName: 'Publish Artifact' inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
At the Build step it gives errors when trying to build the Plugins:
2018-12-16T20:31:51.2431313Z
/home/vsts/work/1/s/src/Build/ClearPluginAssemblies.proj(21,5): error
MSB3073: The command "dotnet
"/home/vsts/work/1/s/src/Build\ClearPluginAssemblies.dll"
"OutputPath=/home/vsts/work/1/s/src/Build/../Presentation/Nop.Web/bin/Release/netcoreapp2.1/|PluginPath=/home/vsts/work/1/s/src/Plugins/Nop.Plugin.DiscountRules.CustomerRoles/../../Presentation/Nop.Web/Plugins/DiscountRules.CustomerRoles/|SaveLocalesFolders=""
exited with code 1.
Anyone an idea how to get this working?
Edit:
The response of Eriawan give me some insight to look further. I investigated the csproj files of one of the Plugins and see there the next section:
Thank you for your response. It took me closer to the root cause of the problem (hopefully). I investigated one of the csproj file of the PlugIns of nopCommerce and I see the following section
<!-- This target execute after "Build" target -->
<Target Name="NopTarget" AfterTargets="Build">
<!-- Delete unnecessary libraries from plugins path -->
<MSBuild Projects="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" Properties="PluginPath=$(MSBuildProjectDirectory)\$(OutDir)" Targets="NopClear" />
</Target>
Is there a way to turn off these extra execution during build? or to get this work during build, without adjust the csproj file (because I want to adopt future changes of the project)?
If you are using YAML as option for your Azure Pipelines, you should pay attention to the sequence for the build. Also don't mix YAML with build definition, because YAML is different from the old build definition used by TFS and VSTS (before it changed name to be Azure DevOps).
Looking at the YAML, you should have a full build on your DotNetCoreCLI#2 task, by executing command build. The error you have is a little bit cryptic, but it shows that you just execute dll directly and this means you are going to execute the dll instead of doing actual build.
So instead of this:
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: '$(Parameters.RestoreBuildProjects)'
arguments: '--configuration $(BuildConfiguration)'
It should be this:
- task: DotNetCoreCLI#2
displayName: Build
command: build
inputs:
projects: '$(Parameters.RestoreBuildProjects)'
arguments: '--configuration $(BuildConfiguration)'
Notice the additional command: build.