Skip to content

Commit ae43398

Browse files
authored
Merge pull request #134 from lahma/modern-csproj
Suggestion: modernize the project files and generate the package with dotnet pack
2 parents 3e8c56b + f6fbd93 commit ae43398

12 files changed

Lines changed: 119 additions & 150 deletions

File tree

‎.nuke/build.schema.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"enum": [
2727
"Clean",
2828
"Compile",
29-
"CopyFiles",
3029
"CreatePackage",
3130
"Default",
3231
"Package",

‎AGENTS.md‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,32 @@ The orchestrator is NUKE (`nuke/Build.cs`), bootstrapped by `build.ps1` / `build
1616
```powershell
1717
.\build.ps1 # restore, compile, run the full test suite
1818
.\build.ps1 -Target Compile # other targets: Clean Restore Compile RunUnitTests
19-
.\build.ps1 -Target Package # CopyFiles CreatePackage Package PrePublish Publish
19+
.\build.ps1 -Target Package # CreatePackage Package PrePublish Publish
2020
```
2121

2222
For the normal edit/test loop use the SDK directly — much faster than the NUKE bootstrap:
2323

2424
```powershell
2525
dotnet build src/AngleSharp.Js.sln
26-
dotnet test src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj -f net8.0
27-
dotnet test src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj -f net8.0 --filter "FullyQualifiedName~InstanceOfTests"
28-
dotnet test src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj -f net8.0 --filter "Name=WindowIsAnInstanceOfWindow"
26+
dotnet test src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj -f net10.0
27+
dotnet test src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj -f net10.0 --filter "FullyQualifiedName~InstanceOfTests"
28+
dotnet test src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj -f net10.0 --filter "Name=WindowIsAnInstanceOfWindow"
2929
```
3030

31-
- Always pass `-f net8.0` when iterating. On Windows both projects also target `net462` and
32-
`net472`, so omitting it runs everything three times.
31+
- Always pass `-f net10.0` when iterating. On Windows the test project also targets `net462`
32+
and `net472`, so omitting it runs everything three times.
3333
- `TreatWarningsAsErrors` is on (`src/Directory.Build.props`) — a warning breaks the build.
3434
There is no separate lint step; the compiler is it.
35-
- The package version is parsed from the top entry of `CHANGELOG.md` (`ReleaseNotesParser`),
36-
not from a csproj property. Release-worthy changes get a `CHANGELOG.md` line.
35+
- Package versions are centralized in `src/Directory.Packages.props` (CPM is on), so a
36+
`PackageReference` in a csproj carries no `Version`. AngleSharp and Jint are deliberately
37+
stated as ranges: `dotnet pack` publishes them verbatim as the package's dependency ranges.
38+
- The package version is parsed from the top entry of `CHANGELOG.md` (`ReleaseNotesParser`)
39+
and passed to the build as `-p:Version`. Release-worthy changes get a `CHANGELOG.md` line.
40+
`AssemblyVersion` is pinned to `1.0.0.0` so the strong-name identity survives that.
3741
- `RunUnitTests` runs the suite twice, differing only in a `prefetched` environment variable
3842
that nothing in this repo currently reads — a single run is equivalent locally.
39-
- There is no `global.json`; the bootstrap scripts use the STS channel, CI installs 10.0.x.
43+
- There is deliberately no `global.json` — the repository does not restrict the SDK version. The
44+
bootstrap scripts use the STS channel, CI installs 10.0.x.
4045

4146
## Architecture
4247

@@ -154,8 +159,8 @@ Concrete .NET techniques that apply here:
154159
caches, and `Engine.PrepareScript` moves parsing and static analysis off the run path.
155160

156161
Constraint worth knowing before reaching for a newer BCL API: the library targets
157-
`netstandard2.0`, `net462`, `net472` and `net8.0`, and takes no dependency beyond AngleSharp
158-
and Jint. `Span<T>`, `MemoryExtensions`, `ArrayPool<T>` and friends are therefore **not**
162+
`netstandard2.0`, `net462`, `net472`, `net8.0` and `net10.0`, and takes no dependency beyond
163+
AngleSharp and Jint. `Span<T>`, `MemoryExtensions`, `ArrayPool<T>` and friends are therefore **not**
159164
available unconditionally — they would need a `System.Memory` package reference or a
160165
`#if NET8_0_OR_GREATER` guard, so weigh that against the actual gain. `LangVersion` is
161166
`latest`, so modern C# *syntax* is always fine.

‎nuke/Build.cs‎

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Nuke.Common.ProjectModel;
66
using Nuke.Common.Tools.DotNet;
77
using Nuke.Common.Tools.GitHub;
8-
using Nuke.Common.Tools.NuGet;
98
using Nuke.Common.Utilities.Collections;
109
using Octokit;
1110
using Octokit.Internal;
@@ -15,7 +14,6 @@
1514
using System.IO;
1615
using System.Linq;
1716
using static Nuke.Common.Tools.DotNet.DotNetTasks;
18-
using static Nuke.Common.Tools.NuGet.NuGetTasks;
1917
using Project = Nuke.Common.ProjectModel.Project;
2018

2119
class Build : NukeBuild
@@ -46,8 +44,6 @@ class Build : NukeBuild
4644

4745
AbsolutePath SourceDirectory => RootDirectory / "src";
4846

49-
AbsolutePath BuildDirectory => SourceDirectory / TargetProjectName / "bin" / Configuration;
50-
5147
AbsolutePath ResultDirectory => RootDirectory / "bin" / Version;
5248

5349
AbsolutePath NugetDirectory => ResultDirectory / "nuget";
@@ -141,6 +137,8 @@ protected override void OnBuildInitialized()
141137
var settings = s
142138
.SetProjectFile(Solution)
143139
.SetConfiguration(Configuration)
140+
.SetVersion(Version)
141+
.SetContinuousIntegrationBuild(IsServerBuild)
144142
.EnableNoRestore();
145143

146144
if (!String.IsNullOrEmpty(AngleSharpVersion))
@@ -161,6 +159,7 @@ protected override void OnBuildInitialized()
161159
var settings = s
162160
.SetProjectFile(Solution)
163161
.SetConfiguration(Configuration)
162+
.SetProperty("Version", Version)
164163
.EnableNoRestore()
165164
.EnableNoBuild();
166165

@@ -173,39 +172,30 @@ protected override void OnBuildInitialized()
173172
});
174173
});
175174

