forked from tarsgate/conventions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinconsistentNugetVersionsInDotNetProjects.fsx
More file actions
executable file
·79 lines (59 loc) · 2.42 KB
/
Copy pathinconsistentNugetVersionsInDotNetProjects.fsx
File metadata and controls
executable file
·79 lines (59 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env -S dotnet fsi
open System
open System.IO
#r "System.Core.dll"
#r "System.Xml.Linq.dll"
#r "nuget: Fsdk, Version=0.9.99--date20260525-0605.git-a5cfc39"
open Fsdk
#r "nuget: Microsoft.Build, Version=17.8.43"
#load "../src/FileConventions/Helpers.fs"
#load "../src/FileConventions/NugetVersionsCheck.fs"
open NugetVersionsCheck
let errUsage =
(1, sprintf "Usage: dotnet fsi %s [example.sln(optional)]" __SOURCE_FILE__)
let ErrDirectoryNotAllowed arg =
(2, sprintf "Use an .sln file instead of directory: '%s'" arg)
let ErrFileNotFound arg =
(3, sprintf "'%s' does not exist." arg)
let ErrInvalidArgument arg =
(4,
sprintf
"'%s' argument is invalid. You should enter an .sln file or run this script on current directory"
arg)
let args = Misc.FsxOnlyArguments()
let currentDirectory = Directory.GetCurrentDirectory()
if args.Length > 1 then
let exitCode, errMsg = errUsage
Console.Error.WriteLine errMsg
Environment.Exit exitCode
let target =
if args.IsEmpty then
currentDirectory |> DirectoryInfo |> ScriptTarget.Folder
else
let singleArg = args.[0]
if Directory.Exists singleArg then
let exitCode, errMsg = ErrDirectoryNotAllowed singleArg
Console.Error.WriteLine errMsg
Environment.Exit exitCode
failwith <| "Unreachable because of: " + errMsg
elif not(File.Exists singleArg) then
let exitCode, errMsg = ErrFileNotFound singleArg
Console.Error.WriteLine errMsg
Environment.Exit exitCode
failwith <| "Unreachable because of: " + errMsg
elif singleArg.EndsWith ".sln" then
singleArg |> FileInfo |> ScriptTarget.Solution
else
let exitCode, errMsg = ErrInvalidArgument singleArg
Console.Error.WriteLine errMsg
Environment.Exit exitCode
failwith <| "Unreachable because of: " + errMsg
let nugetSolutionPackagesDir =
Path.Combine(currentDirectory, "packages") |> DirectoryInfo
let nugetPackageConfigDir =
Path.Combine(currentDirectory, "NuGet.config") |> FileInfo
if not nugetPackageConfigDir.Exists || not nugetSolutionPackagesDir.Exists then
failwithf
"NuGet.config not found in '%s', please create it with the `globalPackagesFolder` key as `packages`."
nugetPackageConfigDir.FullName
SanityCheckNugetPackages target currentDirectory nugetSolutionPackagesDir