Commit Graph

11 Commits

Author SHA1 Message Date
Marc Gravell 8becae8d0e Publish to nuget.org via Trusted Publishing (OIDC), and retire MyGet/AppVeyor (#2230)
* Fix the release-tag pattern in version.json

publicReleaseRefSpec requires `^refs/tags/v\d+\.\d+`, but every tag this repo has
ever cut is unprefixed - 2.1.79, 2.1.72, 2.1.66 and so on - so the regex cannot
match any of them. Checking out the real 2.1.79 tag and asking nbgv gives
`2.1.79-g72a54c475f`, PublicRelease False: a tag-triggered build has always
produced a -g suffixed version, which is fine while releases are pushed by hand
and fatal once a workflow does it. Relaxed to `v?` so both spellings work.

Same fix, same reason, as DapperAOT b5194b4 and StackExchange.Redis 611e478.
Also adds the `$schema` line the file was missing.

* CI: report the computed version, build on SDK 11, and test net481

**Report the computed version.** A step writes NuGetPackageVersion to the job
summary and the log, before the build so it stays legible when a later step
fails. Cutting a release now means reading that line off a green main run and
tagging with exactly it - so the number has to be visible. A PR run builds
refs/pull/N/merge, whose height includes the branch commits and the merge, so its
number is *not* the one that will ship; the summary says so on anything that is
not main, rather than inviting a mis-tag. This needs full history, so checkout
gains fetch-depth: 0 (and moves v1 -> v4).

**Build on SDK 11.** global.json already says rollForward:latestMajor, so simply
installing the SDK 11 preview alongside 10 makes it the one that builds. Breakage
from a new major toolchain then surfaces on an ordinary PR instead of when a
release is being cut. Target frameworks are untouched - this changes what compiles
the code, not what the code runs on - and global.json stays the single lever if we
ever want to pin back to 10.

**Test net481.** tests/Directory.Build.targets sets IsTestProject=false for net4x
outside Windows, so the Ubuntu job has never run net481 - and net481 is the only
TFM that compiles the ENTITY_FRAMEWORK, LINQ2SQL and OLEDB code paths. AppVeyor
was quietly the only thing covering them, so retiring it (next commit) without
this would drop that cover silently. New windows-job runs exactly that leg.

GitHub's Windows images ship no SQL Server engine - only the OLEDB drivers -
hence the install step; AppVeyor's image had an MSSQL$SQL2019 instance built in.
MySQL and PostgreSQL are deliberately not provisioned there: FactMySqlAttribute
and FactPostgresqlAttribute probe the server in a static constructor and skip the
tests when it is unreachable, and the Ubuntu job already covers both providers
against real servers.

Also fixes `.NET Lib Pack`, which passed a cmd-style `%CD%\.nupkgs` to a job that
has run on Ubuntu for years, and so has been writing to a directory named
literally that.

* Add release.yml: verify the tag, then publish to nuget.org over OIDC

There has never been a workflow that publishes to nuget.org - AppVeyor pushed to
two MyGet feeds on every main build, and the actual nuget.org releases were pushed
by hand. That is also why the broken tag pattern went unnoticed for years.

Triggered by a published GitHub Release, with workflow_dispatch as a dry run that
does everything except the tag check and the push, so the pipeline can be proven
(and the packages inspected, via the run artifact) without cutting a release.

The guard is the point: nbgv computes the version from version.json plus commit
height, so the tag name does not set it and a mistyped tag would otherwise ship a
package that disagrees with its release. The step compares the two and fails
loudly instead. A leading "v" is stripped, matching the `v?` pattern.

Auth is Trusted Publishing (OIDC) - no long-lived key anywhere, which is the whole
reason for the move. Setup lives outside this file and is recorded in the header
comment: a GitHub environment named "release", a NUGET_USER secret, and a
trusted-publishing policy on nuget.org for each of the six published packages. A
package with no matching policy fails its push, so all six need one up front.

Runs on Ubuntu, matching main.yml: that is the configuration CI actually proves,
and it means bash expands the push glob (DapperAOT 13f9f0d had to unpick exactly
that on Windows). Packages are uploaded as a run artifact before the push, so a
failed push does not cost the build, and --skip-duplicate makes a partial push
safely re-runnable. Output goes to `nupkgs`, not `.nupkgs`: upload-artifact skips
hidden files by default and a dot-directory uploads as an empty artifact.

No tests here - the commit being released already passed CI, and this job's only
job is to reproduce that build and push it.

* Retire AppVeyor, and drop MyGet from the badges

release.yml now publishes to nuget.org on a tagged release, so AppVeyor's two
MyGet deploy providers are both redundant and a second, unversioned place for
packages to appear. The rest of AppVeyor went with them: its Windows build and
test run is now main.yml's windows-job, which is the part worth keeping.

That also retires the two encrypted MyGet API keys the file carried.

Badges and package tables follow: the AppVeyor build badge becomes the GitHub
Actions one, and the MyGet pre-release column and feed link come out of both
readmes, since that feed is no longer fed by anything.

build.ps1 / build.cmd are left in place - AppVeyor was their only caller, but they
still work as a local build-test-pack entry point.

* Stop packing Dapper.ProviderTools

`dotnet pack Build.csproj` produces it, so a release workflow would push it - but
it was last released as 2.0.90 in April 2021 and has had no work since. Shipping
it now means a dormant package jumping to 2.1.x on the next release, and a
nuget.org trusted-publishing policy that has to be kept alive for something nobody
is maintaining.

IsPackable=false instead, which drops the push set to the six packages the readme
actually lists. The project still builds and is still referenced; un-set the
property to resume shipping it.

* Bump Microsoft.SourceLink.GitHub to clear the NU1902 build break

Microsoft.Build.Tasks.Git 10.0.300, pulled in transitively by SourceLink, has
picked up GHSA-23fw-v26w-5fgq. TreatWarningsAsErrors turns the NU1902 audit
warning into an error, so Dapper and Dapper.StrongName fail to build - tests and
benchmarks only warn, since they set TreatWarningsAsErrors=false.

This is not caused by anything else in this PR: it reproduces on main, under SDK
10 and SDK 11 alike. It is bundled here only because it blocks the checks, and
with them the first real run of the new net481 job.

There is no fixed 10.x - the only versions above 10.0.300 are 11.0.100 previews -
so this takes the rc. That is tolerable for this particular dependency: SourceLink
is PrivateAssets=all, a build-time-only asset that never becomes a dependency of
the packages we publish, and it already tracks the SDK we now build with.

Verified locally: NU1902 is gone and the build exits 0, leaving the pre-existing
NU1903 warnings in tests/benchmarks (SQLitePCLRaw, System.Security.Cryptography.Xml)
which are warnings only and are a separate matter.

* Windows: reach SQL Server over shared memory, not TCP

First real run of this job: 735 of 825 net481 tests failed, every one of them
"TCP Provider, error: 0 - The remote computer refused the network connection."

The install itself was fine - ankane/setup-sqlserver puts in a default MSSQLSERVER
instance with SQL auth - but a Windows SQL Server install leaves the TCP/IP
protocol disabled, so nothing is listening on 1433 and every connection to
tcp:localhost,1433 is refused. AppVeyor never hit this because it connected to
`(local)\SQL2019`, not over TCP. Dropping the `tcp:`/port from both connection
strings uses shared memory against the local default instance, which needs no
protocol configuration.

Also pins the engine to 2019: that is what the Ubuntu job's service container
runs and what AppVeyor ran these tests against, and the action otherwise installs
SQL Server 2025. This job exists to preserve cover that already existed - moving
the engine version underneath it at the same time is a separate decision, and the
OLEDB tests in particular use the legacy SQLOLEDB provider.

Adds a reachability check before the tests, so the next time something is wrong
with the server the job says so in one line instead of several hundred identical
connection failures.

* Windows: stop pinning SQL Server 2019, it hangs the install

The pin added in the previous commit hung "Install SQL Server" for 28 minutes
before the run was cancelled; the same step with the action's default took 2m48s
on the same image a run earlier. SQL Server 2019 predates the Windows Server 2025
runner image, and its setup stalls rather than failing outright.

Reverting to the action's default. The conservatism was not worth its cost: it
was meant to keep this job as close as possible to what AppVeyor proved, but it
cannot install at all. The net481 leg therefore runs against a newer engine than
AppVeyor used - worth knowing, and called out in the comment, because the OLEDB
tests reach SQL Server through the legacy SQLOLEDB provider and that combination
has not been exercised before.

The shared-memory connection strings and the reachability check stay: those were
the actual fix for the 735 connection failures, and are independent of version.
2026-09-12 13:18:00 +01:00
Marc Gravell bd4f75b512 normalize async API surface over all TFMs (#2144)
* - normalize async API surface over all TFMs (fix #2143)
- target net8.0 instead of net5.0
- lib updates

* net9 SDK

* perf tests: clean up SqlClient warning

* CI fix: test concurrency

* rev snowflake
2025-02-06 12:11:30 +00:00
Marc Gravell aecffecae1 attempt NRT makeover (#1928)
* attempt NRT makeover

- annotate NRTs on GridReader API
- add protected access to some of the GridReader internals
- switch GridReader callbacks to be more type-independent

docs

lib updates; deal with yellow warnings and test failures (SQL server certs and cancellation surfacing differently)

fix break

simplify proposed GridReader changes to protected OnBeforeGrid and OnAfterGrid[Async]

Builds: Bump library versions (#1935)

Tests: Upgrade dependencies for Dependabot (#1936)

I'll do a pass at all of these later, but getting CVE versions out of the pipe.

Resolving 4 alerts here: https://github.com/DapperLib/Dapper/security/dependabot

merge and lib updates

allow Identity to be constructed on-the-fly inside GridReader

fix build warnings

include readme

rev minor

- enable [SkipLocalsInit] everywhere
- use NET5_0_OR_GREATER
 for remoting check

# Conflicts:
#	Dapper/CommandDefinition.cs
#	Dapper/DefaultTypeMap.cs
#	Dapper/SqlMapper.Async.cs
#	Dapper/SqlMapper.IDataReader.cs
#	Dapper/SqlMapper.Link.cs
#	Dapper/SqlMapper.cs
#	Directory.Build.props

* shipped, not unshipped

* fixup SqlBuilder; use is null / is not null

* use central package management (#1949)

* Nullable test tweaks

* Nuget: let's just remove it!

* 2 test fixes from review

* fix FindExplicitConstructor

* add GetPropertySetterOrThrow

* fix NRT on FindConstructor

* DapperRow: value is object?

* use NotNullWhen

* make constructor problem more obvious

* test fixes

---------

Co-authored-by: Nick Craver <nrcraver@gmail.com>
2023-09-12 15:58:49 +01:00
Marc Gravell 67f7a1fe17 add Microsoft.CodeAnalysis.PublicApiAnalyzers on the main libs (#1948) 2023-08-18 11:47:37 +01:00
Marc Gravell 6ab170c160 .Net 5 (#1572)
* initial net5.0 tweaks; also fix current IDE warnings

* lib updates and fixes

* more cleanup

* fix snafu

* skip locals init

* disable xunit shadow copy in tests

* test records

* explore scenario that currently works re #1571
2020-11-17 09:57:17 +00:00
Nick Craver 663588f90b AppVeyor: Build tweaks & misc fixes (#1450)
Simplifying and improve build speed.

- Decreases builds from 8-13 minutes down to ~2 minutes (while running more tests)
- Moves to SQL Server 2019 on AppVeyor
- Moves the 2 longest running tests with params to `[FactLongRunning]`
- Bumps tests up to `netcoreapp3.1`
- Also fixes .Contrib tests
- Moves to `Build.csproj`
- Simplifies `build.ps1`
- Removed defunct `build.sh`
- Nukes `IsAppveyor` (moves to environmental variable overloads)
- Builds now work in Linux/macOS
2020-05-02 07:52:40 -04:00
Marc Gravell 765300a32b Enable deterministic build (#1433)
* - enable deterministic build
- lib updates for core packages

* set source root if needed

* Restore VS test runner

xUnit won't run in VS without it :)

Co-authored-by: Nick Craver <craver@stackoverflow.com>
2020-04-05 13:43:31 +01:00
mgravell 7769253d59 framework and tooling lib updates; does *NOT* include the full corpus of 3rd party ADO.NET providers 2019-09-27 10:39:40 +01:00
Nick Craver 1481c4d379 Tooling and project updates (#1333)
This is a branch cleaning up old `#if` clauses, `.csproj` bits, Linux build compatibility, and a few other tid-bits (broken out by commit).

In general: we're on 3.0 tooling and all previous cruft has been removed.
2019-09-26 19:47:55 -04:00
mgravell aefb2840bb reinstate net461 TFM; fix #1325 2019-09-12 08:30:35 +01:00
mgravell 3fe88fc1e0 add Dapper.ProviderTools lib 2019-08-30 13:33:04 +01:00