diff --git a/scripts/sanityCheckNuget.fsx b/scripts/sanityCheckNuget.fsx index c2f7f9e2..7528d8e0 100755 --- a/scripts/sanityCheckNuget.fsx +++ b/scripts/sanityCheckNuget.fsx @@ -23,11 +23,9 @@ open Fsdk.Process #r "nuget: Microsoft.Build, Version=16.11.0" open Microsoft.Build.Construction -let ScriptsDir = __SOURCE_DIRECTORY__ |> DirectoryInfo -let RootDir = Path.Combine(ScriptsDir.FullName, "..") |> DirectoryInfo -let NugetSolutionPackagesDir = - Path.Combine(RootDir.FullName, "packages") |> DirectoryInfo +let GetNugetSolutionPackagesDir(solutionDir: DirectoryInfo) = + Path.Combine(solutionDir.FullName, "packages") |> DirectoryInfo let args = Misc.FsxOnlyArguments() @@ -102,8 +100,8 @@ type private ComparableFileInfo = let SanityCheckNugetPackages() = - let notPackagesFolder(dir: DirectoryInfo) : bool = - dir.FullName <> NugetSolutionPackagesDir.FullName + let notPackagesFolder (solutionDir: DirectoryInfo) (dir: DirectoryInfo) : bool = + dir.FullName <> (GetNugetSolutionPackagesDir solutionDir).FullName let notSubmodule(dir: DirectoryInfo) : bool = let getSubmoduleDirsForThisRepo() : seq = @@ -169,7 +167,7 @@ let SanityCheckNugetPackages() = dir .EnumerateDirectories() .Where(notSubmodule) - .Where(notPackagesFolder) do + .Where(notPackagesFolder sol.Directory) do for file in findNuspecFiles subdir do yield file } @@ -324,14 +322,16 @@ let SanityCheckNugetPackages() = : Map> = solDir.Refresh() - if not NugetSolutionPackagesDir.Exists then + let packagesDir = GetNugetSolutionPackagesDir solDir + + if not packagesDir.Exists then failwithf "'%s' subdir under solution dir %s doesn't exist, run `make` first" - NugetSolutionPackagesDir.Name - NugetSolutionPackagesDir.FullName + packagesDir.Name + packagesDir.FullName let packageDirsAbsolutePaths = - NugetSolutionPackagesDir + packagesDir .EnumerateDirectories() .Select(fun dir -> dir.FullName) @@ -339,8 +339,8 @@ let SanityCheckNugetPackages() = Console.Error.WriteLine( sprintf "'%s' subdir under solution dir %s doesn't contain any packages" - NugetSolutionPackagesDir.Name - NugetSolutionPackagesDir.FullName + packagesDir.Name + packagesDir.FullName ) Console.Error.WriteLine @@ -353,7 +353,7 @@ let SanityCheckNugetPackages() = idealPackageDirs do let pkgDirToLookFor = Path.Combine( - NugetSolutionPackagesDir.FullName, + packagesDir.FullName, packageDirNameThatShouldExist ) |> DirectoryInfo @@ -369,15 +369,17 @@ let SanityCheckNugetPackages() = : seq = solDir.Refresh() - if not(NugetSolutionPackagesDir.Exists) then + let packagesDir = GetNugetSolutionPackagesDir solDir + + if not(packagesDir.Exists) then failwithf "'%s' subdir under solution dir %s doesn't exist, run `make` first" - NugetSolutionPackagesDir.Name - NugetSolutionPackagesDir.FullName + packagesDir.Name + packagesDir.FullName // "src" is a directory for source codes and build scripts, // not for packages, so we need to exclude it from here let packageDirNames = - NugetSolutionPackagesDir + packagesDir .EnumerateDirectories() .Select(fun dir -> dir.Name) .Except([ "src" ]) @@ -385,8 +387,8 @@ let SanityCheckNugetPackages() = if not(packageDirNames.Any()) then failwithf "'%s' subdir under solution dir %s doesn't contain any packages" - NugetSolutionPackagesDir.Name - NugetSolutionPackagesDir.FullName + packagesDir.Name + packagesDir.FullName let packageDirsThatShouldExist = MapHelper.GetKeysOfMap idealPackageDirs