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
60 changes: 60 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and Test

on:
push:
branches: [ main, vNext, develop ]
pull_request:
branches: [ main, vNext ]

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup NuGet
uses: nuget/setup-nuget@v2
with:
nuget-version: 'latest'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Restore NuGet packages
run: nuget restore

- name: Build solution
run: msbuild /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal

- name: Run tests
shell: pwsh
run: |
$vstest = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
if (-not (Test-Path $vstest)) {
$vstest = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
}
if (-not (Test-Path $vstest)) {
Write-Host "Installing xunit console runner..."
nuget install xunit.runner.console -Version 2.9.3 -OutputDirectory packages
$xunit = "packages\xunit.runner.console.2.9.3\tools\net462\xunit.console.exe"
& $xunit "Xrm.Json.Serialization.Tests\bin\Release\Xrm.Json.Serialization.Tests.dll" -xml TestResults.xml
} else {
& $vstest "Xrm.Json.Serialization.Tests\bin\Release\Xrm.Json.Serialization.Tests.dll" /TestAdapterPath:"packages\xunit.runner.visualstudio.2.5.3\build\net462" /Logger:console
}

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults/

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
Xrm.Json.Serialization\bin\Release\*.dll
Xrm.Json.Serialization\bin\Release\*.pdb
88 changes: 88 additions & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Publish to NuGet

on:
push:
tags:
- 'v*.*.*'

jobs:
publish:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Extract version from tag
id: get_version
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$version = $tag -replace '^v', ''
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Version: $version"

- name: Setup NuGet
uses: nuget/setup-nuget@v2
with:
nuget-version: 'latest'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Restore NuGet packages
run: nuget restore

- name: Build solution in Release mode
run: msbuild /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal

- name: Run tests
shell: pwsh
run: |
$vstest = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
if (-not (Test-Path $vstest)) {
$vstest = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
}
if (-not (Test-Path $vstest)) {
Write-Host "Installing xunit console runner..."
nuget install xunit.runner.console -Version 2.9.3 -OutputDirectory packages
$xunit = "packages\xunit.runner.console.2.9.3\tools\net462\xunit.console.exe"
& $xunit "Xrm.Json.Serialization.Tests\bin\Release\Xrm.Json.Serialization.Tests.dll" -xml TestResults.xml
} else {
& $vstest "Xrm.Json.Serialization.Tests\bin\Release\Xrm.Json.Serialization.Tests.dll" /TestAdapterPath:"packages\xunit.runner.visualstudio.2.5.3\build\net462" /Logger:console
}

- name: Update .nuspec version
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.VERSION }}"
$nuspecPath = "Xrm.Json.Serialization.nuspec"
$content = Get-Content $nuspecPath -Raw
$content = $content -replace '<version>[\d\.]+</version>', "<version>$version</version>"
Set-Content $nuspecPath $content
echo "Updated .nuspec to version $version"

- name: Pack NuGet package
run: nuget pack Xrm.Json.Serialization.nuspec -Properties Configuration=Release

- name: Push to NuGet
run: nuget push *.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }} -SkipDuplicate

- name: Upload NuGet package as artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: '*.nupkg'

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: '*.nupkg'
body: |
## Release ${{ steps.get_version.outputs.VERSION }}