176-
Target CopyFiles => _ => _
175+
// The package is produced by `dotnet pack` straight from the project, so the dependency
176+
// groups follow the actual TargetFrameworks instead of a hand-maintained nuspec.
177+
Target CreatePackage => _ => _
177178
.DependsOn(Compile)
178179
.Executes(() =>
179180
{
180-
foreach (var item in TargetFrameworks)
181+
DotNetPack(s =>
181182
{
182-
var targetDir = NugetDirectory / "lib" / item;
183-
var srcDir = BuildDirectory / item;
184-
185-
(srcDir / $"{TargetProjectName}.dll").Copy(targetDir / $"{TargetProjectName}.dll", ExistsPolicy.FileOverwriteIfNewer);
186-
(srcDir / $"{TargetProjectName}.pdb").Copy(targetDir / $"{TargetProjectName}.pdb", ExistsPolicy.FileOverwriteIfNewer);
187-
(srcDir / $"{TargetProjectName}.xml").Copy(targetDir / $"{TargetProjectName}.xml", ExistsPolicy.FileOverwriteIfNewer);
188-
}
183+
var settings = s
184+
.SetProject(TargetProject)
185+
.SetConfiguration(Configuration)
186+
.SetVersion(Version)
187+
.SetOutputDirectory(NugetDirectory)
188+
.SetContinuousIntegrationBuild(IsServerBuild)
189+
.EnableNoRestore()
190+
.EnableNoBuild();
189191

190-
(SourceDirectory / $"{TargetProjectName}.nuspec").Copy(NugetDirectory / $"{TargetProjectName}.nuspec", ExistsPolicy.FileOverwriteIfNewer);
191-
(RootDirectory / "logo.png").Copy(NugetDirectory / "logo.png", ExistsPolicy.FileOverwriteIfNewer);
192-
(RootDirectory / "README.md").Copy(NugetDirectory / "README.md", ExistsPolicy.FileOverwriteIfNewer);
193-
});
192+
if (!String.IsNullOrEmpty(AngleSharpVersion))
193+
{
194+
settings = settings.SetProperty("AngleSharpVersion", AngleSharpVersion);
195+
}
194196

195-
Target CreatePackage => _ => _
196-
.DependsOn(CopyFiles)
197-
.Executes(() =>
198-
{
199-
var nuspec = NugetDirectory / $"{TargetProjectName}.nuspec";
200-
201-
NuGetPack(_ => _
202-
.SetTargetPath(nuspec)
203-
.SetVersion(Version)
204-
.SetOutputDirectory(NugetDirectory)
205-
.SetSymbols(true)
206-
.SetSymbolPackageFormat("snupkg")
207-
.AddProperty("Configuration", Configuration)
208-
);
197+
return settings;
198+
});
209199
});
210200

