Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions d365fo.tools/functions/get-d365model.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ function Get-D365Model {

[string] $BinDir = "$Script:BinDir\bin",

[string] $PackageDirectory = $Script:PackageDirectory
[string] $PackageDirectory = $Script:PackageDirectory,

[string] $MetaDataDir = $Script:MetaDataDir
)

begin {
Expand All @@ -205,6 +207,7 @@ function Get-D365Model {
Write-PSFMessage -Level Verbose -Message "Intializing RuntimeProvider."

$runtimeProviderConfiguration = New-Object Microsoft.Dynamics.AX.Metadata.Storage.Runtime.RuntimeProviderConfiguration -ArgumentList $PackageDirectory
$runtimeProviderConfiguration.AddRootAndIncludes($MetaDataDir, $null)
$metadataProviderFactoryViaRuntime = New-Object Microsoft.Dynamics.AX.Metadata.Storage.MetadataProviderFactory
$metadataProviderViaRuntime = $metadataProviderFactoryViaRuntime.CreateRuntimeProvider($runtimeProviderConfiguration)

Expand All @@ -221,7 +224,7 @@ function Get-D365Model {
Write-PSFMessage -Level Verbose -Message "Machine is onebox. Initializing DiskProvider too."

$diskProviderConfiguration = New-Object Microsoft.Dynamics.AX.Metadata.Storage.DiskProvider.DiskProviderConfiguration
$diskProviderConfiguration.AddMetadataPath($PackageDirectory)
$diskProviderConfiguration.AddMetadataPath($MetaDataDir)
$metadataProviderFactoryViaDisk = New-Object Microsoft.Dynamics.AX.Metadata.Storage.MetadataProviderFactory
$metadataProviderViaDisk = $metadataProviderFactoryViaDisk.CreateDiskProvider($diskProviderConfiguration)

Expand Down
71 changes: 69 additions & 2 deletions d365fo.tools/internal/functions/get-applicationenvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,28 @@ function Get-ApplicationEnvironment {
$AOSPath = Join-Path $script:ServiceDrive "\AOSService\webroot\bin"

Write-PSFMessage -Level Verbose -Message "Testing if we are running on a AOS server or not."
$isUDE = $false
if (-not (Test-Path -Path $AOSPath -PathType Container)) {
Write-PSFMessage -Level Verbose -Message "The machine is NOT an AOS server."

$MRPath = Join-Path $script:ServiceDrive "MRProcessService\MRInstallDirectory\Server\Services"

Write-PSFMessage -Level Verbose -Message "Testing if we are running on a BI / MR server or not."
if (-not (Test-Path -Path $MRPath -PathType Container)) {
Write-PSFMessage -Level Verbose -Message "It seems that you ran this cmdlet on a machine that doesn't have the assemblies needed to obtain system details. Most likely you ran it on a <c='em'>personal workstation / personal computer</c>."
return
Write-PSFMessage -Level Verbose -Message "The machine is NOT a BI/MR server"
$RegSplat = @{
Path = "HKCU:\Software\Microsoft\Dynamics\AX7\Development\Configurations"
Name = "FrameworkDirectory"
}
$frameworkDirectoryRegValue = $( if (Test-RegistryValue @RegSplat) { Get-ItemPropertyValue @RegSplat } else { "" } )
$BasePath = Join-Path $frameworkDirectoryRegValue "bin"
if (-not (Test-Path -Path $BasePath -PathType Container)) {
Write-PSFMessage -Level Verbose -Message "It seems that you ran this cmdlet on a machine that doesn't have the assemblies needed to obtain system details. Most likely you ran it on a <c='em'>personal workstation / personal computer</c>."
return
}
Write-PSFMessage -Level Verbose -Message "The machine is a unified development environment"
$isUDE = $true
$null = $Files2Process.Add((Join-Path $BasePath "Microsoft.Dynamics.AX.Authentication.Instrumentation.dll"))
}
else {
Write-PSFMessage -Level Verbose -Message "The machine is a BI / MR server."
Expand Down Expand Up @@ -59,6 +72,60 @@ function Get-ApplicationEnvironment {

Write-PSFMessage -Level Verbose -Message "All assemblies loaded. Getting environment details."
$environment = [Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory]::GetApplicationEnvironment()
if ($isUDE) {
# In case of unified development environments, the system information returned by the assemblies is lacking.
# In this case, the .NET object gets replaced with a PowerShell object that contains the necessary information.
$environment = Initialize-UnifiedDevelopmentEnvironment -environment $environment
}

$environment
}

function Initialize-UnifiedDevelopmentEnvironment {
[CmdletBinding()]
param (
[Object]
$environment
)

$RegSplat = @{
Path = "HKCU:\Software\Microsoft\Dynamics\AX7\Development\Configurations"
Name = "FrameworkDirectory"
}
$frameworkDirectoryRegValue = $( if (Test-RegistryValue @RegSplat) { Get-ItemPropertyValue @RegSplat } else { "" } )
$RegSplat.Name = "CurrentMetadataConfig"
$metadataConfigFileRegValue = $( if (Test-RegistryValue @RegSplat) { Get-ItemPropertyValue @RegSplat } else { "" } )
$metadataConfig = Get-Content -Path $metadataConfigFileRegValue -Raw | ConvertFrom-Json

$psEnvironment = New-Object -TypeName PSObject -Property @{
Aad = @{
TenantDomainGUID = $environment.Aad.TenantDomainGUID # TODO mapped to $Script.TenantId
}
Aos = @{
AppRoot = $environment.Aos.AppRoot # TODO mapped to $Script.AOSPath; is usually */AOSService/webroot
PackageDirectory = $frameworkDirectoryRegValue # aka the PackagesLocalDirectory
MetadataDirectory = $metadataConfig.ModelStoreFolder # TODO on UDE, this is different from the PackagesLocalDirectory
}
DataAccess = @{
# TODO all values are empty on UDE
DbServer = $environment.DataAccess.DbServer
Database = $environment.DataAccess.Database
SqlUser = $environment.DataAccess.SqlUser
SqlPwd = $environment.DataAccess.SqlPwd
}
Common = @{
BinDir = $frameworkDirectoryRegValue # aka the PackagesLocalDirectory
DevToolsBinDir = $frameworkDirectoryRegValue + '\bin'
IsOneboxEnvironment = $true # TODO check what this controls, maybe $false is better for UDE?
}
Monitoring = @{
MARole = $environment.Monitoring.MARole
}
Infrastructure = @{
HostName = "UnifiedDevelopmentEnvironment" # TODO Ugly solution to identify UDE
HostUrl = $environment.Infrastructure.HostUrl
}
}

$psEnvironment
}
1 change: 1 addition & 0 deletions d365fo.tools/internal/scripts/enums.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
AzureHostedTier1
MSHostedTier1
MSHostedTier2
UnifiedDevelopmentEnvironment
}

enum ServerRole {
Expand Down
3 changes: 3 additions & 0 deletions d365fo.tools/internal/scripts/variables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ elseif ($infrastructure.HostName -like "*sandbox.ax.dynamics.com*") {
elseif ($infrastructure.HostName -like "*sandbox.operations.*dynamics.com*") {
$Script:EnvironmentType = [EnvironmentType]::MSHostedTier2
}
elseif ($environment.Infrastructure.HostName -eq "UnifiedDevelopmentEnvironment") {
$Script:EnvironmentType = [EnvironmentType]::UnifiedDevelopmentEnvironment
}
$Script:Url = $infrastructure.HostUrl

$Script:Company = "DAT"
Expand Down
Loading