From 5846e69a26e1b9e2f7cabb0ab7acce376161d6bd Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Sun, 11 Mar 2018 17:02:32 -0400 Subject: [PATCH] Only do sourcelink when there is a remote.origin.url closes #36 --- Content/build.fsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Content/build.fsx b/Content/build.fsx index 980d8976..0eea8423 100644 --- a/Content/build.fsx +++ b/Content/build.fsx @@ -175,6 +175,14 @@ Target "AssemblyInfo" (fun _ -> ) Target "DotnetPack" (fun _ -> + // https://github.com/ctaggart/SourceLink relies on a some git depedencies. + // Checks if there's a remote.origin.url and the last git hash. + let remoteOriginOk, remoteMessages, _ = Git.CommandHelper.runGitCommand "." "config --get remote.origin.url" + let sha1Ok, sha1Message, _ = Git.CommandHelper.runGitCommand "." "rev-parse HEAD" + let canSourceLink = + remoteOriginOk && (remoteMessages |> Seq.length > 0) + && sha1Ok && (sha1Message |> Seq.length > 0) + !! srcGlob |> Seq.iter (fun proj -> DotNetCli.Pack (fun c -> @@ -186,7 +194,7 @@ Target "DotnetPack" (fun _ -> [ sprintf "/p:PackageVersion=%s" release.NugetVersion sprintf "/p:PackageReleaseNotes=\"%s\"" (String.Join("\n",release.Notes)) - "/p:SourceLinkCreate=true" + sprintf "/p:SourceLinkCreate=%b" canSourceLink ] }) )