Skip to content

Add dotnet new template for project scaffolding#32

Open
Kristoffer88 wants to merge 5 commits intomainfrom
feature/dotnet-new-template
Open

Add dotnet new template for project scaffolding#32
Kristoffer88 wants to merge 5 commits intomainfrom
feature/dotnet-new-template

Conversation

@Kristoffer88
Copy link
Collaborator

Summary

Adds a dotnet new xrmbedrock template that automates most of the project setup process.

What the template handles automatically

  • Project renaming: XrmBedrock{name} in all files and filenames (sourceName)
  • Lowercase renaming: xrmbedrock{namelower} for SNK references (nameLower generator)
  • Prefixed folder/refs: ctx_XrmBedrock{prefix}_{name} (prefixedName join generator)
  • Environment URLs: All four Dataverse URLs replaced via --dev-url, --test-url, etc.
  • Assembly metadata: MGS / DEMO replaced via --org-name / --repo-name
  • Resource group: resourcegroupname replaced via --rg-name
  • Cert password: someRandomPassword replaced via --cert-password
  • Username: Written to src/Tools/Daxif/username.txt via --username
  • SNK key: Generated cross-platform in post-action script (CSP blob format)
  • Post-setup: git init, copy initial files, dotnet tool restore, npm install

What still requires manual replacement

These values are too short for safe global string replacement (the template engine's replaces does literal substring matching):

Value Location Why unsafe
ctx _Config.fsx publisher prefix Appears inside entity names like ctx_invoice, ctx_subscription
demo main.bicep solutionId Appears in CustomAPI identifier and pipeline resource names
mgs main.bicep companyId Appears in Dataverse env var schema name mgs_AzureStorageAccountUrl

The --publisher-prefix, --solution-id, and --company-id parameters are collected but not auto-replaced. Users must find-and-replace these manually after project creation.

Compatibility fixes

  • #pragma warning disable IDE0005 around #if NET462 in AzureService.cs — prevents build error when template engine evaluates the conditional (NET462 symbol set to true as constant)
  • #pragma warning disable SA1210 in TestBase.cs — using order changes when XrmBedrock is renamed to a name alphabetically before WireMock

Files added/changed

File Change
.template.config/template.json New — template configuration
.template.config/dotnetcli.host.json New — CLI parameter aliases
Setup/postTemplateSetup.ps1 New — post-action script (SNK gen, file copy, tool restore, npm)
src/Tools/Daxif/username.txt New — placeholder for Dataverse username
README.md Added quick start section
AzureService.cs IDE0005 pragma for template compatibility
TestBase.cs SA1210 pragma for template compatibility

Test plan

  • dotnet new install .
  • dotnet new xrmbedrock -n TestProject --publisher-prefix tst --org-name TestOrg --repo-name TestRepo --dev-url https://test.crm4.dynamics.com -o ~/repos/TestProject
  • Answer Y to post-action prompt
  • Verify testproject.snk exists (596 bytes)
  • Verify src/Tools/Daxif/username.txt has correct value
  • Verify tst_TestProject folder created under WebResources
  • dotnet build --configuration Release — 0 errors, 0 warnings
  • Manually replace ctx, demo, mgs in target files
  • dotnet new uninstall .

Kristoffer Rasmussen and others added 5 commits February 12, 2026 17:30
Adds `dotnet new xrmbedrock` template that automates project setup:
- Renames project files/namespaces via sourceName
- Replaces URLs, cert password, org/repo names, resource group name
- Generates unique SNK strong name key (cross-platform)
- Copies initial setup files, restores tools, installs npm
- Creates username.txt from --username parameter
- Fix .gitignore path for username.txt (was /src/Dataverse/Tools/ should be /src/Tools/)
- Replace someRandomPassword in README with <your-cert-password> to prevent cert password leaking into docs
- Add --cert-password to README quick start example
- Add manual replacement steps to README (ctx, demo, mgs)
- Add PowerShell Core prerequisite note
- Remove contradictory isRequired from publisherPrefix (has defaultValue)
@magesoe magesoe marked this pull request as ready for review February 13, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments