Skip to content
Merged
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
204 changes: 184 additions & 20 deletions d365fo.tools/bin/d365fo.tools-index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion d365fo.tools/functions/get-d365environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

.PARAMETER DMF
Instruct the cmdlet query the DMF service

.PARAMETER DocumentRouting
Instruct the cmdlet query the document routing service

Expand Down
2 changes: 1 addition & 1 deletion d365fo.tools/functions/get-d365tfsworkspace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ function Get-D365TfsWorkspace {
Write-PSFMessage -Level Host -Message "No matching workspace configuration found for the specified URI. Either the URI is wrong or you haven't configured the server connection / workspace details correctly."
}
}
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/functions/import-d365bacpac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,4 @@ function Import-D365Bacpac {
}

Invoke-TimeSignal -End
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/functions/invoke-d365azcopytransfer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ function Invoke-D365AzCopyTransfer {

Invoke-TimeSignal -End
}
}
}
60 changes: 30 additions & 30 deletions d365fo.tools/functions/invoke-d365modulebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,82 @@
<#
.SYNOPSIS
Build a package / module (X++ compile + labels, reports optional)

.DESCRIPTION
Build a package / module using the builtin "xppc.exe" executable to compile source code and "labelc.exe" to compile label files

Specify -IncludeReports to also compile reports using "ReportsC.exe"

Returns a result object per module and writes the compiler errors to the console when a module fails

Exits with a terminating error when any module fails

.PARAMETER Module
The package to build

.PARAMETER OutputDir
The path to the folder to save assemblies

.PARAMETER LogPath
Path where you want to store the log outputs generated from the compiler

Also used as the path where the log file(s) will be saved

When running without the ShowOriginalProgress parameter, the log files will be the standard output and the error output from the underlying tool executed

.PARAMETER MetaDataDir
The path to the meta data directory for the environment

.PARAMETER ReferenceDir
The full path of one or more folders containing all assemblies referenced from X++ code

Accepts multiple folders, one "-referencefolder" argument is passed to the compiler per folder

Default path is the same as the aos service PackagesLocalDirectory

.PARAMETER BinDir
The path to the bin directory for the environment

Default path is the same as the aos service PackagesLocalDirectory\bin

.PARAMETER IncludeReports
Instruct the cmdlet to also compile the reports of the module using "ReportsC.exe"

Default is $false which will skip the reports compile

.PARAMETER ShowOriginalProgress
Instruct the cmdlet to show the standard output in the console

Default is $false which will silence the standard output

.PARAMETER OutputCommandOnly
Instruct the cmdlet to only output the command that you would have to execute by hand

Will include full path to the executable and the needed parameters based on your selection

.PARAMETER Verbosity
Controls how much output is written to the console

None only outputs when there are errors. Minimal always returns the result object, with the compiler errors on failure. Detailed streams the live compiler output. Default is None

.EXAMPLE
PS C:\> Invoke-D365ModuleBuild -Module Essence-Temp

This will use the default paths and start the xppc.exe with the needed parameters to compile the Essence-Temp package.
When the X++ compile succeeds it will start the labelc.exe to compile the labels.
The build result is returned as an object.
If the build fails, the compiler errors are written to the console.
The default output from all the different steps will be silenced.

.EXAMPLE
PS C:\> Invoke-D365ModuleBuild -Module Essence-Temp -IncludeReports -ShowOriginalProgress

This will compile X++, labels and reports for the Essence-Temp package.
The output from the different steps will be written to the console / host.

.NOTES
Tags: Compile, Model, Servicing, Build, X++

Author: Mötz Jensen (@Splaxi)
#>

Expand Down Expand Up @@ -397,4 +397,4 @@ function Invoke-D365ModuleBuild {

Invoke-TimeSignal -End
}
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/functions/new-d365bacpac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,4 @@ function New-D365Bacpac {
}

Invoke-TimeSignal -End
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/functions/repair-d365bacpacmodelfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,4 @@ function Repair-D365BacpacModelFile {

Invoke-TimeSignal -End
}
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/functions/restart-d365environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

.PARAMETER DMF
Instructs the cmdlet to work against the DMF service

