-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bugs with paths and refactored the solution init script
- Loading branch information
Showing
23 changed files
with
93 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Implement exception handling in template scripts - currently it doesn't even tell you that it couldn't find solution.xml file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dataverse/templates/pp-entity/.template.scripts/AddCardFormToSolutionXml.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dataverse/templates/pp-entity/.template.scripts/AddEntityToSolutionXml.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dataverse/templates/pp-entity/.template.scripts/AddFormToSolutionXml.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dataverse/templates/pp-entity/.template.scripts/AddQCFormToSolutionXml.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dataverse/templates/pp-entity/.template.scripts/AddQuickFormToSolutionXml.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 48 additions & 11 deletions
59
src/Dataverse/templates/pp-solution/.template.scripts/InitializeSolution.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,54 @@ | ||
# Initialize a Dataverse solution project | ||
pac solution init --publisher-name examplepublisher --publisher-prefix examplepublisherprefix --outputDirectory Solutions.Example | ||
cd Solutions.Example | ||
# Initialize a Dataverse solution project using PAC CLI | ||
pac solution init --publisher-name examplepublisher --publisher-prefix examplepublisherprefix --outputDirectory "SolutionLogicalNameExample" | ||
cd "SolutionLogicalNameExample" | ||
|
||
# Rename the src folder (produced by PAC CLI to remove the double src folder) | ||
# and remove the unnecessary .gitignore file (we already have one in the root) | ||
# and remove the unnecessary .gitignore file (we already have one in the repository root) | ||
Rename-Item -Path .\src -NewName Declarations && Remove-Item .gitignore -Force | ||
|
||
# Rename the solution component folder in .cdsproj and add the missing project type ID to make dotnet accept the custom project type | ||
$csproj = Get-ChildItem -Path . -Filter *.cdsproj | Select-Object -First 1; [xml]$xml = Get-Content $csproj.FullName -Raw; $propertyGroup = $xml.Project.PropertyGroup | Where-Object { $_.SolutionRootPath } | Select-Object -First 1; $propertyGroup.SolutionRootPath = 'Declarations'; $newElement = $xml.CreateElement('DefaultProjectTypeGuid', $xml.Project.NamespaceURI); $newElement.InnerText = 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC'; $propertyGroup.AppendChild($newElement) > $null; $xml.Save($csproj.FullName) | ||
# Find the .cdsproj file and read it as XML | ||
$csproj = Get-ChildItem -Path . -Filter *.cdsproj | Select-Object -First 1 | ||
[xml]$xml = Get-Content $csproj.FullName -Raw | ||
|
||
# Switch solution ty to both | ||
# sanitize UniqueName element value to remove characters other than letters and numbers | ||
# by finding the first Solution.xml in subfolders, then reading the xml, them readint element value of ImportExportXml/SolutionManifest/UniqueName and then updating it with the sanitized value | ||
$solutionXml = Get-ChildItem -Path . -Filter Solution.xml -Recurse | Select-Object -First 1; [xml]$xml = Get-Content $solutionXml.FullName -Raw; $uniqueName = $xml.ImportExportXml.SolutionManifest.UniqueName; $sanitized = [regex]::Replace($uniqueName, '[^a-zA-Z0-9]', ''); $xml.ImportExportXml.SolutionManifest.UniqueName = $sanitized; $xml.ImportExportXml.SolutionManifest.Managed = 2; $xml.Save($solutionXml.FullName) | ||
# Rename the solution component folder in .cdsproj and | ||
$propertyGroup = $xml.Project.PropertyGroup | Where-Object { $_.SolutionRootPath } | Select-Object -First 1 | ||
$propertyGroup.SolutionRootPath = 'Declarations' | ||
|
||
cd .. | ||
# Add the missing project type ID to make dotnet accept the custom project type | ||
$newElement = $xml.CreateElement('DefaultProjectTypeGuid', $xml.Project.NamespaceURI) | ||
$newElement.InnerText = 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC' | ||
$propertyGroup.AppendChild($newElement) > $null | ||
|
||
# Override the default Publish target to prevent errors when running publish on .sln file | ||
$targetElement = $xml.CreateElement('Target', $xml.Project.NamespaceURI) | ||
$targetElement.SetAttribute('Name', 'Publish') | ||
$comment = $xml.CreateComment(' Override the default Publish target to prevent errors when running publish on .sln file ') | ||
$xml.Project.AppendChild($comment) > $null | ||
$xml.Project.AppendChild($targetElement) > $null | ||
|
||
# Save the updated XML back to the .cdsproj file | ||
$xml.Save($csproj.FullName) | ||
|
||
# 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) | ||
|
||
cd .. | ||
|
||
# Move the solution files from the temp folder to the root | ||
Move-Item -Path "SolutionLogicalNameExample\*" -Destination . -Force | ||
Remove-Item -Path "SolutionLogicalNameExample" -Force | ||
|
||
# The new project is automatically added to the Visual Studio solution by the templating engine | ||
# This would be an alternative: dotnet sln ../../ add SolutionLogicalNameExample.cdsproj" |