Package Deployer Extension library
$ dotnet add package BeerLike.PackageDeployer[!WARNING] This project is still in development. Use at your own risk in production environments.
A .NET library that provides custom extensions for Power Platform Package Deployer projects.
Currently, the library provides the following features:
Install the NuGet package in your Package Deployer project:
dotnet add package BeerLike.PackageDeployer
Or just add the package reference to your Package Deployer project>
<PackageReference Include="BeerLike.PackageDeployer" Version="0.0.*" />
Change your package class to inherit from BeerLike.PackageDeployer.PackageExtension instead of the default ImportExtension. The custom PackageExtension class inherits from ImportExtension so we don't lose any of the default functionality.
using BeerLike.PackageDeployer;
namespace YourNamespace;
public class PackageImportExtension : PackageExtension
{
...
}
Add the following properties and target to your package deployer .csproj file to enable build-time JSON validation and auto-initialization:
<!-- Configure paths for BeerLike.PackageDeployer JSON validation/initialization -->
<PropertyGroup>
<TeamRolesConfig>$(MSBuildProjectDirectory)\PkgAssets\TeamRoles.json</TeamRolesConfig>
<TeamCspsConfig>$(MSBuildProjectDirectory)\PkgAssets\TeamCsps.json</TeamCspsConfig>
</PropertyGroup>
<!-- Runs JSON validation/initialization before build -->
<Target Name="InitializePackageConfigs" BeforeTargets="Build" DependsOnTargets="ValidatePackageConfigs" />
The properties define the paths to the JSON configuration files.
The target runs a task that either creates the config files if they don't exist in given paths (specified by the props) or validates them againts the JSON schemas.
Feel free to change the paths to the JSON configuration files to your liking but make sure to they are contained in the your package assets folder (default is PkgAssets).
If you set the props and targets as described above, build the package deployer project locally once and the config files will be created in the given paths.
If you skipped the step 2, create manually json files in the package assets folder (default is PkgAssets).
If you completed the step 2, the config files already exist.
Set your declarative configuration as in the examples in Configuration.
To execute the custom tasks, invoke them in the appropriate stage of the package import process.
public override void AfterPrimaryImport()
{
//GetImportPackageDataFolderName is a property of the default ImportExtension class
SyncTeamRoles(GetImportPackageDataFolderName + "/TeamRoles.json");
SyncTeamCsps(GetImportPackageDataFolderName + "/TeamCsps.json");
return true;
}
TeamRoles.json)Assign security roles to teams declaratively:
[
{
"team": "Sales Team",
"removeUnassigned": false,
"securityRoles": [
"00000000-0000-0000-0000-000000000001",
"00000000-0000-0000-0000-000000000002"
]
},
{
"team": "00000000-0000-0000-0000-000000000003",
"removeUnassigned": true,
"securityRoles": [
"00000000-0000-0000-0000-000000000004"
]
}
]
| Property | Type | Required | Description |
|---|---|---|---|
team | string | Yes | Team identifier — can be the team name or team ID (GUID) |
securityRoles | string[] | Yes | Array of security role IDs (GUIDs) to assign |
removeUnassigned | boolean | No | If true, removes any security roles from the team that are not in the securityRoles array. Default: false |
TeamCsps.json)Assign column security profiles (field-level security) to teams:
[
{
"team": "Sales Team",
"removeUnassigned": false,
"columnSecurityProfiles": [
"00000000-0000-0000-0000-000000000001",
"00000000-0000-0000-0000-000000000002"
]
}
]
| Property | Type | Required | Description |
|---|---|---|---|
team | string | Yes | Team identifier — can be the team name or team ID (GUID) |
columnSecurityProfiles | string[] | Yes | Array of column security profile IDs (GUIDs) to assign |
removeUnassigned | boolean | No | If true, removes any column security profiles from the team that are not in the columnSecurityProfiles array. Default: false |
This project is licensed under the MIT License - see the LICENSE file for details.