.PARAMETER DocumentRouting
Instructs the cmdlet to work against the Document Routing service

Expand Down
42 changes: 29 additions & 13 deletions d365fo.tools/functions/set-d365webservertype.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"IIS"
"IISExpress"

.PARAMETER Confirm
Switch parameter to require confirmation before making changes.

.PARAMETER WhatIf
Switch parameter to show what would happen if the cmdlet runs, without making any changes.

.PARAMETER Force
Switch parameter to force the operation without confirmation.

Comment on lines +21 to +29

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would "hate" that we would have to have documentation for all 3 standard parameter, across all cmdlets.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FH-Inway - If we could settle without these, at least over time - then I'm happy.

We'll have to face what operations / actions should be medium or high - so people can accept things, without having to manage Confirm.

If we start with low - then all people will have non-breaking changes, while you can set "low" on your profile and you will be prompted.

Then over time, we can gradually promote different functions / cmdlets, to different levels.

.EXAMPLE
PS C:\> Set-D365WebServerType -RuntimeHostType "IIS"

Expand All @@ -30,20 +39,25 @@
Tag: Web Server, IIS, IIS Express, Development

Author: Sander Holvoet (@smholvoet)

Author: Mötz Jensen (@Splaxi)
Author: Florian Hopfner (@FH-Inway)
#>

function Set-D365WebServerType {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
[CmdletBinding()]
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')]
param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ValueFromPipeline = $true)]
[ValidateSet('IIS', 'IISExpress')]
[string] $RuntimeHostType
[string] $RuntimeHostType,

[switch] $Force
)

begin {
if ($Force -and -not $PSBoundParameters.ContainsKey('Confirm')) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we have this discussion once? That contains would fire if -Confirm:$false?

We should be able to have it be simpler with $Confirm

I'm not entirely sure

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Splaxi
I was following the guidance in ShouldProcess on that. -Confirm:$false would be the one of the intended ways to override the confirmation behavior, the other would be changing the $ConfirmPreference. But since users are more familiar with the -Force parameter, they tend to use that in an attempt to get rid of confirmations. This basically makes it so that -Force works like -Confirm:$false. I think this works in this case because -Force is not used to control other behavior.

In any case, since the ConfirmImpact is set to 'Low', most users will never run into unwanted confirmations. Either you set $ConfirmPreference to 'Low' before running the command (which means you seem to know what you are doing) or you are using the -Confirm switch (out of curiosity or because you know what you are doing).

$ConfirmPreference = 'None'
}