211201
Target PublishPackage => _ => _
@@ -221,9 +211,10 @@ protected override void OnBuildInitialized()
221211
throw new BuildAbortedException("Could not resolve the NuGet API key.");
222212
}
223213

214+
// Pushing the .nupkg also uploads the matching .snupkg next to it.
224215
foreach (var nupkg in NugetDirectory.GlobFiles("*.nupkg"))
225216
{
226-
NuGetPush(s => s
217+
DotNetNuGetPush(s => s
227218
.SetTargetPath(nupkg)
228219
.SetSource("https://api.nuget.org/v3/index.json")
229220
.SetApiKey(apiKey));

‎nuke/_build.csproj‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Nuke.Common" Version="10.0.0" />
14+
<PackageReference Include="Nuke.Common" Version="10.1.0" />
15+
<!-- Transitive pins for advisories in Nuke.Common's dependency graph. -->
1516
<PackageReference Include="NuGet.Packaging" Version="6.12.5" PrivateAssets="All" />
1617
<PackageReference Include="System.Security.Cryptography.Xml" Version="10.0.10" PrivateAssets="All" />
1718
</ItemGroup>
1819

19-
<ItemGroup>
20-
<PackageDownload Include="NuGet.CommandLine" Version="[6.12.5]" />
21-
</ItemGroup>
22-
2320
</Project>
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0</TargetFrameworks>
3+
<TargetFrameworks>net10.0</TargetFrameworks>
44
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net472</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5 -->
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<ProjectReference Include="..\AngleSharp.Js\AngleSharp.Js.csproj">
11-
<TargetFramework>netstandard2.0</TargetFramework>
12-
</ProjectReference>
10+
<ProjectReference Include="..\AngleSharp.Js\AngleSharp.Js.csproj" />
1311
</ItemGroup>
1412

1513
<ItemGroup>
1614
<EmbeddedResource Include="Fixtures\Html5Test\**\*" />
1715
</ItemGroup>
1816

1917
<ItemGroup>
20-
<PackageReference Include="AngleSharp.Io" Version="1.0.0" />
21-
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
18+
<PackageReference Include="AngleSharp.Css" />
19+
<PackageReference Include="AngleSharp.Io" />
20+
<PackageReference Include="AngleSharp.Xml" />
21+
<PackageReference Include="Newtonsoft.Json" />
22+
<PackageReference Include="NUnit" />
23+
<PackageReference Include="NUnit3TestAdapter" />
24+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
25+
<PackageReference Include="GitHubActionsTestLogger">
2226
<PrivateAssets>all</PrivateAssets>
2327
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2428
</PackageReference>
25-
<PackageReference Include="AngleSharp.Css" Version="1.0.0" />
26-
<PackageReference Include="AngleSharp.Xml" Version="1.0.0" />
27-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
28-
<PackageReference Include="NUnit" Version="3.14.0" />
29-
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
30-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
3129
</ItemGroup>
3230
</Project>

‎src/AngleSharp.Js.Tests/Properties/AssemblyInfo.cs‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎src/AngleSharp.Js.nuspec‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎src/AngleSharp.Js.sln‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,10 @@ Global
1919
{4ED5A0B3-AE7A-40B6-BBAC-FF408D6C6BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
2020
{4ED5A0B3-AE7A-40B6-BBAC-FF408D6C6BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
2121
{4ED5A0B3-AE7A-40B6-BBAC-FF408D6C6BC3}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{73856B9E-967D-44AA-A644-91CBBE75BF9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{73856B9E-967D-44AA-A644-91CBBE75BF9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{73856B9E-967D-44AA-A644-91CBBE75BF9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{73856B9E-967D-44AA-A644-91CBBE75BF9D}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{9136D59F-9F50-4E02-96B2-3EAC114B95FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{9136D59F-9F50-4E02-96B2-3EAC114B95FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{9136D59F-9F50-4E02-96B2-3EAC114B95FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{9136D59F-9F50-4E02-96B2-3EAC114B95FA}.Release|Any CPU.Build.0 = Release|Any CPU
3022
{18B0B97B-8795-4DC2-A1E7-8070255BE718}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3123
{18B0B97B-8795-4DC2-A1E7-8070255BE718}.Debug|Any CPU.Build.0 = Debug|Any CPU
3224
{18B0B97B-8795-4DC2-A1E7-8070255BE718}.Release|Any CPU.ActiveCfg = Release|Any CPU
3325
{18B0B97B-8795-4DC2-A1E7-8070255BE718}.Release|Any CPU.Build.0 = Release|Any CPU
34-
{2BEBF4AD-1660-43A6-B452-109716F42FA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35-
{2BEBF4AD-1660-43A6-B452-109716F42FA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
36-
{2BEBF4AD-1660-43A6-B452-109716F42FA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
37-
{2BEBF4AD-1660-43A6-B452-109716F42FA6}.Release|Any CPU.Build.0 = Release|Any CPU
38-
{14AC7A32-E4E4-4ADF-A81A-030FC90E1BB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39-
{14AC7A32-E4E4-4ADF-A81A-030FC90E1BB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
40-
{14AC7A32-E4E4-4ADF-A81A-030FC90E1BB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
41-
{14AC7A32-E4E4-4ADF-A81A-030FC90E1BB6}.Release|Any CPU.Build.0 = Release|Any CPU
4226
EndGlobalSection
4327
GlobalSection(SolutionProperties) = preSolution
4428
HideSolutionNode = FALSE

‎src/AngleSharp.Js/AngleSharp.Js.csproj‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,37 @@
33
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
44
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net472</TargetFrameworks>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
</PropertyGroup>
7+
8+
<PropertyGroup Label="Packaging">
9+
<PackageProjectUrl>https://anglesharp.github.io</PackageProjectUrl>
10+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
11+
<PackageIcon>logo.png</PackageIcon>
12+
<PackageReadmeFile>README.md</PackageReadmeFile>
13+
<PackageTags>html;html5;css;css3;dom;javascript;scripting;library;js;scripts;runtime;jint;anglesharp;angle</PackageTags>
14+
<PackageReleaseNotes>https://github.com/AngleSharp/AngleSharp.Js/blob/master/CHANGELOG.md</PackageReleaseNotes>
615
<RepositoryUrl>https://github.com/AngleSharp/AngleSharp.Js</RepositoryUrl>
716
<RepositoryType>git</RepositoryType>
817
<PublishRepositoryUrl>true</PublishRepositoryUrl>
918
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1019
<IncludeSymbols>true</IncludeSymbols>
1120
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
12-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
13-
<AngleSharpVersion>1.*</AngleSharpVersion>
1421
</PropertyGroup>
1522

1623
<ItemGroup>
17-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
24+
<PackageReference Include="AngleSharp" />
25+
<PackageReference Include="Jint" />
1826
</ItemGroup>
1927

2028
<ItemGroup>
21-
<PackageReference Include="AngleSharp" Version="$(AngleSharpVersion)" />
22-
<PackageReference Include="Jint" Version="4.15.3" />
29+
<None Include="$(MSBuildThisFileDirectory)..\..\logo.png" Pack="true" PackagePath="\" Visible="false" />
30+
<None Include="$(MSBuildThisFileDirectory)..\..\README.md" Pack="true" PackagePath="\" Visible="false" />
2331
</ItemGroup>
2432

25-
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
26-
<DelaySign>false</DelaySign>
27-
</PropertyGroup>
28-
</Project>
33+
<ItemGroup>
34+
<InternalsVisibleTo Include="AngleSharp.Js.Tests" Key="002400000480000094000000060200000024000052534131000400000100010001adf274fa2b375134e8e4558d606f1a0f96f5cd0c6b99970f7cce9887477209d7c29f814e2508d8bd2526e99e8cd273bd1158a3984f1ea74830ec5329a77c6ff201a15edeb8b36ab046abd1bce211fe8dbb076d7d806f46b15bfda44def04ead0669971e96c5f666c9eda677f28824fff7aa90d32929ed91d529a7a41699893" />
35+
<AssemblyAttribute Include="System.Runtime.InteropServices.ComVisibleAttribute">
36+
<_Parameter1>false</_Parameter1>
37+
</AssemblyAttribute>
38+
</ItemGroup>
39+
</Project>

‎src/AngleSharp.Js/Properties/AssemblyInfo.cs‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)