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).
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)'
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.
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 using abp (Aspnet boilerplate) with net core 2.2.0 .
The backend run without problems in local and also in Azure with the D1 plane.
But if i change plane to B1 or higher, it shows this error:
Why? The code is the same. i ve changed only the subscription plane. There are many similar questions online but no answer solves my problem.
EDIT
If I pusblish from Visual Studio it works but if i publish through Continuous integration (through the azure pipelines) the problem returns
My 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 test <test-project> --logger trx --collect "Code coverage"
# - task: PublishTestResults#2
# inputs:
# testRunner: VSTest
# testResultsFiles: '**/*.trx'
- 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