Azure CI pipeline ignored my botdetect.xml file - azure

I am using Azure CI pipeline and using the .NetCore build tasks template, today I noticed that the file botdetect.xml in my source control, and after project passes from CI/CD pipeline, specific .xml

dotnet publish command publish the output of your .NET build, you need to make sure the botdetect.xml file exists in your build output, then it can be published to $(Build.ArtifactStagingDirectory) by running dotnet publish --output $(Build.ArtifactStagingDirectory), and publish the artifact by using Publish artifact task.
You could check your .csproj file to see whether the .xml file has been set to "Always Copy To Output Directory", it seems like:
<Compile Include="botdetect.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>

Related

Where to save a reusable static jar to be used from an Azure DevOps pipeline?

I have an Azure DevOps pipeline
The pipeline has a "command line" task that runs a java command on a jar file
The jar file is a static one that represents a tool to be used in the build process.
The jar file is not created as part of the build pipeline. It's just a jar with one version and it doesn't change with each build
Where is the best place to save this jar file and how to download it to the agent during the build pipeline execution ?
Since the jar file is static one and not created as part of the build pipeline, you can save the jar file to Azure Artifacts Feed -> Universal Package.
To upload the jar file to Azure Artifacts Universal Package, you can use Universal Packages Task - Publish command in Pipeline or Azure CLI command: az artifacts universal publish (work in pipeline or local machine).
Then you can use the task: Universal Packages Task - Download command to download the Universal Package during the build pipeline execution.

Compile directory in Azure DevOps Repos and save the results somewhere

Let’s say I have a directory structure like this in an Azure DevOps repo:
Main/
- A/
- *.csproj
- B/
- *.csproj
- C/
- *.csproj
Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild#1 task, or do I need to use some other Azure task?
How do I tell Azure to build that precise Main/A/*.csproj file and do
I need to use /p:OutputPath inside the VSBuild#1 task
If you're using classic UI, you need to unlink the default solution:
And then choose the A project by the browse option:
If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.
Note:
Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.
If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.
In addition:
1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:
Copy Files Task.
Publish Build Artifacts
Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.
Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.
Hope all above helps :)

Azure deployment from Azure DevOps failing to find zip package

I am setting up a build and release pipeline for our Azure mobile app using Azure DevOps. I have completed the build and all works fine. I have a build task defined that creates the required zip file for deploying to Azure and this succeeds and the zip file is created at the root of the folder. But the deployment fails stating that the zip file cannot be found.
Here is my build task that creates the zip file.
And here is the output from the build step showing that it has successfully created the zip file.
But the deployment fails as it can't find the zip file.
You need to publish the .zip file from your build using the Publish Build Artifacts task. That will make it available as an artifact to be linked into a release definition to be deployed.

No packages found with specified pattern

I am using Deploy azure app service to slot build step in Team Services, I want to be able to build my solution with PackageAsSingleFile set to False. However when I try to release the package with path to the artifact created I get "No packages found with specified pattern".
Do I need to create two artifacts, one as zip file and one as a package of files to be able to do what I want? I have tried different path to folders, but I get same error no matter.
Refer to these steps:
NuGet Installer task to restore package
Visual Studio Build task (Solution: ***.sln; Visual Studio Version: Visual Studio 2015; MSBuild Arguments: /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="$(build.artifactstagingdirectory)\"; Platform: $(BuildPlatform); Configuration: $(BuildConfiguration))
Publish Build Artifacts (Path to Publish: $(build.artifactstagingdirectory); Artifact Name: drop; Artifact Type: Server)
Edit/create Release definition
Link artifact to previous build
Azure App Service Deploy (Package or Folder: $(System.DefaultWorkingDirectory)/**/drop)
Uncheck Publish using Web Deploy option
I used zip file, and Azure App Services Deploy task can be execute successfully.
For the related build definition, you can use below tasks:
Copy Files task:
Source Folder: $(Build.SourcesDirectory).
Contents: the project you want to deploy to Azure, such as ASPNETCoreProj\**.
Target Folder: $(Build.ArtifactStagingDirectory).
Archive Files task:
Root folder (or file) to archive: $(Build.ArtifactStagingDirectory).
Archive type: zip.
Archive file to create: $(Build.ArtifactStagingDirectory)/project.zip.
Publish Build Artifacts task:
Path to Publish: $(Build.ArtifactStagingDirectory).
Artifact Name: drop.
In the release definition, you can specify Package or folder as $(System.DefaultWorkingDirectory)\**\*.zip in Azure App Services Deploy task.

How can I have teamcity run a .bat file on each successful build?

I have a teamcity (4.something) install that creates .wsp file for deployment to sharepoint. Currently I have to copy the wsp out of the build artifacts directory and into a little deploy folder I have created. In the folder I run a .bat that deploys the new .wsp to our test server.
What steps can I take to automate this?
Either copy the .bat into the artifacts folder and update the paths etc or copy from the artifacts folder into the 'deploy' folder and run the .bat from there.
I am a neophyte when it comes to the intricacies (or basics!) of MSBuild and the like... so hand holding is appreciated!
In more recent versions of TeamCity...
In the build definition you can identify artifacts which can be copied/zipped. Artifacts can then be downloaded manually or referenced from another build (Artifact Dependency).
You can setup a 'build configuration' to do your deployment directly from artifacts produced by your ci build.
Create a build to do your deployment
Build Step
Run: Executable with parameters
Command executable: .bat file (make sure it as part of the ci build artifacts generated)
Command parameters: whatever parameters your patch files needs
Dependencies
Add New Artifact dependency
Depend on: select the ci build you want to deploy
GetArtifacts from: Last successful build
Artifact rules: +:**/*.*
So, given artifacts (like your batch file) are in the CI build... You now have a 'deploy' build. When you run it (manually or setup a Build Trigger) it will copy all the CI build artifacts to it's working directory (Artifact Dependency) and then run your batch file to do the deployment.
Pretty slick.
note: just make sure that the account running the TeamCity BuildAgent has permissions to do all the deployment stuff.
Hope this helps somebody as it took me a while to sort this out ;)
I've done this by creating a nant task, and then having TeamCity execute the nant task. It's more of a pain than it should be. You should be able to do the same as a post-build event with MSBuild.

Resources