Tuesday, November 19, 2024
How to Keep Your Repositories Clean: Folder Structure Tips for Dynamics 365 FO Projects
Posted by
Introduction
When working with Dynamics 365 for Finance and Operations, maintaining a consistent folder structure is critical for efficient collaboration and scalability. A well-structured repository not only improves team productivity but also minimizes the risk of errors caused by misplaced files. In this post, I’ll walk you through an example folder structure and demonstrate how to enforce it using Azure DevOps File Path Validation policies.
Example Folder Structure for Dynamics 365 FO Projects
A clear folder structure is a foundation for effective version control, especially when working in a multi-developer environment.
- App/SourceCode
- App/BinaryOnly
- Pipeline
- Solution
- .gitignore
- README.md
Folder Explanations
Name | Description |
---|---|
App/SourceCode | Contains all source code specific to modules, including customizations and extensions. |
App/BinaryOnly | Modules provided as binary-only packages, such as ISV solutions or third-party code. |
Pipeline | YAML definitions for CI/CD pipelines and other automation processes. |
Solution | Visual Studio solution and project files. |
.gitignore | Specifies paths and files to exclude from version control. |
README.md | Provides an overview of the repository structure and its purpose. |
Why Enforce Folder Structure?
Even with guidelines, manual enforcement is prone to errors, especially in larger teams. By enforcing folder structure with Azure DevOps policies, you ensure consistency across contributions. This approach eliminates misplaced files and maintains repository hygiene without constant oversight.
Setting Up File Path Validation in Azure DevOps
Azure DevOps offers a built-in File Path Validation policy to prevent undesired file paths. Here’s how to configure it:
Navigate to your Azure DevOps project and go to Project Settings.
Select Repos > Repositories.
Choose the repository you want to configure.
Go to Policies > File path validation.
Enter the blocked file paths in the following format
/*
to block all files by default.- Add exceptions for allowed folders using paths prefixed with
!
. - Separate multiple paths using
;
.
Example Configuration
To enforce the example folder structure above, use the following policy:
/*;!/App/SourceCode/*;!/App/BinaryOnly/*;!/Pipeline/*;!/Solution/*;!/.gitignore;!/README.md
Real-World Example
Let’s say a developer accidentally tries to add a new file directly to the root directory of the repository. With the above configuration, Azure DevOps will block the push and provide a clear error message indicating the invalid path. This safeguard helps prevent mistakes and ensures adherence to the agreed structure.