See [CHANGELOG.md](https://github.com/imranakram/Xrm.Json.Serialization/blob/main/CHANGELOG.md) for details.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102 changes: 102 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project uses **Calendar Versioning (CalVer)**: `1.YYYY.MM.patch`

## [1.2026.3.0] - 2026-03-11

### Added
- **AliasedValue converter** - Critical for FetchXML queries with linked entities
- **OptionSetValueCollection converter** - Support for multi-select picklists
- **BooleanManagedProperty converter** - Support for managed property fields
- **EntitySerializer helper class** - Simplified serialization/deserialization API
- 27 new comprehensive unit tests for new converters
- Plugin usage examples in README (logging, Service Bus, webhooks, FetchXML, caching)
- External integration examples (console apps, Azure Functions, Web API)
- Deployment guidance for plugins (ILMerge vs NuGet package approaches)

### Fixed
- **[#20]** String escaping issue with double quotes and special characters in `BasicsConverter`
- Removed unsafe `CodeDomProvider` usage that caused JSON escaping problems
- Proper handling of backslashes, newlines, and tabs in strings

### Changed
- **Reverted target framework** from .NET Framework 4.8 to **4.6.2** for plugin compatibility
- Updated `XrmContractResolver` to include new converters
- Enhanced `EntityConverter` to support deserializing new data types
- Updated xunit.runner.visualstudio from 3.1.5 to 2.5.3 (net462 compatibility)
- Improved README with comprehensive plugin and external integration examples
- Updated NuGet package metadata with better description and tags

## [2.0.0] - 2025-03-10

### Changed
- **BREAKING:** Changed root namespace from `Innofactor.Xrm.Json.Serialization` to `Xrm.Json.Serialization`
- **BREAKING:** Assembly name changed from `Innofactor.Xrm.Json.Serialization.dll` to `Xrm.Json.Serialization.dll`
- Upgraded Newtonsoft.Json from 13.0.1 to 13.0.4
- Upgraded System.Text.Json from 6.0.6 to 6.0.10
- Upgraded xUnit from 2.4.2 to 2.9.3
- Updated assembly metadata (copyright 2025)
- Improved NuGet package metadata with better description and tags
- Project structure: moved projects from `src\` folder to root level

### Added
- Comprehensive README.md with usage examples and documentation
- CHANGELOG.md for version history tracking

## [1.0.0] - 2021

### Added
- Initial release
- Support for Dynamics 365/CRM entity serialization
- Converters for Entity, EntityCollection, EntityReference
- Converters for OptionSetValue, Money, DateTime, Guid
- BasicsConverter for primitive types (string, int, double, decimal)
- XrmContractResolver for automatic converter selection
- Comprehensive unit test coverage

### Supported Types
- `Entity` - Full entity serialization with attributes
- `EntityCollection` - Collections of entities
- `EntityReference` - Lookup/reference fields
- `OptionSetValue` - Picklist values
- `Money` - Currency values
- `DateTime` - Date/time with timezone support
- `Guid` - Unique identifiers
- Basic CLR types (string, int, long, float, double, decimal, object)

---

---

## Versioning

This project uses **Calendar Versioning (CalVer)**: `1.YYYY.MM.patch`

Format: `Major.Year.Month.Patch`

Examples:
- `1.2026.3.0` - March 2026, first release
- `1.2026.3.1` - March 2026, patch release
- `1.2022.10.1` - October 2022

---

## Version Comparison

| Version | Date | .NET Framework | Key Changes |
|---------|------|----------------|-------------|
| **1.2026.3.0** | 2026-03-11 | 4.6.2 | AliasedValue, multi-select, plugin examples, bug #20 fix |
| 1.2022.10.1 | 2022-10 | 4.6.2 | Namespace change to Xrm.Json.Serialization |
| 1.0.0 | 2021 | 4.6.2 | Initial release |

---

## Links

- [NuGet Package](https://www.nuget.org/packages/Xrm.Json.Serialization/)
- [GitHub Repository](https://github.com/imranakram/Xrm.Json.Serialization)
- [Issue Tracker](https://github.com/imranakram/Xrm.Json.Serialization/issues)
- [Documentation](https://github.com/imranakram/Xrm.Json.Serialization/blob/main/README.md)
130 changes: 130 additions & 0 deletions GITHUB-ACTIONS-SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# GitHub Actions Setup Guide

This project uses **GitHub Actions** for CI/CD instead of AppVeyor.

## 🔧 Setup Instructions

### 1. Update Git Remote (Already Done)
The repository was moved from `Biznamics` to `imranakram`:

```bash
git remote set-url origin https://github.com/imranakram/Xrm.Json.Serialization
git remote -v
```

### 2. Enable GitHub Actions
GitHub Actions is enabled by default for public repositories. The workflows are already configured in `.github/workflows/`.

### 3. Configure NuGet API Key Secret

To enable automatic NuGet publishing on release:

1. Go to https://www.nuget.org/account/apikeys
2. Create a new API key with:
- **Key Name:** `GitHub-Actions-Xrm.Json.Serialization`
- **Glob Pattern:** `Xrm.Json.Serialization`
- **Scopes:** Push new packages and package versions
3. Copy the generated API key
4. Go to your GitHub repository → **Settings** → **Secrets and variables** → **Actions**
5. Click **New repository secret**
6. Name: `NUGET_API_KEY`
7. Value: Paste your NuGet API key
8. Click **Add secret**

### 4. Workflows

#### **Build and Test** (`.github/workflows/build-and-test.yml`)
- **Triggers:** Push to `main`, `vNext`, `develop` branches; Pull requests
- **Actions:**
- Restore NuGet packages
- Build solution in Release mode
- Run all unit tests
- Upload test results and build artifacts

#### **Publish to NuGet** (`.github/workflows/publish-nuget.yml`)
- **Triggers:** Push tags matching `v*.*.*` (e.g., `v1.2026.3.0`)
- **Actions:**
- Extract version from Git tag
- Build and test
- Update .nuspec with version from tag
- Pack NuGet package
- Publish to NuGet.org
- Create GitHub Release with package attached

### 5. Publishing a Release

When you're ready to publish version **1.2026.3.0** (CalVer format):

```bash
# Commit all changes
git add .
git commit -m "Release v1.2026.3.0 - Add AliasedValue support and fix #20"

# Create and push tag (CalVer: 1.YYYY.MM.patch)
git tag v1.2026.3.0
git push origin vNext
git push origin v1.2026.3.0
```

This will automatically:
1. Trigger the publish workflow
2. Extract version from tag (v1.2026.3.0 → 1.2026.3.0)
3. Update .nuspec version dynamically
4. Build and test the solution
5. Create the NuGet package
6. Push to NuGet.org
7. Create GitHub Release with artifacts

### 6. Monitoring

- View workflow runs: https://github.com/imranakram/Xrm.Json.Serialization/actions
- Check build status badge in README.md
- NuGet publish status will appear in the workflow logs

## 🗑️ AppVeyor Migration

The old `appveyor.yml` has been marked as deprecated and kept for reference only. You can:

**Option 1:** Delete it entirely
```bash
git rm appveyor.yml
git commit -m "Remove deprecated AppVeyor configuration"
```

**Option 2:** Keep it for reference (current state)

If you decide to keep using AppVeyor instead:
1. Update the AppVeyor project settings at https://ci.appveyor.com
2. The configuration has been updated to work with the new structure
3. Update the NuGet API key in AppVeyor settings

## 📊 Benefits of GitHub Actions

| Feature | GitHub Actions | AppVeyor |
|---------|---------------|----------|
| **Cost** | Free (public repos) | Free tier limited |
| **Integration** | Native GitHub | External service |
| **Setup** | No account needed | Separate account |
| **Marketplace** | 10,000+ actions | Limited |
| **Build Minutes** | 2,000/month free | 1 concurrent job |
| **Artifacts** | 500MB storage | Limited |
| **Modern** | Active development | Legacy |

## 🎯 Recommended Next Steps

1. ✅ **Update Git remote:** `git remote set-url origin https://github.com/imranakram/Xrm.Json.Serialization`
2. ✅ **Manually update version numbers** in `.nuspec` and `CHANGELOG.md` to use **CalVer format** (`1.2026.3.0`)
3. ✅ Test the GitHub Actions workflows by pushing a commit to vNext branch
4. ✅ Add NuGet API key secret to GitHub (see step 3 above)
5. ✅ When ready, create release tag: `git tag v1.2026.3.0 && git push origin v1.2026.3.0`
6. ✅ Monitor workflow run at: https://github.com/imranakram/Xrm.Json.Serialization/actions

## 📝 Notes

- GitHub Actions builds on Windows (required for .NET Framework 4.6.2)
- Test results are preserved as artifacts
- NuGet packages are created on every tag push
- Build status badge is already added to README.md
- **Version format:** CalVer `1.YYYY.MM.patch` (e.g., `1.2026.3.0` for March 2026)
- Git tag format: `v1.2026.3.0` (with 'v' prefix)
- The workflow automatically extracts version from tag and updates .nuspec
Loading
Loading