diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13ff922..54b8006 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,18 +21,6 @@ jobs: with: dotnet-version: 10.x - - name: ✏️ Set abstractions version from CHANGELOG.md - shell: pwsh - run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore.Abstractions/CHANGELOG.md -CsprojPath XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj - - - name: ✏️ Set source generator version from CHANGELOG.md - shell: pwsh - run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore/CHANGELOG.md -CsprojPath XrmPluginCore.SourceGenerator/XrmPluginCore.SourceGenerator.csproj - - - name: ✏️ Set implementations version from CHANGELOG.md - shell: pwsh - run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore/CHANGELOG.md -CsprojPath XrmPluginCore/XrmPluginCore.csproj - - name: 📦 Install dependencies run: dotnet restore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bdd7b7..cbb3d68 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,18 +26,6 @@ jobs: with: dotnet-version: 10.x - - name: ✏️ Set abstractions version from CHANGELOG.md - shell: pwsh - run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore.Abstractions/CHANGELOG.md -CsprojPath XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj - - - name: ✏️ Set source generator version from CHANGELOG.md - shell: pwsh - run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore/CHANGELOG.md -CsprojPath XrmPluginCore.SourceGenerator/XrmPluginCore.SourceGenerator.csproj - - - name: ✏️ Set implementations version from CHANGELOG.md - shell: pwsh - run: ./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath XrmPluginCore/CHANGELOG.md -CsprojPath XrmPluginCore/XrmPluginCore.csproj - - name: 📦 Restore dependencies run: dotnet restore diff --git a/CLAUDE.md b/CLAUDE.md index f866818..04b1b94 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -489,7 +489,7 @@ Version numbers are managed through CHANGELOG.md files: - `XrmPluginCore/CHANGELOG.md` for the main library and source generator (both use the same version) - `XrmPluginCore.Abstractions/CHANGELOG.md` for abstractions -The `Set-VersionFromChangelog.ps1` script updates .csproj files from CHANGELOG during CI/CD. +`Directory.Build.targets` derives each project's `` from the latest `### v...` entry in the relevant CHANGELOG.md at build time — no script or CI step required. Core and the source generator share `XrmPluginCore/CHANGELOG.md`; Abstractions overrides `ChangelogPath` in its .csproj to use its own changelog. An explicit `-p:Version=...` still overrides the derived value. ## Source Generator Development diff --git a/Directory.Build.targets b/Directory.Build.targets index 57dc5e3..a54633e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,10 +1,49 @@ - + + + $(MSBuildThisFileDirectory)XrmPluginCore\CHANGELOG.md + <_ChangelogVersionLine Condition="Exists('$(ChangelogPath)')">$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(ChangelogPath)')), '(?m)^### v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\-\.]+)?')) + + $(_ChangelogVersionLine.Substring(5)) + + 1.0.0-local + + + + true + https://github.com/delegateas/XrmPluginCore + true + snupkg LICENSE contextand.png README.md - 1.0.0-local + + + + + + + + + + + + diff --git a/XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj b/XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj index d6b88e9..06658d3 100644 --- a/XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj +++ b/XrmPluginCore.Abstractions/XrmPluginCore.Abstractions.csproj @@ -1,29 +1,13 @@ netstandard2.0 - True XrmPluginCore.Abstractions XrmPluginCore.Abstractions - https://github.com/delegateas/XrmPluginCore Abstractions and shared Enums for the XrmPluginCore package xrm,crm,dataverse,daxif,delegate,context&,contextand,xrmmockup - True - snupkg XrmPluginCore true + + $(MSBuildProjectDirectory)\CHANGELOG.md - - - True - \ - - - True - \ - - - True - \ - - diff --git a/XrmPluginCore/XrmPluginCore.csproj b/XrmPluginCore/XrmPluginCore.csproj index 8b4c480..58d5d73 100644 --- a/XrmPluginCore/XrmPluginCore.csproj +++ b/XrmPluginCore/XrmPluginCore.csproj @@ -1,32 +1,14 @@  net462;net8 - True true XrmPluginCore XrmPluginCore XrmPluginCore provides base functionality for developing plugins and custom APIs in Dynamics 365. It includes context wrappers and registration utilities to streamline the development process. - https://github.com/delegateas/XrmPluginCore xrm,crm,dataverse,daxif,delegate,context&,contextand,xrmmockup,xrmsync - True - snupkg true true - - - True - \ - - - True - \ - - - True - \ - - diff --git a/scripts/Pack-Local.ps1 b/scripts/Pack-Local.ps1 index 4710387..3374d77 100644 --- a/scripts/Pack-Local.ps1 +++ b/scripts/Pack-Local.ps1 @@ -1,6 +1,4 @@ -./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath .\XrmPluginCore\CHANGELOG.md -CsprojPath .\XrmPluginCore\XrmPluginCore.csproj -./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath .\XrmPluginCore.SourceGenerator\CHANGELOG.md -CsprojPath .\XrmPluginCore.SourceGenerator\XrmPluginCore.SourceGenerator.csproj -./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath .\XrmPluginCore.Abstractions\CHANGELOG.md -CsprojPath .\XrmPluginCore.Abstractions\XrmPluginCore.Abstractions.csproj - +# Versions are derived automatically from each project's CHANGELOG.md by +# Directory.Build.targets, so no version-setting step is needed here. dotnet build --configuration Release dotnet pack diff --git a/scripts/Set-VersionFromChangelog.ps1 b/scripts/Set-VersionFromChangelog.ps1 deleted file mode 100644 index bc205bb..0000000 --- a/scripts/Set-VersionFromChangelog.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -# Sets the property in the given .csproj file to the latest version found in CHANGELOG.md (keepachangelog format) -param( - [string]$ChangelogPath, - [string]$CsprojPath -) - -$changelog = Get-Content $ChangelogPath -# Match lines like: ### v1.0.0-rc.1 - xx xxxx 2025 - -$regex = '^### v([0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\-\.]+)?)' -$resolved = Resolve-Path $CsprojPath - -$versionLine = $changelog | Where-Object { $_ -match $regex } | Select-Object -First 1 -if ($versionLine -match $regex) { - $version = $matches[1] - Write-Host "Detected version: $version" - [xml]$xml = Get-Content $resolved - - $propertyGroup = $xml.Project.PropertyGroup | Where-Object { $_.Version -or $_.OutputType } | Select-Object -First 1 - if (-not $propertyGroup) { - $propertyGroup = $xml.Project.PropertyGroup | Select-Object -First 1 - } - if (-not $propertyGroup.Version) { - $versionElement = $xml.CreateElement('Version') - $versionElement.InnerText = $version - $propertyGroup.AppendChild($versionElement) | Out-Null - } else { - $propertyGroup.Version = $version - } - - $xml.Save($resolved) - Write-Host "Updated $CsprojPath with version $version" -} else { - Write-Error 'No version found in CHANGELOG.md' - exit 1 -}