I'm very new to this pipeline and i'm trying to build a automated way to build the .msi installer file for my application.
I have 2 projects .Net Core and Python, so i created 2 pipelines. The .Net Core pipeline will build and save the files in a location and Python pipeline uses those files(from location) for its dependency and builds a new .msi file, the last portion in the pipeline newsetup.py builds the .msi to which i'll be passing the location of the output files of .Net Core pipeline.
The error i get is Artifact dropcli was not found for build 150.
.Net Core pipeline script:
- 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: PublishPipelineArtifact#1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifact: 'dropcli'
publishLocation: 'pipeline'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Python pipeline script:
- task: DownloadPipelineArtifact#2
inputs:
buildType: 'current'
artifactName: 'dropcli'
targetPath: '$(Pipeline.Workspace)'
- task: PythonScript#0
inputs:
scriptSource: 'filePath'
scriptPath: 'src/python/newsetup.py'
arguments: 'bdist_msi $(Pipeline.Workspace)'
Also if i specify the build number somewhere won't it be an issue when a new pipeline is created? Or is that an limitation?
In your DownloadPipelineArtifact#2 task, the value of buildType is current. This means that you are downloading the artifact in the current run. You should set buildType to specific. Here is an example to download the latest artifact from a specific pipeline:
- task: DownloadPipelineArtifact#2
inputs:
buildType: 'specific'
project: '{project id}'
definition: '{pipeline id}'
buildVersionToDownload: 'latest'
artifactName: 'dropcli'
targetPath: '$(Pipeline.Workspace)'
You can click "Settings" at the top of the task, it will help you to complete your task more easily.
Click Download Pipeline Artifacts task for detailed information about arguments of this task.
If i specify the build number somewhere won't it be an issue when a new pipeline is created? Or is that an limitation?
As mentioned above, you don't need to specify the build number, and what you need to specify is the pipeline definition id. You can either download the latest artifact of a pipeline or the artifact of a specific build of a pipeline.
Related
I have two solutions in my repository (one AppService (.NET Core API project) and another that is containing Azure Functions).
I am having 2 separate build pipelines and 2 separate release pipelines on Azure DevOps:
UserManagementAPI .yml file (API build pipeline):
trigger:
- dev
pool:
vmImage: 'windows-latest'
variables:
solution: '**/UserManagementAPI.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
displayName: 'Build'
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: DotNetCoreCLI#2
displayName: 'Test'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: 'Publish'
inputs:
command: publish
publishWebProjects: true
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
publishLocation: pipeline
artifactName: userManagementAPI
UserManagementAPI.Functions .yml file (Functions build pipeline):
trigger:
- dev
pool:
vmImage: 'windows-latest'
variables:
solution: '**/UserManagementAPI.Functions.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
displayName: 'Build'
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\UserManagement-Function.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: 'Test'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: 'Publish'
inputs:
command: publish
publishWebProjects: true
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
publishLocation: pipeline
artifactName: userManagementAPI-functions
The build pipeline for UserManagementAPI is working just fine, artifact is created correctly, there is a zip file with everything included inside. The release pipeline is working fine as well, basically it's an Azure App Service Deploy task, here is the image:
On the other hand, build pipeline or release pipeline for azure functions are not working correctly, here is the artifact generated from UserManagementAPI.Functions build:
If I download the artifact, UserManagementAPI.zip file is containing all the dlls for UserManagementAPI solution (not the functions) and UserManagement-Function.zip is containing some weird data. Here is what is inside of it:
If I go deep into Content folder:
Here I can see my functions folders and bin folder, bin folder is containing all dlls of the functions (but it's too deep I think, it should be at the top of the zip, not inside Content\D_C\a\1\s\UserManagement.Functions\obj\Release\net6.0\PubTmp\Out\bin).
Each of the functions folders are containing one json file, here is one example:
The artifact files are generated in weird way and weird path in my opinion.
Here is the release pipeline of UserManagementAPI.Functions:
Both build pipelines (API and Functions) are executing successfully, they generate artifacts, release pipeline of UserManagementAPI is working fine but release pipeline of UserManagementAPI-Functions is throwing an error:
##[error]Error: Deployment of msBuild generated package is not supported. Change package format or use Azure App Service Deploy task. /home/azureuser/myagent/_work/r35/a/InternalUsers-Functions/userManagementAPI-functions/UserManagement-Function.zip
I have also found an article on stackoverflow having similar issue, but I couldn't solve it using Fernando Magno's suggestion and Leo Liu's suggestion is confusing to me, how can I have App Service for Azure Function.
To be honest, I'm new to release/build pipelines, especially having same repo with 2 solutions, so any help is appreciated here!
I'm learning Azure DevOps and I'm stuck with a build pipeline.
The project is a simple .NET Core web app and this is the YAML file
# 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:
- main
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: '**/azpipe.csproj'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\'
platform: '$(buildConfiguration)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
When I run the pipeline I get error and this is the log
Publish:
azpipe -> D:\a\1\s\obj\Debug\net5.0\PubTmp\Out\
_TransformWebConfig:
No web.config found. Creating 'D:\a\1\s\obj\Debug\net5.0\PubTmp\Out\web.config'
_PrepareForMsDeployPublish:
Creating directory "D:\a\1\a\ \p:platform=Release \p:configuration=Release \p:VisualStudioVersion=17.0 \p:_MSDeployUserAgent=VSTS_ac5aa204-3429-4edf-ae3d-777f0b31c141_build_9_0\".
##[warning]C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk.Publish\targets\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(156,5): Warning MSB3191: Unable to create directory "D:\a\1\a\ \p:platform=Release \p:configuration=Release \p:VisualStudioVersion=17.0 \p:_MSDeployUserAgent=VSTS_ac5aa204-3429-4edf-ae3d-777f0b31c141_build_9_0\". The given path's format is not supported.
C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk.Publish\targets\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(156,5): warning MSB3191: Unable to create directory "D:\a\1\a\ \p:platform=Release \p:configuration=Release \p:VisualStudioVersion=17.0 \p:_MSDeployUserAgent=VSTS_ac5aa204-3429-4edf-ae3d-777f0b31c141_build_9_0\". The given path's format is not supported. [D:\a\1\s\azpipe.csproj]
The previous error was converted to a warning because the task was called with ContinueOnError=true.
Build continuing because "ContinueOnError" on the task "MakeDir" is set to "true".
and so far whit many of this rows.
I tried several solution found but I cannot get it to work.
Can someone help me?
Thank you!
According to the warning message "Warning MSB3191: Unable to create directory "D:\a\1\a\ \p:platform=Release \p:configuration=Release \p:VisualStudioVersion=17.0 \p:_MSDeployUserAgent=VSTS_ac5aa204-3429-4edf-ae3d-777f0b31c141_build_9_0\". The given path's format is not supported."
It appears that the given path's format is not correct. And in your yaml file, you specified the project but not the solution.
Please specify the solution instead of the project, reference below format:
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildConfiguration)'
configuration: '$(buildConfiguration)'
Would like your opinion on how to do this. We have a solution with multiple projects. The solution needs to be deployed in only one website. At the moment, when I build my pipeline, the drop folder contains multiple zip files, one for each project.
This is the YAML for the Build task
- task: VSBuild#1
displayName: 'Build MySolution'
inputs:
solution: '$/MyRepo/Main/MySolution/Mysolution.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
This is my YAML for the Publish task
steps:
- task: PublishBuildArtifacts#1
displayName: 'Publish ChilliDB'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
When I looked at my drop folder, I can see the following zip files
drop
Project 1.zip
Project 2.zip
Project 3.zip
The problem is when I create a Release using IIS website Deployment template, I can only select one zip file from the drop folder to be deployed into the website.
Is it possible that in my pipepline build and publish tasks I will end up with my drop containing something like this:
drop
My solution.zip
And then the My solution.zip will contain folders for each of the project files.
OR can I do something on my Release Pipeline that I can deploy multiple projects zip file into one website.
You may try to extract the project.zip file before publishing the drop. Check the example below:
steps:
- task: VSBuild#1
inputs:
solution: '**\*.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\1"'
- task: ExtractFiles#1
inputs:
archiveFilePatterns: '$(build.artifactstagingdirectory)/1/WebApplication1.zip'
destinationFolder: '$(build.artifactstagingdirectory)/2/WebApplication1'
cleanDestinationFolder: true
overwriteExistingFiles: false
- task: ExtractFiles#1
inputs:
archiveFilePatterns: '$(build.artifactstagingdirectory)/1/WebApplication2.zip'
destinationFolder: '$(build.artifactstagingdirectory)/2/WebApplication2'
cleanDestinationFolder: true
overwriteExistingFiles: false
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/2'
ArtifactName: 'drop'
publishLocation: 'Container'
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.
I'm deployng my net core 2.2 app with azure pipeline
yml:
trigger:
- dev
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller#1
- task: UseDotNet#2
displayName: 'Use dotnet sdk 2.2'
inputs:
version: 2.x
includePreviewVersions: false
- 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)'
# code coverage
- task: DotNetCoreCLI#2
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
- script: dotnet -d ef -v migrations script --output $(Build.ArtifactStagingDirectory)\SQL\$(scriptName) --context $(dbContext) --idempotent --project src\WorkFlowManager.EntityFrameworkCore\WorkFlowManager.EntityFrameworkCore.csproj
- task: PublishBuildArtifacts#1
And now i've added to the solution an azure function project that i want to exclude from the build, because this last project is developed using net core 3.1 .
I'm trying to exclude it from the pipeline with something like that:
variables:
solution: |
'**/*.sln'
'!**/*Project.AzureFunction*.csproj'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
But the build does not works:
Starting: VSBuild
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.166.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
##[error]Solution not found using search pattern ''**\*.sln'
'!**\*WorkFlowManager.Functions.EnelGenerator*.csproj'
'.
Finishing: VSBuild
Any ideas?
To exclude the azure function project from build, you can modify your solution file directly to exclude the azure function project.
For below example NUnitTest2.csproj is commented out in the solution file(.sln), and will be excluded when build the solution. You can also check out this thread for other workarounds.
If you do not want to modify the solution file. You can use DotNetCoreCLI#2 task to build all projects except azure function project like below (use ! to exclude a project) .
- task: DotNetCoreCLI#2
inputs:
command: build
projects: |
**\*.csproj
!**\azurefunction.csproj
The VSBuild#1 task is used for building a VS solution. You could therefore put the new project in a separate solution within the same repository.
Or you could use the DotNetCoreCLI#2 task for your build step that allows you to specify individual projects or a solution to build (see build multiple projects).