@@ -299,6 +299,93 @@ Target.create "RunSample" (fun _ ->
299299 runImmediate
300300 })
301301
302+ // --------------------------------------------------------------------------------------
303+ // Pack the NuGet package using dotnet pack (cross-platform)
304+
305+ let nupkgDir = makeRootPath " temp/nupkg"
306+ let runtimeProjectPath = makeRootPath " src/SqlClient/SqlClient.fsproj"
307+
308+ Target.create " Pack" ( fun _ ->
309+ Shell.cleanDir nupkgDir
310+
311+ DotNet.pack
312+ ( fun args ->
313+ { args with
314+ Configuration = DotNet.Release
315+ NoBuild = true
316+ OutputPath = Some nupkgDir
317+ MSBuildParams =
318+ { args.MSBuildParams with
319+ Properties = [ ( " Version" , release.NugetVersion) ]
320+ DisableInternalBinLog = true } })
321+ runtimeProjectPath
322+
323+ Trace.logfn " Package created in %s " nupkgDir
324+
325+ for pkg in Directory.GetFiles( nupkgDir, " *.nupkg" ) do
326+ Trace.logfn " %s " ( Path.GetFileName pkg))
327+
328+ // --------------------------------------------------------------------------------------
329+ // Validate that the NuGet package is consumable via PackageReference
330+ //
331+ // This builds and runs a standalone project that references the package from a
332+ // local NuGet source (temp/nupkg), exercising all three type providers end-to-end.
333+ // It proves the .nupkg layout is correct independently of the repo build output.
334+
335+ let validationProjectPath =
336+ makeRootPath " tests/PackageValidation/PackageValidation.fsproj"
337+
338+ Target.create " ValidatePackage" ( fun _ ->
339+
340+ // If the CI connection-string override is set, also patch the validation app.config
341+ let connStrOverride =
342+ System.Environment.GetEnvironmentVariable " GITHUB_ACTION_SQL_SERVER_CONNECTION_STRING"
343+
344+ if not ( String.IsNullOrWhiteSpace connStrOverride) then
345+ let appConfigPath = makeRootPath " tests/PackageValidation/app.config"
346+ let doc = XDocument.Load( appConfigPath)
347+
348+ let el =
349+ doc.Root.Element( " connectionStrings" ) .Elements( " add" )
350+ |> Seq.find ( fun el -> el.Attribute( XName.Get " name" ) .Value = " AdventureWorks" )
351+
352+ el.SetAttributeValue( XName.Get " connectionString" , connStrOverride)
353+ doc.Save( appConfigPath)
354+
355+ pipeline " ValidatePackage" {
356+ stage " clean validation caches" {
357+ run ( fun _ ->
358+ // Clear any cached restore so we pick up the freshly-built nupkg
359+ let objDir = makeRootPath " tests/PackageValidation/obj"
360+ let binDir = makeRootPath " tests/PackageValidation/bin"
361+
362+ if Directory.Exists objDir then
363+ Directory.Delete( objDir, true )
364+
365+ if Directory.Exists binDir then
366+ Directory.Delete( binDir, true ))
367+ }
368+
369+ stage " build validation project" {
370+ run
371+ $" dotnet build {validationProjectPath} -c Release -p:FSharpDataSqlClientVersion={release.NugetVersion} --tl"
372+ }
373+
374+ stage " run validation project" {
375+ run ( fun _ ->
376+ let result =
377+ DotNet.exec
378+ id
379+ " run"
380+ $" --project {validationProjectPath} -c Release --no-build -p:FSharpDataSqlClientVersion={release.NugetVersion}"
381+
382+ if not result.OK then
383+ failwith " Package validation failed – the NuGet package is not consumable via PackageReference" )
384+ }
385+
386+ runImmediate
387+ })
388+
302389let funBuildRestore stageName sln =
303390 stage $" dotnet restore %s {stageName} '{sln}'" { run $" dotnet restore {sln} --tl" }
304391
@@ -415,8 +502,10 @@ open Fake.Core.TargetOperators // for ==>
415502==> " CheckFormat"
416503==> " AssemblyInfo"
417504==> " Build"
505+ ==> " Pack"
418506==> " DeployTestDB"
419507==> " RunSample"
508+ ==> " ValidatePackage"
420509==> " BuildTestProjects"
421510==> " RunTests"
422511==> " All"
0 commit comments