Skip to content

Commit

Permalink
Merge pull request #20 from rnwood/rnwood-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rnwood authored Dec 11, 2024
2 parents 76e84a1 + 48682dc commit edcf812
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,6 @@ public GetDataverseConnectionCmdlet()
{
}

static GetDataverseConnectionCmdlet()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}

private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

string assyName = args.Name.Split(',')[0];
string assyFile = assyDir + "/" + assyName + ".dll";

if (File.Exists(assyFile))
{
return Assembly.LoadFrom(assyFile);
}

return null;
}

private const string PARAMSET_CLIENTSECRET = "Authenticate with client secret";
private const string PARAMSET_INTERACTIVE = "Authenticate interactively";
private const string PARAMSET_DEVICECODE = "Authenticate using the device code flow";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Provider;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Rnwood.Dataverse.Data.PowerShell.FrameworkSpecific.Commands
{
[CmdletProvider("Dataverse", ProviderCapabilities.None)]
public class ModuleInitProvider : DriveCmdletProvider
{
protected override Collection<PSDriveInfo> InitializeDefaultDrives()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

var assy = Assembly.Load(new AssemblyName("Microsoft.Xrm.Sdk"));
WriteVerbose($"Loaded Dataverse SDK from {assy.Location}");

return base.InitializeDefaultDrives();
}

private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

string assyName = args.Name.Split(',')[0];
string assyFile = assyDir + "/" + assyName + ".dll";

if (File.Exists(assyFile))
{
return Assembly.LoadFrom(assyFile);
}

return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
</Target>

<Target Name="BuildHelp" DependsOnTargets="BuildFrameworkSpecifics" AfterTargets="Build">
<Message Text="Building help to $(TargetDir)" Importance="high"/>
<Message Text='pwsh -file "$(ProjectDir)updatehelp.ps1" -projectdir "$(ProjectDir.TrimEnd("\\"))" -outdir "$(TargetDir.TrimEnd("\\"))"' Importance="high"/>
<Exec Command='pwsh -file "$(ProjectDir)updatehelp.ps1" -projectdir "$(ProjectDir.TrimEnd("\\"))" -outdir "$(TargetDir.TrimEnd("\\"))"' />
<Message Text='pwsh -file "$(ProjectDir)build.ps1" -projectdir "$(ProjectDir.TrimEnd("\\"))" -outdir "$(TargetDir.TrimEnd("\\"))"' Importance="high"/>
<Message Text="Building help to $(TargetDir)" Importance="high" />
<Message Text="pwsh -file &quot;$(ProjectDir)updatehelp.ps1&quot; -projectdir &quot;$(ProjectDir.TrimEnd(&quot;\\&quot;))&quot; -outdir &quot;$(TargetDir.TrimEnd(&quot;\\&quot;))&quot;" Importance="high" />
<Exec Command="pwsh -file &quot;$(ProjectDir)updatehelp.ps1&quot; -projectdir &quot;$(ProjectDir.TrimEnd(&quot;\\&quot;))&quot; -outdir &quot;$(TargetDir.TrimEnd(&quot;\\&quot;))&quot;" />
<Message Text="pwsh -file &quot;$(ProjectDir)build.ps1&quot; -projectdir &quot;$(ProjectDir.TrimEnd(&quot;\\&quot;))&quot; -outdir &quot;$(TargetDir.TrimEnd(&quot;\\&quot;))&quot;" Importance="high" />

<Exec Command='pwsh -file "$(ProjectDir)buildhelp.ps1" -projectdir "$(ProjectDir.TrimEnd("\\"))" -outdir "$(TargetDir.TrimEnd("\\"))"' />
<Exec Command="pwsh -file &quot;$(ProjectDir)buildhelp.ps1&quot; -projectdir &quot;$(ProjectDir.TrimEnd(&quot;\\&quot;))&quot; -outdir &quot;$(TargetDir.TrimEnd(&quot;\\&quot;))&quot;" />
</Target>

</Project>
Binary file not shown.
18 changes: 17 additions & 1 deletion Rnwood.Dataverse.Data.PowerShell/docs/Remove-DataverseRecord.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Deletes an existing Dataverse record.
```
Remove-DataverseRecord -Connection <ServiceClient> [-InputObject <PSObject>] -TableName <String> -Id <Guid>
[-BatchSize <UInt32>] [-IfExists] [-BypassBusinessLogicExecution <BusinessLogicTypes[]>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-BypassBusinessLogicExecutionStepIds <Guid[]>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -194,6 +195,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -BypassBusinessLogicExecutionStepIds
Specifies the IDs of plugin steps to bypass
```yaml
Type: Guid[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
18 changes: 17 additions & 1 deletion Rnwood.Dataverse.Data.PowerShell/docs/Set-DataverseRecord.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Set-DataverseRecord -Connection <ServiceClient> -InputObject <PSObject> [-BatchS
-TableName <String> [-IgnoreProperties <String[]>] [-Id <Guid>] [-MatchOn <String[][]>] [-PassThru]
[-NoUpdate] [-NoCreate] [-NoUpdateColumns <String[]>] [-CallerId <Guid>] [-UpdateAllColumns] [-CreateOnly]
[-Upsert] [-LookupColumns <Hashtable>] [-BypassBusinessLogicExecution <BusinessLogicTypes[]>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-BypassBusinessLogicExecutionStepIds <Guid[]>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -379,6 +380,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -BypassBusinessLogicExecutionStepIds
Specifies the IDs of plugin steps to bypass
```yaml
Type: Guid[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
1 change: 0 additions & 1 deletion tests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ BeforeAll {
}

Add-Type -AssemblyName "System.Runtime.Serialization"
Add-Type -AssemblyName "Microsoft.Xrm.Sdk"

# Define the DataContractSerializer
$serializer = New-Object System.Runtime.Serialization.DataContractSerializer([Microsoft.Xrm.Sdk.Metadata.EntityMetadata])
Expand Down

0 comments on commit edcf812

Please sign in to comment.