Skip to content

Commit 17704b9

Browse files
committed
REFACTOR: Centralize project definitions
1 parent 6cc92ab commit 17704b9

File tree

8 files changed

+52
-50
lines changed

8 files changed

+52
-50
lines changed

Directory.Build.props

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Common metadata for all projects -->
4+
<Company>Context&amp; A/S</Company>
5+
<Authors>Context&amp;</Authors>
6+
<Copyright>Copyright (c) Context&amp; A/S</Copyright>
7+
<RepositoryUrl>https://github.com/delegateas/XrmPluginCore</RepositoryUrl>
8+
<RepositoryType>git</RepositoryType>
9+
10+
<!-- Consistent language version (C# 14) -->
11+
<LangVersion>14</LangVersion>
12+
</PropertyGroup>
13+
14+
<!-- Assembly signing for non-test projects -->
15+
<PropertyGroup Condition="!$(MSBuildProjectName.EndsWith('.Tests'))">
16+
<SignAssembly>True</SignAssembly>
17+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)resources\delegate.snk</AssemblyOriginatorKeyFile>
18+
</PropertyGroup>
19+
20+
<!-- Package metadata for packable projects -->
21+
<PropertyGroup Condition="'$(IsPackable)' != 'false'">
22+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
23+
<PackageIcon>contextand.png</PackageIcon>
24+
<PackageReadmeFile>README.md</PackageReadmeFile>
25+
<Version>1.0.0-local</Version>
26+
</PropertyGroup>
27+
28+
<!-- Test project defaults -->
29+
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
30+
<IsPackable>false</IsPackable>
31+
<IsTestProject>true</IsTestProject>
32+
</PropertyGroup>
33+
34+
<!-- Centralized Dataverse SDK references for projects that need them -->
35+
<ItemGroup Condition="'$(UseDataverseSdk)' == 'true'">
36+
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.59" Condition="'$(TargetFramework)' == 'net462'" />
37+
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.3" Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net8'" />
38+
</ItemGroup>
39+
</Project>
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
55
<PackageId>XrmPluginCore.Abstractions</PackageId>
66
<Title>XrmPluginCore.Abstractions</Title>
7-
<Company>Context&amp; A/S</Company>
8-
<Copyright>&#169; Context&amp; A/S</Copyright>
9-
<Authors>Context&amp;</Authors>
107
<PackageProjectUrl>https://github.com/delegateas/XrmPluginCore</PackageProjectUrl>
118
<Description>Abstractions and shared Enums for the XrmPluginCore package</Description>
12-
<PackageReadmeFile>README.md</PackageReadmeFile>
13-
<RepositoryUrl>https://github.com/delegateas/XrmPluginCore</RepositoryUrl>
14-
<RepositoryType>git</RepositoryType>
159
<PackageTags>xrm,crm,dataverse,daxif,delegate,context&amp;,contextand,xrmmockup</PackageTags>
16-
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1710
<IncludeSymbols>True</IncludeSymbols>
1811
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1912
<RootNamespace>XrmPluginCore</RootNamespace>
20-
<SignAssembly>True</SignAssembly>
21-
<AssemblyOriginatorKeyFile>../resources/delegate.snk</AssemblyOriginatorKeyFile>
22-
<PackageIcon>contextand.png</PackageIcon>
23-
<Version>1.0.0-local</Version>
2413
</PropertyGroup>
2514
<ItemGroup>
2615
<None Include="..\LICENSE">
@@ -36,4 +25,4 @@
3625
<PackagePath>\</PackagePath>
3726
</None>
3827
</ItemGroup>
39-
</Project>
28+
</Project>

XrmPluginCore.SourceGenerator.Tests/XrmPluginCore.SourceGenerator.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<IsPackable>false</IsPackable>
8-
<IsTestProject>true</IsTestProject>
97
</PropertyGroup>
108

119
<ItemGroup>

XrmPluginCore.SourceGenerator/XrmPluginCore.SourceGenerator.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<LangVersion>14</LangVersion>
65
<IsRoslynComponent>true</IsRoslynComponent>
76
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
87
<IsPackable>false</IsPackable>
9-
<Version>1.0.0-local</Version>
108
</PropertyGroup>
119

1210
<ItemGroup>

XrmPluginCore.Tests/XrmPluginCore.Tests.csproj

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>net462;net8.0</TargetFrameworks>
5-
<IsPackable>false</IsPackable>
6-
<IsTestProject>true</IsTestProject>
7-
<LangVersion>10.0</LangVersion>
5+
<UseDataverseSdk>true</UseDataverseSdk>
86

