Skip to content

Commit

Permalink
Fsdk/Network: allow nuget.exe on non-legacy
Browse files Browse the repository at this point in the history
This commit changes Fsdk to allow running nuget.exe on non
legacy frameworks, this is useful when running build scripts
that run on dotnet6 but use xbuild simultaneously.
  • Loading branch information
aarani committed Aug 18, 2023
1 parent 7f075fe commit a044ebe
Showing 1 changed file with 4 additions and 49 deletions.
53 changes: 4 additions & 49 deletions Fsdk/Network.fs
Original file line number Diff line number Diff line change
Expand Up @@ -421,37 +421,17 @@ module Network =
GetPrivateIpOfThisServer()
)

#if !LEGACY_FRAMEWORK
let private nugetExeMsg =
"We warned you at compile time, NuGet.exe is not supported when using dotnet6 or higher (use 'dotnet restore' or 'dotnet nuget')"

[<Obsolete "Rather call 'dotnet restore' or 'dotnet nuget'">]
#endif
let NugetDownloadUrl =
"https://dist.nuget.org/win-x86-commandline/v5.4.0/nuget.exe"

#if !LEGACY_FRAMEWORK
[<Obsolete "Rather call 'dotnet restore' or 'dotnet nuget'">]
#endif
let DownloadNugetExe
#if !LEGACY_FRAMEWORK
(_targetFile: FileInfo)
=
failwith nugetExeMsg
#else
(targetFile: FileInfo)
=
let DownloadNugetExe(targetFile: FileInfo) =
if not targetFile.Directory.Exists then
targetFile.Directory.Create()

if not targetFile.Exists then
use webClient = new WebClient()
webClient.DownloadFile(NugetDownloadUrl, targetFile.FullName)
#endif
DownloadFileTo (Uri NugetDownloadUrl) targetFile
|> Async.RunSynchronously
|> ignore<FileInfo>

#if !LEGACY_FRAMEWORK
[<Obsolete "Rather call 'dotnet restore' or 'dotnet nuget'">]
#endif
let CreateNugetCommand (nugetExe: FileInfo) (args: string) =
let platform = Misc.GuessPlatform()

Expand All @@ -466,18 +446,7 @@ module Network =
Arguments = sprintf "%s %s" nugetExe.FullName args
}

#if !LEGACY_FRAMEWORK
[<Obsolete "Rather call 'dotnet restore' or 'dotnet nuget'">]
#endif
let RunNugetCommand
#if !LEGACY_FRAMEWORK
(_nugetExe: FileInfo)
(_command: string)
(_echo: Echo)
(_safe: bool)
: ProcessResult =
failwith nugetExeMsg
#else
(nugetExe: FileInfo)
(command: string)
(echo: Echo)
Expand All @@ -492,21 +461,8 @@ module Network =
proc.UnwrapDefault() |> ignore<string>

proc
#endif

#if !LEGACY_FRAMEWORK
[<Obsolete "Rather call 'dotnet restore' or 'dotnet nuget'">]
#endif
let InstallNugetPackage
#if !LEGACY_FRAMEWORK
(_nugetExe: FileInfo)
(_outputDirectory: DirectoryInfo)
(_pkgName: string)
(_maybeVersion: Option<string>)
(_echo: Echo)
: ProcessResult =
failwith nugetExeMsg
#else
(nugetExe: FileInfo)
(outputDirectory: DirectoryInfo)
(pkgName: string)
Expand All @@ -531,7 +487,6 @@ module Network =
outputDirectory.FullName)
echo
true
#endif

let private SLACK_WEBHOOK_URI =
"https://hooks.slack.com/services/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"
Expand Down

0 comments on commit a044ebe

Please sign in to comment.