if (-not ($script:IsAdminRuntime)) {
Write-PSFMessage -Level Host -Message "The cmdlet needs <c='em'>administrator permission</c> (Run As Administrator) to be able to update the configuration. Please start an <c='em'>elevated</c> session and run the cmdlet again."
Stop-PSFFunction -Message "Stopping because the function is not run elevated"
Expand All @@ -58,20 +72,22 @@ function Set-D365WebServerType {
process {
if (Test-PSFFunctionInterrupt) { return }

$filePathBackup = $filePath.Replace(".xml", ".xml$((Get-Date).Ticks)")
Copy-Item -Path $filePath -Destination $filePathBackup -Force
if ($PSCmdlet.ShouldProcess($filePath, "Set web server type to '$RuntimeHostType'")) {
$filePathBackup = $filePath.Replace(".xml", ".xml$((Get-Date).Ticks)")
Copy-Item -Path $filePath -Destination $filePathBackup -Force

$namespace = @{ns = "http://schemas.microsoft.com/dynamics/2012/03/development/configuration" }
$namespace = @{ns = "http://schemas.microsoft.com/dynamics/2012/03/development/configuration" }

$xmlDoc = [xml] (Get-Content -Path $filePath)
$runtimeHostType = Select-Xml -Xml $xmlDoc -XPath "/ns:DynamicsDevConfig/ns:RuntimeHostType" -Namespace $namespace
$xmlDoc = [xml] (Get-Content -Path $filePath)
$runtimeHostTypeNode = Select-Xml -Xml $xmlDoc -XPath "/ns:DynamicsDevConfig/ns:RuntimeHostType" -Namespace $namespace

$oldValue = $runtimeHostType.Node.InnerText
$oldValue = $runtimeHostTypeNode.Node.InnerText

Write-PSFMessage -Level Verbose -Message "Old value found in the file was: $oldValue" -Target $oldValue
Write-PSFMessage -Level Verbose -Message "Old value found in the file was: $oldValue" -Target $oldValue

$runtimeHostType.Node.InnerText = $RuntimeHostType
$xmlDoc.Save($filePath)
$runtimeHostTypeNode.Node.InnerText = $RuntimeHostType
$xmlDoc.Save($filePath)
}
}

end {
Expand Down
2 changes: 1 addition & 1 deletion d365fo.tools/functions/start-d365environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

.PARAMETER DMF
Start the Data Management Framework service

.PARAMETER DocumentRouting
Start the Document Routing service

Expand Down
2 changes: 1 addition & 1 deletion d365fo.tools/functions/start-d365environmentv2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

.PARAMETER DMF
Start the Data Management Framework service

.PARAMETER DocumentRouting
Start the Document Routing service

Expand Down
2 changes: 1 addition & 1 deletion d365fo.tools/functions/stop-d365environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

.PARAMETER DMF
Start the Data Management Framework service

.PARAMETER DocumentRouting
Stop the Document Routing service

Expand Down
2 changes: 1 addition & 1 deletion d365fo.tools/internal/functions/get-servicelist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

.PARAMETER DMF
Switch to instruct the cmdlet to output the data management service name

.PARAMETER DocumentRouting
Switch to instruct the cmdlet to output the document routing service name

Expand Down
26 changes: 13 additions & 13 deletions d365fo.tools/internal/functions/invoke-buildtool.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@
<#
.SYNOPSIS
Invoke a compiler executable quietly and return its exit code

.DESCRIPTION
Minimal process runner for Invoke-D365ModuleBuild.

Unlike Invoke-Process it never writes the standard output or error
streams to the console. They are discarded, because the compiler log
files are the source of truth and the caller parses those for the
agent friendly summary.

It returns the numeric exit code of the executable, so the caller can
signal success or failure without any console noise.

.PARAMETER Executable
Full path to the program / executable that you want to start

.PARAMETER Params
Array of string parameters that you want to pass to the executable

.PARAMETER ShowOriginalProgress
Instruct the cmdlet to let the standard output stream live to the console

Default is $false which will discard the standard output

.PARAMETER OutputCommandOnly
Instruct the cmdlet to only output the command that you would have to execute by hand

Will include full path to the executable and the needed parameters based on your selection

.EXAMPLE
PS C:\> Invoke-BuildTool -Executable "C:\AOSService\PackagesLocalDirectory\bin\xppc.exe" -Params "-metadata=`"C:\AOSService\PackagesLocalDirectory`"", "-verbose"

This will invoke the xppc.exe executable with discarded output.
It will return the numeric exit code of the executable.

.NOTES
Author: Mötz Jensen (@splaxi)
#>
Expand Down Expand Up @@ -99,4 +99,4 @@ function Invoke-BuildTool {
Write-PSFMessage -Level Verbose -Message "Exit code from $tool was: $($p.ExitCode)"

$p.ExitCode
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/internal/functions/invoke-process.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ function Invoke-Process {
ExitCode = $p.ExitCode
}
}
}
}
2 changes: 1 addition & 1 deletion d365fo.tools/internal/functions/test-pathexists.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ function Test-PathExists {
}

$res
}
}
15 changes: 14 additions & 1 deletion d365fo.tools/tests/functions/Set-D365WebServerType.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,25 @@
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $True
$parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
}
It 'Should have the expected parameter Force' {
$parameter = (Get-Command Set-D365WebServerType).Parameters['Force']
$parameter.Name | Should -Be 'Force'
$parameter.ParameterType.ToString() | Should -Be System.Management.Automation.SwitchParameter
$parameter.IsDynamic | Should -Be $False
$parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
$parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
$parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
$parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
}
}

Describe "Testing parameterset __AllParameterSets" {
<#
__AllParameterSets -RuntimeHostType
__AllParameterSets -RuntimeHostType
__AllParameterSets -RuntimeHostType -Force
#>
}

Expand Down
Loading
Loading