From 2060d17483e258940369d39f08f90a59fd6e10e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Samler?= Date: Mon, 4 May 2026 18:04:15 +0200 Subject: [PATCH] feat(pp-solution): compute CustomizationOptionValuePrefix via CLI post-action Replace hardcoded value 36171 with a computed hash derived from PublisherPrefix. Uses ReplaceOptionValuePrefixProcessor (A1B2C3D4-1003) which reads from Solution.xml and computes a deterministic value in [10000, 99999] via PublisherPrefixHasher. Also removes PowerShell post-action scripts from pp-solution and pp-entity templates, replaced by native CLI post-action processors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../pp-entity/.template.config/template.json | 100 ++++++++-------- .../AddCardFormToSolutionXml.ps1 | 20 ---- .../AddEntityToSolutionXml.ps1 | 18 --- .../AddFormToSolutionXml.ps1 | 18 --- .../AddQCFormToSolutionXml.ps1 | 18 --- .../AddQuickFormToSolutionXml.ps1 | 19 --- .../pp-entity/.template.scripts/Cleanup.ps1 | 1 - .../SortEntityAttributes.ps1 | 31 ----- .../.template.config/template.json | 109 +++++------------- .../pp-solution/.template.scripts/Cleanup.ps1 | 1 - .../EnsureSolutionInitialized.ps1 | 43 ------- .../FlattenSolutionRootIfInplace.ps1 | 21 ---- .../.template.scripts/NormalizeNilTags.ps1 | 13 --- .../RemoveGeneratePluginAssemblyIfTrue.ps1 | 11 -- .../Other/Solution.xml | 4 +- .../SolutionLogicalNameExample.csproj | 6 +- 16 files changed, 91 insertions(+), 342 deletions(-) delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/AddCardFormToSolutionXml.ps1 delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/AddEntityToSolutionXml.ps1 delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/AddFormToSolutionXml.ps1 delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/AddQCFormToSolutionXml.ps1 delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/AddQuickFormToSolutionXml.ps1 delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/Cleanup.ps1 delete mode 100644 src/Dataverse/templates/pp-entity/.template.scripts/SortEntityAttributes.ps1 delete mode 100644 src/Dataverse/templates/pp-solution/.template.scripts/Cleanup.ps1 delete mode 100644 src/Dataverse/templates/pp-solution/.template.scripts/EnsureSolutionInitialized.ps1 delete mode 100644 src/Dataverse/templates/pp-solution/.template.scripts/FlattenSolutionRootIfInplace.ps1 delete mode 100644 src/Dataverse/templates/pp-solution/.template.scripts/NormalizeNilTags.ps1 delete mode 100644 src/Dataverse/templates/pp-solution/.template.scripts/RemoveGeneratePluginAssemblyIfTrue.ps1 diff --git a/src/Dataverse/templates/pp-entity/.template.config/template.json b/src/Dataverse/templates/pp-entity/.template.config/template.json index 01023a79..2e804c34 100644 --- a/src/Dataverse/templates/pp-entity/.template.config/template.json +++ b/src/Dataverse/templates/pp-entity/.template.config/template.json @@ -12,6 +12,12 @@ "sourceName": "examplecustomentity", "sources": [ { + "exclude": [ + "**/[Bb]in/**", + "**/[Oo]bj/**", + ".template.config/**/*", + ".template.scripts/**/*" + ], "modifiers": [ { "condition": "(Behavior == \"New\")", @@ -759,99 +765,99 @@ }, "postActions": [ { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "actionId": "A1B2C3D4-1001-4000-8000-000000000001", "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/AddEntityToSolutionXml.ps1\"", - "redirectStandardOutput": "false" + "type": "1", + "schemaName": "examplepublisherprefix_examplecustomentity", + "behavior": "behaviorType" }, "manualInstructions": [ { - "text": "Adding entity to solution.xml" + "text": "Add to Solution.xml RootComponents" } ], "continueOnError": false, - "description": "Adding entity to solution.xml" + "description": "Register entity in Solution.xml" }, { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "actionId": "A1B2C3D4-1001-4000-8000-000000000001", "condition": "(AddQuickCreateForm)", "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/AddQCFormToSolutionXml.ps1\"", - "redirectStandardOutput": "false" + "type": "60", + "id": "{quickCreateFormId}", + "behavior": "0" }, "manualInstructions": [ { - "text": "Adding form to solution.xml" + "text": "Add to Solution.xml RootComponents" } ], "continueOnError": false, - "description": "Adding form to solution.xml" + "description": "Register quick create form in Solution.xml" }, { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "actionId": "A1B2C3D4-1001-4000-8000-000000000001", "condition": "(AddMainForm)", "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/AddFormToSolutionXml.ps1\"", - "redirectStandardOutput": "false" + "type": "60", + "id": "{mainFormId}", + "behavior": "0" }, "manualInstructions": [ { - "text": "Adding form to solution.xml" + "text": "Add to Solution.xml RootComponents" } ], "continueOnError": false, - "description": "Adding form to solution.xml" + "description": "Register main form in Solution.xml" }, { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "actionId": "A1B2C3D4-1001-4000-8000-000000000001", "condition": "(AddCardForm)", "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/AddCardFormToSolutionXml.ps1\"", - "redirectStandardOutput": "false" + "type": "60", + "id": "{cardFormId}", + "behavior": "0" }, "manualInstructions": [ - { "text": "Adding the card form to solution.xml" } + { + "text": "Add to Solution.xml RootComponents" + } ], "continueOnError": false, - "description": "Adding the card form to solution.xml" + "description": "Register card form in Solution.xml" }, { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "actionId": "A1B2C3D4-1001-4000-8000-000000000001", "condition": "(AddQuickForm)", "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/AddQuickFormToSolutionXml.ps1\"", - "redirectStandardOutput": "false" - }, - "manualInstructions": [{ "text": "Adding a quick form to solution.xml" }], - "continueOnError": false, - "description": "Adding form to solution.xml" - }, - { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/SortEntityAttributes.ps1\"", - "redirectStandardOutput": "false" + "type": "60", + "id": "{quickFormId}", + "behavior": "0" }, - "manualInstructions": [{ "text": "Sorting entity attributes alphabetically by PhysicalName" }], + "manualInstructions": [ + { + "text": "Add to Solution.xml RootComponents" + } + ], "continueOnError": false, - "description": "Sorting entity attributes" + "description": "Register quick form in Solution.xml" }, { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "actionId": "A1B2C3D4-1002-4000-8000-000000000002", "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/Cleanup.ps1\"", - "redirectStandardOutput": "false" + "filePattern": "Entities/*/Entity.xml", + "xpath": "//entity/attributes", + "sortBy": "PhysicalName", + "caseSensitive": "false" }, - "manualInstructions": [{ "text": "Removing Scripts" }], + "manualInstructions": [ + { + "text": "Sort elements in Entity.xml alphabetically by PhysicalName" + } + ], "continueOnError": false, - "description": "Removing Scripts" + "description": "Sort entity attributes alphabetically" } ] } diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/AddCardFormToSolutionXml.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/AddCardFormToSolutionXml.ps1 deleted file mode 100644 index 77518f5d..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/AddCardFormToSolutionXml.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -# Resolve the relative path to an absolute path (to support other OSes) -$solutionPath = Resolve-Path -Path 'SolutionDeclarationsRoot/Other/Solution.xml' - -# Load the XML file -[XML]$File = Get-Content -Path $solutionPath -Raw -$rootComponents = $File.SelectSingleNode("//RootComponents") - -$newComponent = $File.CreateElement("RootComponent") -$newComponent.SetAttribute("type", '60') -$newComponent.SetAttribute("id", '{cardFormId}') -$newComponent.SetAttribute("behavior", '0') - -# Append the new component to the root components without writing output to console -$null = $rootComponents.AppendChild($newComponent) - -# Save the updated XML back to the file -$File.Save($solutionPath) - - - diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/AddEntityToSolutionXml.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/AddEntityToSolutionXml.ps1 deleted file mode 100644 index cdc1fb9b..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/AddEntityToSolutionXml.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# Resolve the relative path to an absolute path (to support other OSes) -$solutionPath = Resolve-Path -Path 'SolutionDeclarationsRoot/Other/Solution.xml' - -# Load the XML file -[XML]$File = Get-Content -Path $solutionPath -Raw -$rootComponents = $File.SelectSingleNode("//RootComponents") - -# Create a new component element -$newComponent = $File.CreateElement("RootComponent") -$newComponent.SetAttribute("type", '1') -$newComponent.SetAttribute("schemaName", 'examplepublisherprefix_examplecustomentity') -$newComponent.SetAttribute("behavior", 'behaviorType') - -# Append the new component to the root components without writing output to console -$null = $rootComponents.AppendChild($newComponent) - -# Save the updated XML back to the file -$File.Save($solutionPath) diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/AddFormToSolutionXml.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/AddFormToSolutionXml.ps1 deleted file mode 100644 index 218941b2..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/AddFormToSolutionXml.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# Resolve the relative path to an absolute path (to support other OSes) -$solutionPath = Resolve-Path -Path 'SolutionDeclarationsRoot/Other/Solution.xml' - -# Load the XML file -[XML]$File = Get-Content -Path $solutionPath -Raw -$rootComponents = $File.SelectSingleNode("//RootComponents") - -$newComponent = $File.CreateElement("RootComponent") -$newComponent.SetAttribute("type", '60') -$newComponent.SetAttribute("id", '{mainFormId}') -$newComponent.SetAttribute("behavior", '0') - -# Append the new component to the root components without writing output to console -$null = $rootComponents.AppendChild($newComponent) - -# Save the updated XML back to the file -$File.Save($solutionPath) - diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/AddQCFormToSolutionXml.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/AddQCFormToSolutionXml.ps1 deleted file mode 100644 index 5e731e73..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/AddQCFormToSolutionXml.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# Resolve the relative path to an absolute path (to support other OSes) -$solutionPath = Resolve-Path -Path 'SolutionDeclarationsRoot/Other/Solution.xml' - -# Load the XML file -[XML]$File = Get-Content -Path $solutionPath -Raw -$rootComponents = $File.SelectSingleNode("//RootComponents") - -$newComponent = $File.CreateElement("RootComponent") -$newComponent.SetAttribute("type", '60') -$newComponent.SetAttribute("id", '{quickCreateFormId}') -$newComponent.SetAttribute("behavior", '0') - -# Append the new component to the root components without writing output to console -$null = $rootComponents.AppendChild($newComponent) - -# Save the updated XML back to the file -$File.Save($solutionPath) - diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/AddQuickFormToSolutionXml.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/AddQuickFormToSolutionXml.ps1 deleted file mode 100644 index 7985e391..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/AddQuickFormToSolutionXml.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -# Resolve the relative path to an absolute path (to support other OSes) -$solutionPath = Resolve-Path -Path 'SolutionDeclarationsRoot/Other/Solution.xml' - -# Load the XML file -[XML]$File = Get-Content -Path $solutionPath -Raw -$rootComponents = $File.SelectSingleNode("//RootComponents") - -$newComponent = $File.CreateElement("RootComponent") -$newComponent.SetAttribute("type", '60') -$newComponent.SetAttribute("id", '{quickFormId}') -$newComponent.SetAttribute("behavior", '0') - -# Append the new component to the root components without writing output to console -$null = $rootComponents.AppendChild($newComponent) - -# Save the updated XML back to the file -$File.Save($solutionPath) - - diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/Cleanup.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/Cleanup.ps1 deleted file mode 100644 index 562fe039..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/Cleanup.ps1 +++ /dev/null @@ -1 +0,0 @@ -Remove-Item .template.scripts -Recurse -Force \ No newline at end of file diff --git a/src/Dataverse/templates/pp-entity/.template.scripts/SortEntityAttributes.ps1 b/src/Dataverse/templates/pp-entity/.template.scripts/SortEntityAttributes.ps1 deleted file mode 100644 index 0e50754b..00000000 --- a/src/Dataverse/templates/pp-entity/.template.scripts/SortEntityAttributes.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -$entityXmlPaths = Get-ChildItem -Path "SolutionDeclarationsRoot/Entities" -Recurse -File -Filter "Entity.xml" -ErrorAction SilentlyContinue -if (-not $entityXmlPaths) { exit 0 } - -foreach ($entityXmlFile in $entityXmlPaths) { - [xml]$xml = Get-Content -Path $entityXmlFile.FullName -Raw - - $attributesNodes = $xml.SelectNodes('//entity/attributes') - foreach ($attributesNode in $attributesNodes) { - $attrs = @($attributesNode.SelectNodes('attribute')) - if ($attrs.Count -eq 0) { continue } - - $sorted = $attrs | Sort-Object { $_.GetAttribute('PhysicalName').ToLowerInvariant() } - - foreach ($a in $attrs) { - $attributesNode.RemoveChild($a) | Out-Null - } - foreach ($a in $sorted) { - $attributesNode.AppendChild($a) | Out-Null - } - } - - $settings = New-Object System.Xml.XmlWriterSettings - $settings.Indent = $true - $settings.NewLineHandling = [System.Xml.NewLineHandling]::None - $settings.OmitXmlDeclaration = $false - $settings.Encoding = New-Object System.Text.UTF8Encoding($true) - - $writer = [System.Xml.XmlWriter]::Create($entityXmlFile.FullName, $settings) - $xml.Save($writer) - $writer.Close() -} diff --git a/src/Dataverse/templates/pp-solution/.template.config/template.json b/src/Dataverse/templates/pp-solution/.template.config/template.json index 328f414e..76aa91cd 100644 --- a/src/Dataverse/templates/pp-solution/.template.config/template.json +++ b/src/Dataverse/templates/pp-solution/.template.config/template.json @@ -19,7 +19,8 @@ "*/**/[Oo]bj/**", "**/**/[Bb]in/**", "**/**/[Oo]bj/**", - ".template.config/**/*" + ".template.config/**/*", + ".template.scripts/**/*" ] } ], @@ -40,18 +41,17 @@ "isRequired": true }, "SolutionRootPath": { - "type": "parameter", - "datatype": "text", - "defaultValue": ".", - "replaces": "SolutionDeclarationsRoot", - "fileRename": "SolutionDeclarationsRoot", - "description": "Folder under the project folder where solution components will be placed. Use the folder name only, not the full path. Use '.' if you want to place components directly in the project folder." - }, + "type": "parameter", + "datatype": "text", + "defaultValue": ".", + "replaces": "SolutionDeclarationsRoot", + "fileRename": "SolutionDeclarationsRoot", + "description": "Folder under the project folder where solution components will be placed. Use the folder name only, not the full path. Use '.' if you want to place components directly in the project folder." + }, "GeneratePluginAssembly": { "type": "parameter", "datatype": "choice", "isRequired": false, - "replaces": "generateexamplepluginassembly", "defaultValue": "true", "choices": [ { @@ -60,7 +60,24 @@ { "choice": "false" } - ] + ], + "description": "Whether to generate a plugin assembly during build. When true (default), the SDK default applies and the property is omitted from .csproj. Set to false to explicitly disable." + }, + "SanitizedName": { + "type": "generated", + "generator": "regex", + "datatype": "string", + "replaces": "SanitizedSolutionUniqueName", + "parameters": { + "source": "name", + "steps": [ + { + "regex": "[^a-zA-Z0-9]", + "replacement": "" + } + ] + }, + "description": "Solution UniqueName with non-alphanumeric characters removed" } }, "primaryOutputs": [ @@ -70,34 +87,15 @@ ], "postActions": [ { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/FlattenSolutionRootIfInplace.ps1\"", - "redirectStandardOutput": "false" - }, + "actionId": "A1B2C3D4-1003-4000-8000-000000000003", + "args": {}, "manualInstructions": [ { - "text": "Flatten SolutionDeclarationsRoot if SolutionRootPath is '.'" + "text": "Compute CustomizationOptionValuePrefix from publisher prefix hash" } ], "continueOnError": false, - "description": "Flatten SolutionDeclarationsRoot into project root when SolutionRootPath is '.'" - }, - { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/EnsureSolutionInitialized.ps1\"", - "redirectStandardOutput": "false" - }, - "manualInstructions": [ - { - "text": "Ensure solution artifacts are initialized" - } - ], - "continueOnError": false, - "description": "Ensure solution artifacts are initialized" + "description": "Compute CustomizationOptionValuePrefix from publisher prefix" }, { "description": "Add generated project to .sln file", @@ -112,51 +110,6 @@ "actionId": "D396686C-DE0E-4DE6-906D-291CD29FC5DE", "continueOnError": true, "primaryOutputIndexes": "0" - }, - { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/RemoveGeneratePluginAssemblyIfTrue.ps1\"", - "redirectStandardOutput": "false" - }, - "manualInstructions": [ - { - "text": "Remove from .csproj when value is true" - } - ], - "continueOnError": false, - "description": "Remove from .csproj when GeneratePluginAssembly is true" - }, - { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/NormalizeNilTags.ps1\"", - "redirectStandardOutput": "false" - }, - "manualInstructions": [ - { - "text": "Normalize nil XML tags to single-line format" - } - ], - "continueOnError": true, - "description": "Normalize nil XML tags to match SolutionPackager export format" - }, - { - "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", - "args": { - "executable": "pwsh", - "args": "-noprofile -executionpolicy bypass -File \"./.template.scripts/Cleanup.ps1\"", - "redirectStandardOutput": "false" - }, - "manualInstructions": [ - { - "text": "Removing template files" - } - ], - "continueOnError": false, - "description": "Removing template files" } ] } diff --git a/src/Dataverse/templates/pp-solution/.template.scripts/Cleanup.ps1 b/src/Dataverse/templates/pp-solution/.template.scripts/Cleanup.ps1 deleted file mode 100644 index 562fe039..00000000 --- a/src/Dataverse/templates/pp-solution/.template.scripts/Cleanup.ps1 +++ /dev/null @@ -1 +0,0 @@ -Remove-Item .template.scripts -Recurse -Force \ No newline at end of file diff --git a/src/Dataverse/templates/pp-solution/.template.scripts/EnsureSolutionInitialized.ps1 b/src/Dataverse/templates/pp-solution/.template.scripts/EnsureSolutionInitialized.ps1 deleted file mode 100644 index a650e4f1..00000000 --- a/src/Dataverse/templates/pp-solution/.template.scripts/EnsureSolutionInitialized.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -# Run solution initialization only if key solution artifacts are missing. - -$requiredFiles = @( - 'Customizations.xml', - 'Relationships.xml', - 'Solution.xml' -) - -$missing = @() - -foreach ($file in $requiredFiles) { - $found = Get-ChildItem -Path . -Recurse -File -Filter $file -ErrorAction SilentlyContinue | Select-Object -First 1 - if (-not $found) { - $missing += $file - } -} - -# Find the Solution.xml file and read it as XML -$solutionXml = Get-ChildItem -Path . -Filter Solution.xml -Recurse | Select-Object -First 1 -[xml]$xml = Get-Content $solutionXml.FullName -Raw - -# Find the UniqueName element and sanitize it -$uniqueName = $xml.ImportExportXml.SolutionManifest.UniqueName -$sanitized = [regex]::Replace($uniqueName, '[^a-zA-Z0-9]', '') -$xml.ImportExportXml.SolutionManifest.UniqueName = $sanitized - -# Switch solution type to both to support packing managed solutions using SolutionPackager -$xml.ImportExportXml.SolutionManifest.Managed = 2 - -# Save the updated XML back to the file -$xml.Save($solutionXml.FullName) - -if ($missing.Count -eq 0) { - Write-Host "Solution artifacts already present (Customizations.xml, Relationships.xml, Solution.xml). Skipping InitializeSolution." - return -} - -Write-Host "Missing solution artifacts: $($missing -join ', '). Running InitializeSolution..." -& (Join-Path $PSScriptRoot 'InitializeSolution.ps1') -if ($LASTEXITCODE -ne 0) { - Write-Error "InitializeSolution.ps1 failed with exit code $LASTEXITCODE" - exit $LASTEXITCODE -} diff --git a/src/Dataverse/templates/pp-solution/.template.scripts/FlattenSolutionRootIfInplace.ps1 b/src/Dataverse/templates/pp-solution/.template.scripts/FlattenSolutionRootIfInplace.ps1 deleted file mode 100644 index 6a489405..00000000 --- a/src/Dataverse/templates/pp-solution/.template.scripts/FlattenSolutionRootIfInplace.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -$solutionRootPath = "SolutionDeclarationsRoot" - -if ($solutionRootPath -ne ".") { return } - -$projectRoot = (Get-Location).Path - -$stranded = Join-Path $projectRoot "SolutionDeclarationsRoot" -$strandedResolved = (Resolve-Path -LiteralPath $stranded -ErrorAction SilentlyContinue)?.Path -# Skip if the stranded path resolves to the project root itself (SolutionRootPath was '.') -if ($strandedResolved -and $strandedResolved -ne $projectRoot -and (Test-Path -LiteralPath $stranded)) { - Get-ChildItem -LiteralPath $stranded -Force | ForEach-Object { - Move-Item -LiteralPath $_.FullName -Destination $projectRoot -Force - } - Remove-Item -LiteralPath $stranded -Recurse -Force -} - -Get-ChildItem -LiteralPath $projectRoot -Filter *.csproj -File | ForEach-Object { - $lines = Get-Content -LiteralPath $_.FullName - $filtered = $lines | Where-Object { $_ -notmatch '^\s*\.\s*$' } - Set-Content -LiteralPath $_.FullName -Value $filtered -} diff --git a/src/Dataverse/templates/pp-solution/.template.scripts/NormalizeNilTags.ps1 b/src/Dataverse/templates/pp-solution/.template.scripts/NormalizeNilTags.ps1 deleted file mode 100644 index 9aa606b4..00000000 --- a/src/Dataverse/templates/pp-solution/.template.scripts/NormalizeNilTags.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -# Normalize nil XML tags to match SolutionPackager export format -# Template engine splits across two lines - -$solutionXml = Get-ChildItem -Path . -Filter Solution.xml -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 - -if (-not $solutionXml) { - Write-Warning "Solution.xml not found, skipping nil tag normalization" - exit 0 -} - -$content = [System.IO.File]::ReadAllText($solutionXml.FullName) -$content = [regex]::Replace($content, '(xsi:nil="true")>\s*\r?\n\s*.*\s*$' } - Set-Content -LiteralPath $_.FullName -Value $filtered -} diff --git a/src/Dataverse/templates/pp-solution/SolutionDeclarationsRoot/Other/Solution.xml b/src/Dataverse/templates/pp-solution/SolutionDeclarationsRoot/Other/Solution.xml index 480dc9fa..9bc837fa 100644 --- a/src/Dataverse/templates/pp-solution/SolutionDeclarationsRoot/Other/Solution.xml +++ b/src/Dataverse/templates/pp-solution/SolutionDeclarationsRoot/Other/Solution.xml @@ -1,7 +1,7 @@ - SolutionLogicalNameExample + SanitizedSolutionUniqueName @@ -19,7 +19,7 @@ examplepublisherprefix - 36171 + 00000
1 diff --git a/src/Dataverse/templates/pp-solution/SolutionLogicalNameExample.csproj b/src/Dataverse/templates/pp-solution/SolutionLogicalNameExample.csproj index e71c216a..76e41516 100644 --- a/src/Dataverse/templates/pp-solution/SolutionLogicalNameExample.csproj +++ b/src/Dataverse/templates/pp-solution/SolutionLogicalNameExample.csproj @@ -1,9 +1,13 @@ net462 + SolutionDeclarationsRoot + Solution - generateexamplepluginassembly + + false + examplepublisher