Appearance
Plugins
Project Config (Classic)
.csproj file structure
csharp
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>AccountPlugins.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.56" />
</ItemGroup>
</Project>Signing
Execute the following command on the terminal sn -k <project-name>.snk
Example: sn -k AccountPlugins.snk
Then in Visual Studio open the project's properties and navigate to Build > Strong Naming
- ☑ Sign the assembly
- In the Strong name key file Box ...Browse and select the key you created in the previous step
- You can also add the following line to the .csproj file
<AssemblyOriginatorKeyFile>AccountPlugins.snk</AssemblyOriginatorKeyFile>
Nuget Project Config
Signed assemblies are not required
.csproj file structure
csharp
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<FileVersion>1.0.$([System.DateTime]::UtcNow.ToString("yyyy.MMdd"))</FileVersion>
</PropertyGroup>
<PropertyGroup>
<PackageId>$(MSBuildProjectName)</PackageId>
<Version>$(FileVersion)</Version>
<Authors>Rotem</Authors>
<Company>Rotem Dynamics</Company>
<Description>This is a sample nuget package which contains a Dataverse plugin and its runtime dependencies like Newtonsoft.Json</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.*" PrivateAssets="All" />
<PackageReference Include="Microsoft.PowerApps.MSBuild.Plugin" Version="1.*" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.*" PrivateAssets="All" />
</ItemGroup>
<Target Name="Rename-Package" AfterTargets="Pack">
<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFiles="$(OutputPath)..\$(PackageId).latest.nupkg" />
<Delete Files="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" />
<Message Text="Renamed PackageFile" Importance="high" />
</Target>
</Project>Folder Structure
Plugins/
├─ Rotem.AccountPlugins/
│ ├─ PreValidationCreate.cs
│ ├─ PreCreate.cs
│ ├─ PostCreate.cs
│ ├─ PreUpdate.cs
│ ├─ PostUpdate.cs
│ ├─ AsyncUpdate.cs
├─ Rotem.ContactPlugins/
│ ├─ PreCreate.cs
│ ├─ PreUpdate.cs
│ ├─ PostUpdate.cs
├─ Rotem.LeadPlugins/
│ ├─ PostUpdate.csFolder Structure Rules
- The assembly name is the name of the entity + Plugins
<project>.<entity>Plugins - Each (step,message) couple is getting its owns class
<stage><message>.cs
Context Validation
The plugins MUST implement some kind of context validation to make sure the plugin is running in the expected context.
Context details to verify:
- Step
- Entity
- Message
General Rules
Note
All the Server Side General Rules applies here
- Don't update the
Targetentity in an Update step to avoid infinite-loop. if you want to update the target do so by changing the target attributes in the pre-update stage.