Skip to content

Commit 3a9147d

Browse files
Merge pull request #23 from TimeWarpEngineering/Cramer/2025-07-31/filename-rule
Refactor build configuration and add interface delegation generator
2 parents 8d8e148 + d0280ab commit 3a9147d

File tree

19 files changed

+912
-260
lines changed

19 files changed

+912
-260
lines changed

.github/workflows/ci-cd.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
uses: actions/cache@v4
4848
with:
4949
path: ~/.nuget/packages
50-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
50+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
5151
restore-keys: |
5252
${{ runner.os }}-nuget-
5353
@@ -56,13 +56,12 @@ jobs:
5656
with:
5757
dotnet-version: '9.0.x'
5858

59-
- name: 🔨 Build and Pack
59+
- name: 📁 Create artifacts directory
60+
run: mkdir -p artifacts/packages
61+
62+
- name: 🔨 Build
6063
run: |
6164
dotnet build source/timewarp-source-generators/timewarp-source-generators.csproj --configuration Release
62-
dotnet pack source/timewarp-source-generators/timewarp-source-generators.csproj `
63-
--configuration Release `
64-
--no-build `
65-
-p:NoWarn=NU5128
6665
6766
# TODO: Enable tests when ready
6867
# - name: 🧪 Run Tests
@@ -75,13 +74,13 @@ jobs:
7574
- name: 🔍 Check if version already published (Releases only)
7675
if: github.event_name == 'release'
7776
run: |
78-
$version = (Select-Xml -Path "Directory.Build.props" -XPath "//PackageVersion/text()").Node.Value
77+
$version = (Select-Xml -Path "source/Directory.Build.props" -XPath "//Version/text()").Node.Value
7978
Write-Host "Checking if TimeWarp.SourceGenerators $version is already published on NuGet.org..."
80-
79+
8180
$searchResult = dotnet package search TimeWarp.SourceGenerators --exact-match --prerelease --source https://api.nuget.org/v3/index.json
8281
if ($searchResult -match "TimeWarp\.SourceGenerators.*$version") {
8382
Write-Host "⚠️ WARNING: TimeWarp.SourceGenerators $version is already published to NuGet.org"
84-
Write-Host "❌ This version cannot be republished. Please increment the version in Directory.Build.props"
83+
Write-Host "❌ This version cannot be republished. Please increment the version in source/Directory.Build.props"
8584
exit 1
8685
} else {
8786
Write-Host "✅ TimeWarp.SourceGenerators $version is not yet published on NuGet.org"
@@ -90,7 +89,7 @@ jobs:
9089
- name: 🚀 Publish to NuGet.org (Releases only)
9190
if: github.event_name == 'release'
9291
run: |
93-
dotnet nuget push source/timewarp-source-generators/bin/Release/TimeWarp.SourceGenerators.*.nupkg `
92+
dotnet nuget push artifacts/packages/TimeWarp.SourceGenerators.*.nupkg `
9493
--api-key ${{ secrets.PUBLISH_TO_NUGET_ORG }} `
9594
--source https://api.nuget.org/v3/index.json `
9695
--skip-duplicate
@@ -100,7 +99,7 @@ jobs:
10099
uses: actions/upload-artifact@v4
101100
with:
102101
name: Packages-${{ github.run_number }}
103-
path: source/timewarp-source-generators/bin/Release/*.nupkg
102+
path: artifacts/packages/*.nupkg
104103

105104
- name: ✅ Job Status
106105
run: echo "This job's status is ${{ job.status }}."

Directory.Build.props

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
11
<Project>
2-
<!-- Set common properties regarding assembly information and nuget packages -->
32

4-
<PropertyGroup>
5-
<Authors>Steven T. Cramer</Authors>
6-
<Product>TimeWarp.SourceGenerators</Product>
7-
<PackageId>TimeWarp.SourceGenerators</PackageId>
8-
<PackageVersion>1.0.0-beta.4</PackageVersion>
9-
<PackageProjectUrl>https://timewarpengineering.github.io/timewarp-source-generators/</PackageProjectUrl>
10-
<PackageTags>TimeWarp; Source Generator;SourceGenerators; Delegate</PackageTags>
11-
<PackageIcon>logo.png</PackageIcon>
12-
<RepositoryUrl>https://github.com/TimeWarpEngineering/timewarp-source-generators.git</RepositoryUrl>
13-
<RepositoryType>git</RepositoryType>
14-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
15-
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
16-
<PackageReleaseNotes>
17-
For detailed release notes and changelog, please visit: https://github.com/TimeWarpEngineering/timewarp-source-generators/releases
18-
</PackageReleaseNotes>
19-
<PackageReadmeFile>read-me.md</PackageReadmeFile>
20-
<ContentTargetFolders>contentFiles</ContentTargetFolders>
3+
<!-- Custom path definitions for repository structure -->
4+
<PropertyGroup Label="Custom Repository Variables">
5+
<RepositoryName>timewarp-source-generators</RepositoryName>
6+
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
7+
<SourceDirectory>$(RepositoryRoot)source/</SourceDirectory>
8+
<TestsDirectory>$(RepositoryRoot)tests/</TestsDirectory>
9+
<ArtifactsDirectory>$(RepositoryRoot)artifacts/</ArtifactsDirectory>
10+
<PackagesDirectory>$(ArtifactsDirectory)packages/</PackagesDirectory>
2111
</PropertyGroup>
2212

23-
<!-- Deterministic Builds https://devblogs.microsoft.com/dotnet/producing-packages-with-source-link/#deterministic-builds -->
24-
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
25-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
13+
<!-- MSBuild and NuGet behavior configuration -->
14+
<PropertyGroup Label="MSBuild/NuGet Configuration">
15+
<!-- Output packages to our local feed directory -->
16+
<PackageOutputPath>$(PackagesDirectory)</PackageOutputPath>
17+
18+
<!-- Suppress .NET preview SDK message -->
19+
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
2620
</PropertyGroup>
2721

28-
<!-- Common compile parameters -->
29-
<PropertyGroup>
30-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
31-
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
22+
<!-- Default language and framework settings for all projects -->
23+
<PropertyGroup Label="Project Defaults">
24+
<TargetFramework>net9.0</TargetFramework>
3225
<ImplicitUsings>enable</ImplicitUsings>
33-
<LangVersion>latest</LangVersion>
34-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
35-
<NoWarn>CS7035;NU1503;1503;1591</NoWarn>
3626
<Nullable>enable</Nullable>
37-
<TargetFramework>net9.0</TargetFramework>
27+
<LangVersion>latest</LangVersion>
28+
<IsPackable>false</IsPackable>
29+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
30+
</PropertyGroup>
31+
32+
<!-- Code quality, analyzers, and warning configuration -->
33+
<PropertyGroup Label="Code Quality and Analysis">
34+
<!-- Treat all warnings as errors -->
3835
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
36+
<NoWarn>CS7035;NU1503;1503;1591</NoWarn>
37+
38+
<!-- Enable compiler-generated files output -->
39+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
3940
</PropertyGroup>
4041

41-
<!-- https://devblogs.microsoft.com/nuget/enable-repeatable-package-restores-using-a-lock-file/ supports caching of nugets in CI builds -->
42-
<PropertyGroup>
43-
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
44-
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
42+
<!-- Central Package Management -->
43+
<PropertyGroup Label="NuGet Configuration">
44+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4545
</PropertyGroup>
4646

47-
<PropertyGroup>
47+
<!-- Source Link Settings -->
48+
<PropertyGroup Label="Source Link Settings">
4849
<PublishRepositoryUrl>true</PublishRepositoryUrl>
4950
<IncludeSymbols>false</IncludeSymbols>
5051
<DebugType>portable</DebugType>
5152
</PropertyGroup>
5253

53-
<!--This is to add the CommitDate and CommitHash to your assemblyinfo -->
54-
<Target Name="SetAssemblyMetaData" BeforeTargets="PreBuildEvent" >
54+
<!-- Git commit metadata for assembly info -->
55+
<Target Name="SetAssemblyMetaData" BeforeTargets="PreBuildEvent">
5556
<Exec Command="git log -1 --format=%%ct" ConsoleToMSBuild="true" Condition="'$(OS)' == 'Windows_NT'">
5657
<Output TaskParameter="ConsoleOutput" PropertyName="GitCommitTimestamp"/>
5758
</Exec>
@@ -61,10 +62,6 @@
6162
<Exec Command="pwsh -ExecutionPolicy Bypass -NoProfile -File &quot;$(MSBuildThisFileDirectory)convert-timestamp.ps1&quot; -GitCommitTimestamp $(GitCommitTimestamp)" ConsoleToMSBuild="true">
6263
<Output TaskParameter="ConsoleOutput" PropertyName="CommitDate"/>
6364
</Exec>
64-
<PropertyGroup>
65-
<!-- In Visual Studio the below line crashes if they fix VS then we can use this and no need for the powershell script -->
66-
<!--<LastCommitDate>$([System.DateTime]::UnixEpoch.AddSeconds($(GitCommitTimestamp)).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssK"))</LastCommitDate>-->
67-
</PropertyGroup>
6865
<ItemGroup>
6966
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
7067
<_Parameter1>CommitDate</_Parameter1>
@@ -73,8 +70,8 @@
7370
</ItemGroup>
7471
</Target>
7572

76-
<!-- Common analyzers and code fixes-->
77-
<ItemGroup>
73+
<!-- Common analyzers for all projects -->
74+
<ItemGroup Label="Code Analyzers">
7875
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
7976
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8077
<PrivateAssets>all</PrivateAssets>

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Project>
22
<ItemGroup>
3+
<PackageVersion Include="TimeWarp.SourceGenerators" Version="$(Version)" />
34
<PackageVersion Include="FakeItEasy" Version="7.3.1" />
45
<PackageVersion Include="Fixie" Version="3.2.0" />
56
<PackageVersion Include="Fixie.TestAdapter" Version="3.3.0" />

0 commit comments

Comments
 (0)