97
<!-- Enable source generator output for inspection -->
108
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
@@ -26,14 +24,6 @@
2624
<PackageReference Include="FluentAssertions" Version="7.2.0" />
2725
</ItemGroup>
2826

29-
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
30-
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.59" />
31-
</ItemGroup>
32-
33-
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
34-
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.3" />
35-
</ItemGroup>
36-
3727
<ItemGroup>
3828
<ProjectReference Include="..\XrmPluginCore\XrmPluginCore.csproj" />
3929
<ProjectReference Include="..\XrmPluginCore.Abstractions\XrmPluginCore.Abstractions.csproj" />
@@ -48,4 +38,4 @@
4838
<None Include=".editorconfig" />
4939
</ItemGroup>
5040

51-
</Project>
41+
</Project>

XrmPluginCore/XrmPluginCore.csproj

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,14 @@
22
<PropertyGroup>
33
<TargetFrameworks>net462;net8</TargetFrameworks>
44
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
5+
<UseDataverseSdk>true</UseDataverseSdk>
56
<PackageId>XrmPluginCore</PackageId>
67
<Title>XrmPluginCore</Title>
7-
<Company>Context&amp; A/S</Company>
8-
<Copyright>©2025 Context&amp; A/S</Copyright>
9-
<Authors>Context&amp;</Authors>
108
<Description>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.</Description>
119
<PackageProjectUrl>https://github.com/delegateas/XrmPluginCore</PackageProjectUrl>
12-
<PackageReadmeFile>README.md</PackageReadmeFile>
13-
<RepositoryUrl>https://github.com/delegateas/XrmPluginCore</RepositoryUrl>
14-
<RepositoryType>git</RepositoryType>
1510
<PackageTags>xrm,crm,dataverse,daxif,delegate,context&amp;,contextand,xrmmockup,xrmsync</PackageTags>
16-
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1711
<IncludeSymbols>True</IncludeSymbols>
1812
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
19-
<PackageIcon>contextand.png</PackageIcon>
20-
<SignAssembly>True</SignAssembly>
21-
<AssemblyOriginatorKeyFile>../resources/delegate.snk</AssemblyOriginatorKeyFile>
22-
<Version>1.0.0-local</Version>
2313
</PropertyGroup>
2414
<ItemGroup>
2515
<None Include="..\LICENSE">
@@ -35,12 +25,6 @@
3525
<PackagePath>\</PackagePath>
3626
</None>
3727
</ItemGroup>
38-
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
39-
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.59" />
40-
</ItemGroup>
41-
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
42-
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.3" />
43-
</ItemGroup>
4428
<ItemGroup>
4529
<Folder Include="Properties\" />
4630
</ItemGroup>
@@ -60,4 +44,4 @@
6044
Visible="false"
6145
Link="analyzers\dotnet\cs\XrmPluginCore.SourceGenerator.dll" />
6246
</ItemGroup>
63-
</Project>
47+
</Project>

scripts/Pack-Local.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath .\XrmPluginCore\CHANGELOG.md -CsprojPath .\XrmPluginCore\XrmPluginCore.csproj
2+
./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath .\XrmPluginCore.SourceGenerator\CHANGELOG.md -CsprojPath .\XrmPluginCore.SourceGenerator\XrmPluginCore.SourceGenerator.csproj
23
./scripts/Set-VersionFromChangelog.ps1 -ChangelogPath .\XrmPluginCore.Abstractions\CHANGELOG.md -CsprojPath .\XrmPluginCore.Abstractions\XrmPluginCore.Abstractions.csproj
34

45
dotnet build --configuration Release

scripts/Set-VersionFromChangelog.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ if ($versionLine -match $regex) {
1616
Write-Host "Detected version: $version"
1717
[xml]$xml = Get-Content $resolved
1818

19-
$propertyGroup = $xml.Project.PropertyGroup | Where-Object { $_.Version -or $_.OutputType }
19+
$propertyGroup = $xml.Project.PropertyGroup | Where-Object { $_.Version -or $_.OutputType } | Select-Object -First 1
20+
if (-not $propertyGroup) {
21+
$propertyGroup = $xml.Project.PropertyGroup | Select-Object -First 1
22+
}
2023
if (-not $propertyGroup.Version) {
2124
$versionElement = $xml.CreateElement('Version')
2225
$versionElement.InnerText = $version

0 commit comments

Comments
 (0)