From 540df9782ba837a20874057bb21e4951310ea4b1 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Mon, 21 May 2018 20:33:28 +0200 Subject: [PATCH] Build: build strong name and normal packages in one run --- .paket/Paket.Restore.targets | 37 +++++++++++++++++++++++++++--------- build.fsx | 37 ++++++++++++++++++++---------------- build/build-framework.fsx | 35 +++++++++++++++++++++++++++++++--- 3 files changed, 81 insertions(+), 28 deletions(-) diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets index 1a8920fc..55292f31 100644 --- a/.paket/Paket.Restore.targets +++ b/.paket/Paket.Restore.targets @@ -43,7 +43,7 @@ true - $(NoWarn);NU1603 + $(NoWarn);NU1603;NU1604;NU1605;NU1608 @@ -60,6 +60,9 @@ + + + $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)')) @@ -69,11 +72,19 @@ true + + + + + + + + $(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached @@ -82,7 +93,9 @@ $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references $(MSBuildProjectDirectory)\paket.references - $(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved + + false + true true references-file-or-cache-not-found @@ -101,24 +114,29 @@ - + true - target-framework '$(TargetFramework)' + target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths) - + + - + + false + true + + - + - + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1]) @@ -126,8 +144,9 @@ %(PaketReferencesFileLinesInfo.PackageVersion) - All + All runtime + true diff --git a/build.fsx b/build.fsx index 24bcdef9..07b88021 100644 --- a/build.fsx +++ b/build.fsx @@ -317,7 +317,7 @@ Target "Start" DoNothing Target "Clean" (fun _ -> DeleteDirs (!! "src/**/obj/" ++ "src/**/bin/" ) - CleanDirs [ "out/api"; "out/docs"; "out/packages"; "out/lib" ] + CleanDirs [ "out/api"; "out/docs"; "out/packages/Zip"; "out/packages/NuGet"; "out/lib"; "out/lib-strongname" ] CleanDirs [ "out/MKL"; "out/ATLAS"; "out/CUDA"; "out/OpenBLAS" ] // Native Providers CleanDirs [ "out/Data" ] // Data Extensions clean "MathNet.Numerics.sln" @@ -344,7 +344,6 @@ Target "Restore" (fun _ -> Target "Prepare" DoNothing "Start" =?> ("Clean", not (hasBuildParam "incremental")) - ==> "Restore" ==> "ApplyVersion" ==> "Prepare" @@ -353,26 +352,33 @@ Target "Prepare" DoNothing // BUILD, SIGN, COLLECT // -------------------------------------------------------------------------------------- +let fingerprint = "5dbea70701b40cab1b2ca62c75401342b4f0f03a" +let timeserver = "http://time.certum.pl/" + Target "Build" (fun _ -> - // Build + // Strong Name Build (with strong name, without certificate signature) + if hasBuildParam "strongname" then + CleanDirs (!! "src/**/obj/" ++ "src/**/bin/" ) + restoreSN "MathNet.Numerics.sln" + buildSN "MathNet.Numerics.sln" + CopyDir "out/lib-strongname" "src/Numerics/bin/Release" (fun n -> n.Contains("MathNet.Numerics.dll") || n.Contains("MathNet.Numerics.pdb") || n.Contains("MathNet.Numerics.xml")) + CopyDir "out/lib-strongname" "src/FSharp/bin/Release" (fun n -> n.Contains("MathNet.Numerics.FSharp.dll") || n.Contains("MathNet.Numerics.FSharp.pdb") || n.Contains("MathNet.Numerics.FSharp.xml")) + coreSignedBundle |> zip "out/packages/Zip" "out/lib-strongname" (fun f -> f.Contains("MathNet.Numerics.") || f.Contains("System.Threading.") || f.Contains("FSharp.Core.")) + if isWindows then + packSN "MathNet.Numerics.sln" + CopyDir "out/packages/NuGet" "src/Numerics/bin/Release/" (fun n -> n.EndsWith(".nupkg")) + CopyDir "out/packages/NuGet" "src/FSharp/bin/Release/" (fun n -> n.EndsWith(".nupkg")) + + // Normal Build (without strong name, with certificate signature) + CleanDirs (!! "src/**/obj/" ++ "src/**/bin/" ) + restore "MathNet.Numerics.sln" build "MathNet.Numerics.sln" - - // Sign (Windows only) if isWindows && hasBuildParam "sign" then - let fingerprint = "5dbea70701b40cab1b2ca62c75401342b4f0f03a" - let timeserver = "http://time.certum.pl/" sign fingerprint timeserver (!! "src/Numerics/bin/Release/**/MathNet.Numerics.dll" ++ "src/FSharp/bin/Release/**/MathNet.Numerics.FSharp.dll" ) - - // Collect CopyDir "out/lib" "src/Numerics/bin/Release" (fun n -> n.Contains("MathNet.Numerics.dll") || n.Contains("MathNet.Numerics.pdb") || n.Contains("MathNet.Numerics.xml")) CopyDir "out/lib" "src/FSharp/bin/Release" (fun n -> n.Contains("MathNet.Numerics.FSharp.dll") || n.Contains("MathNet.Numerics.FSharp.pdb") || n.Contains("MathNet.Numerics.FSharp.xml")) - - // ZIP Archive - CleanDir "out/packages/Zip" coreBundle |> zip "out/packages/Zip" "out/lib" (fun f -> f.Contains("MathNet.Numerics.") || f.Contains("System.Threading.") || f.Contains("FSharp.Core.")) - - // NUGET Pack (Windows only) if isWindows then pack "MathNet.Numerics.sln" CopyDir "out/packages/NuGet" "src/Numerics/bin/Release/" (fun n -> n.EndsWith(".nupkg")) @@ -384,12 +390,11 @@ Target "Build" (fun _ -> Target "DataBuild" (fun _ -> // Build + restore "MathNet.Numerics.Data.sln" build "MathNet.Numerics.Data.sln" // Sign (Windows only) if isWindows && hasBuildParam "sign" then - let fingerprint = "5dbea70701b40cab1b2ca62c75401342b4f0f03a" - let timeserver = "http://time.certum.pl/" sign fingerprint timeserver (!! "src/Data/Text/bin/Release/**/MathNet.Numerics.Data.Text.dll" ++ "src/Data/Matlab/bin/Release/**/MathNet.Numerics.Data.Matlab.dll" ) // Collect diff --git a/build/build-framework.fsx b/build/build-framework.fsx index f6f5e656..c28280b1 100644 --- a/build/build-framework.fsx +++ b/build/build-framework.fsx @@ -37,12 +37,28 @@ let msbuild targets configuration project = let properties = [ yield "Configuration", configuration - if hasBuildParam "strongname" then yield "StrongName", "True" + yield "StrongName", "False" ] MSBuildHelper.build (fun p -> { p with NoLogo = true - NodeReuse = true + NodeReuse = false + Targets = targets + Properties = properties + RestorePackagesFlag = false + Verbosity = Some MSBuildVerbosity.Minimal + }) project + +let msbuildSN targets configuration project = + let properties = + [ + yield "Configuration", configuration + yield "StrongName", "True" + ] + MSBuildHelper.build (fun p -> + { p with + NoLogo = true + NodeReuse = false Targets = targets Properties = properties RestorePackagesFlag = false @@ -52,7 +68,17 @@ let msbuild targets configuration project = let dotnet workingDir command = let properties = [ - if hasBuildParam "strongname" then yield "StrongName", "True" + yield "StrongName", "False" + ] + let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" """ name value) |> String.concat "" + DotNetCli.RunCommand + (fun c -> { c with WorkingDir = workingDir}) + (command + suffix) + +let dotnetSN workingDir command = + let properties = + [ + yield "StrongName", "True" ] let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" """ name value) |> String.concat "" DotNetCli.RunCommand @@ -175,8 +201,11 @@ let patchVersionInProjectFile path (release:Release) = let clean project = msbuild [ "Clean" ] "Release" project let restore project = msbuild [ "Restore" ] "Release" project +let restoreSN project = msbuildSN [ "Restore" ] "Release" project let build project = msbuild [ (if hasBuildParam "incremental" then "Build" else "Rebuild") ] "Release" project +let buildSN project = msbuildSN [ (if hasBuildParam "incremental" then "Build" else "Rebuild") ] "Release" project let pack project = dotnet rootDir (sprintf "pack %s --configuration Release --no-restore --no-build" project) +let packSN project = dotnetSN rootDir (sprintf "pack %s --configuration Release --no-restore --no-build" project) //let buildConfig config subject = MSBuild "" (if hasBuildParam "incremental" then "Build" else "Rebuild") [ "Configuration", config ] subject |> ignore //let build subject = buildConfig "Release" subject