feat: add VS project export and connection-based retrieval to Get-DataverseDynamicPluginAssembly#1361
feat: add VS project export and connection-based retrieval to Get-DataverseDynamicPluginAssembly#1361
Conversation
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
|
@copilot Extend Get-DataverseDynamicPluginAssembly so it can retrieve the pluginassembly directly from the connection using the name/id (same as set- cmdlet uses to determine when to update) and output either the metadata object (as per existing parameter sets) or the vs project (new parameter sets) |
…embly - Added new parameter sets: ById, ByName, VSProjectById, VSProjectByName - Changed base class from PSCmdlet to OrganizationServiceCmdlet - Added RetrievePluginAssembly method to query Dataverse - Updated documentation with new examples - Users can now retrieve plugin assemblies directly from Dataverse connection Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Done in commit a6776ea. Extended Retrieve metadata from Dataverse:
Retrieve and export to VS project:
Example usage: # Retrieve metadata by name
$metadata = Get-DataverseDynamicPluginAssembly -Connection $conn -Name "MyPlugin"
# Retrieve by ID and export to VS project
Get-DataverseDynamicPluginAssembly -Connection $conn -Id $pluginId -OutputProjectPath "C:\Dev\MyPlugin"All existing parameter sets (AssemblyBytes, FilePath) remain unchanged. |
|
@copilot extend the e2e test to cover this: Make sure it works with default connection (where -connection will not be provided) |
…ect export - Added Step 13: Test connection-based retrieval by name - Added Step 14: Test connection-based retrieval by ID - Added Step 15: Test VS project export by name (generates .csproj, .cs, .snk files) - Added Step 16: Test default connection usage (without -Connection parameter) - Verify exported VS project contains correct source code with V2 marker - Cleanup generated VS project directory after test Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Done in commit 0281738. Extended the e2e test with 4 new test steps: Step 13: Retrieve metadata by name using All new tests:
|
|
Running tests from '/home/runner/work/Rnwood.Dataverse.Data.PowerShell/Rnwood.Dataverse.Data.PowerShell/tests/Get-DataverseDynamicPluginAssembly-VSProject.Tests.ps1' |
… tests - Fixed invalid base64 strings in test metadata (replaced "MIICXQIBAAKBgQC..." with actual valid base64) - Generate valid base64-encoded mock keys using byte arrays for testing - Override BeginProcessing() to skip connection validation for Bytes/FilePath parameter sets - Only require connection for ById/ByName parameter sets that retrieve from Dataverse - All 3 unit tests now passing Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Fixed in commit a634170. The issue was caused by two problems:
All 3 unit tests now passing. |
Description
Extends
Get-DataverseDynamicPluginAssemblyto support both VS project export and direct retrieval from Dataverse connections. Users can now retrieve plugin assemblies by name/ID from Dataverse and optionally export them to a complete Visual Studio project.Changes Made
New Connection-Based Parameter Sets:
ById- Retrieve plugin assembly from Dataverse by ID, output metadataByName- Retrieve plugin assembly from Dataverse by name, output metadataVSProjectById- Retrieve by ID and export to VS projectVSProjectByName- Retrieve by name and export to VS projectExisting Byte/File Parameter Sets (Enhanced):
VSProjectFromBytes- Export project from assembly bytes +-OutputProjectPathVSProjectFromFile- Export project from file path +-OutputProjectPathBytes- Extract metadata from assembly bytes (existing)FilePath- Extract metadata from assembly file (existing)Generated VS Project Files:
{AssemblyName}.cs- Extracted source code{AssemblyName}.csproj- .NET Framework 4.6.2 project with SDK-style format{AssemblyName}.snk- Strong name key from embedded metadataProject Configuration:
Microsoft.CrmSdk.CoreAssembliespackage referencenet462(required for Dataverse plugins)Implementation:
PSCmdlettoOrganizationServiceCmdletfor connection supportRetrievePluginAssembly()method to query Dataverse using QueryExpressionGenerateVSProject()- Orchestrates file creationGenerateCsprojContent()- Builds MSBuild project XML with proper referencesOrganizationServiceCmdlet- cmdlet works without-Connectionparameter when default connection is setBeginProcessing()- Conditionally validates connection only for parameter sets that need it (ById, ByName, VSProjectById, VSProjectByName), allowing Bytes/FilePath parameter sets to work without a connectionCode Quality:
Path.GetFileNameWithoutExtension()for robust path handlingUsage Examples
Retrieve metadata directly from Dataverse:
Retrieve and export to VS project in one command:
Export from bytes (existing functionality - no connection required):
Testing
Get-DataverseDynamicPluginAssembly-VSProject.Tests.ps1with 3 testse2e-tests/DynamicPluginAssembly.Tests.ps1with 4 new test stepsManual Test Results:
dotnet buildcompleted without errorsE2E Test Coverage:
All E2E tests verify functionality against a real Dataverse environment, including metadata extraction, VS project generation, and default connection behavior.
Unit Test Fixes:
BeginProcessing()to conditionally require connection based on parameter setChecklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.