Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 64 bit VS2022 path and version structure. #2631

Merged
8 changes: 5 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release Notes

## 5.21.0-alpha005 - tbd
* NEW: Support for SqlPackage installed on VS2022.
* NEW: Support for SqlPackage on Linux.

## 5.21.0-alpha004 - 2022-01-06
* BUGFIX: Fix sdk resolver for net6 assemblies. Using offical .NET release JSON to get runtime version, thanks @yazeedobaid - https://github.com/fsprojects/FAKE/pull/2625
Expand Down Expand Up @@ -149,7 +151,7 @@

* LEGACY: Remove `Fake.Deploy` from repository and NuGet package, see https://github.com/fsharp/FAKE/issues/1820
* LEGACY: Update to `net461` to support latest `FSharp.Compiler.Service` to fix https://github.com/fsharp/FAKE/issues/2362
* LEGACY: Release a new version of `FakeLib.dll` (the original FAKE NuGet package)
* LEGACY: Release a new version of `FakeLib.dll` (the original FAKE NuGet package)
* BUGFIX: Fake.Api.Slack uses `Username` not `From`, thanks @mastion - https://github.com/fsharp/FAKE/pull/2360
* ENHANCEMENT: add rollforward policy to next-major to make `fake-cli` work in future dotnet sdk major version, thanks @baronfel - https://github.com/fsharp/FAKE/pull/2372
* ENHANCEMENT: `ProcessUtils` now considers `PATHEXT` on windows - https://github.com/fsharp/FAKE/pull/2368
Expand Down Expand Up @@ -343,7 +345,7 @@

* ENHANCEMENT: Write NUnit arguments to an arguments file, fixes problems with long command lines - https://github.com/fsharp/FAKE/pull/2114
* ENHANCEMENT: Added `SpecFlowNext` module to `Fake.DotNet.Testing.SpecFlow` with improved API and missing arguments - https://github.com/fsharp/FAKE/pull/2143
* ENHANCEMENT (BREAKING): Updated and finalized the new (and undocumented) process API which is more unit-testable - https://github.com/fsharp/FAKE/pull/2131
* ENHANCEMENT (BREAKING): Updated and finalized the new (and undocumented) process API which is more unit-testable - https://github.com/fsharp/FAKE/pull/2131
* ENHANCEMENT: Updated `Fake.Testing.ReportGenerator` to include `ClassFilter` and `FileFilter` - https://github.com/fsharp/FAKE/pull/2120
* ENHANCEMENT: Improve TeamCity integrations - https://github.com/fsharp/FAKE/pull/2138
* ENHANCEMENT: Update `Fake.Tools.Pickles` to include latest CLI additions - https://github.com/fsharp/FAKE/pull/2133
Expand Down Expand Up @@ -938,7 +940,7 @@

## 4.64.17 - 2019-03-19

* Add support for MSBuild16
* Add support for MSBuild16

## 4.64.16 - 2019-02-15

Expand Down
31 changes: 20 additions & 11 deletions src/app/Fake.Sql.SqlPackage/Sql.SqlPackage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,31 @@ module SqlPackage =
Profile : string }

let internal validPaths =
let getSqlVersion (path:string) = path.Split '\\' |> Array.item 3 |> int
let getVsVersion (path: string) = (Path.GetDirectoryName path |> DirectoryInfo).Name |> int
let sql = !!(Environment.ProgramFilesX86 </> @"Microsoft SQL Server\**\DAC\bin\SqlPackage.exe") |> Seq.map(fun path -> path, getSqlVersion path)
let vs = !!(Environment.ProgramFilesX86 </> @"Microsoft Visual Studio*\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\*\SqlPackage.exe") |> Seq.map(fun path -> path, getVsVersion path)
let vs2017 = !!(Environment.ProgramFilesX86 </> @"Microsoft Visual Studio\**\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\*\SqlPackage.exe") |> Seq.map(fun path -> path, getVsVersion path)
let paths = [
let macOrLinux = Set [ PlatformID.MacOSX; PlatformID.Unix ]
if macOrLinux.Contains Environment.OSVersion.Platform then
!!"/usr/local/bin/sqlpackage"
|> Seq.map (fun path -> path, 15)
else
let getSqlVersion (path:string) = path.Split '\\' |> Array.item 3 |> int
let getVsVersion (path: string) = (Path.GetDirectoryName path |> DirectoryInfo).Name |> int
!!(Environment.ProgramFilesX86 </> @"Microsoft SQL Server\**\DAC\bin\SqlPackage.exe") |> Seq.map(fun path -> path, getSqlVersion path)
!!(Environment.ProgramFilesX86 </> @"Microsoft Visual Studio*\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\*\SqlPackage.exe") |> Seq.map(fun path -> path, getVsVersion path)
!!(Environment.ProgramFilesX86 </> @"Microsoft Visual Studio\**\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\*\SqlPackage.exe") |> Seq.map(fun path -> path, getVsVersion path)
!!(Environment.ProgramFiles </> @"Microsoft Visual Studio\**\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\SqlPackage.exe") |> Seq.map(fun path -> path, Reflection.Assembly.LoadFile(path).GetName().Version.Major)
]

[ sql; vs; vs2017 ]
|> List.collect Seq.toList
|> List.sortByDescending snd
|> List.map fst
paths
|> Seq.concat
|> Seq.sortByDescending snd
|> Seq.map fst
|> Seq.cache

/// The default DacPac deployment arguments.
let internal DefaultDeploymentArgs =
{ SqlPackageToolPath =
validPaths
|> List.tryHead
|> Seq.tryHead
|> defaultArg <| ""
Action = Deploy
AccessToken = ""
Expand Down Expand Up @@ -188,7 +197,7 @@ module SqlPackage =

if not (File.Exists args.SqlPackageToolPath) then
let paths =
if validPaths |> List.contains args.SqlPackageToolPath then validPaths
if validPaths |> Seq.contains args.SqlPackageToolPath then validPaths
else [ args.SqlPackageToolPath ]
failwithf "Unable to find a valid instance of SqlPackage.exe. Paths checked were: %A." paths

Expand Down