Muokkaa

Jaa


Use the .artifactignore file

Azure DevOps Services

The artifactignore file works similarly to a gitignore file but serves a different purpose. Instead of specifying files to be ignored by Git, it's used in Azure Pipelines to control which files are excluded when publishing pipeline artifacts or Universal Packages. This file can help reduce your pipeline execution and improve its efficiency by preventing unnecessary files from being copied into the staging directory before publishing.

The artifactignore file has a similar syntax to that of a gitignore file and is typically stored in your version control system. However, unlike gitignore, the artifactignore file doesn't always need to be in the root of your repository. Its location depends on the path specified in the publish task. If placed incorrectly, the task won't recognize it, leading to unintended results. For example, if the path is $(System.DefaultWorkingDirectory)/bin/artifacts, the artifactignore file should be placed in the /bin/artifacts directory.

Note

The artifactignore file does not work with the Publish Build Artifacts task, use the Publish Pipeline Artifacts task instead.

Syntax

The .artifactignore follows the same syntax as the .gitignore with a few exceptions. The plus sign character + is not supported in URL paths, and certain package types, such as Maven, may have limitations with semantic versioning metadata.

Note

By default, the .gitignore file is ignored unless you have an .artifactignore file. To include it, simply create an empty .artifactignore file.

Example

In this example, all files will be ignored except for those located in the src/MyApp/bin/Release directory.

**/*
!src/MyApp/bin/Release/**.*

Important

The .artifactignore file must be placed in the directory specified in the targetPath argument in your Publish Pipeline Artifacts task.