|
| 1 | +# Go compile the DLLs |
| 2 | +Set-Location ./dbatools-library |
| 3 | +Remove-Item .\project\dbatools\obj -Recurse -ErrorAction Ignore |
| 4 | +Remove-Item .\project\dbatools.Tests\lib -Recurse -ErrorAction Ignore |
| 5 | +Remove-Item .\project\dbatools.Tests\obj -Recurse -ErrorAction Ignore |
| 6 | +Get-ChildItem -Recurse lib | Remove-Item -Recurse -ErrorAction Ignore |
| 7 | +Get-ChildItem -Recurse temp | Remove-Item -Recurse -ErrorAction Ignore |
| 8 | +Push-Location ".\project" |
| 9 | +dotnet clean |
| 10 | +dotnet publish --configuration release --framework net6.0 --self-contained | Out-String -OutVariable build |
| 11 | +dotnet publish --configuration release --framework net462 --self-contained | Out-String -OutVariable build |
| 12 | +dotnet test --framework net462 --verbosity normal | Out-String -OutVariable test |
| 13 | +dotnet test --framework net6.0 --verbosity normal | Out-String -OutVariable test |
| 14 | +Pop-Location |
| 15 | + |
| 16 | +Get-ChildItem .\lib -Recurse -Include *.pdb | Remove-Item -Force |
| 17 | +Get-ChildItem .\lib -Recurse -Include *.xml | Remove-Item -Force |
| 18 | +Get-ChildItem .\lib\net462\ -Exclude *dbatools*, publish | Remove-Item -Force -Recurse |
| 19 | +Get-ChildItem .\lib\ -Include runtimes -Recurse | Remove-Item -Force -Recurse |
| 20 | +Get-ChildItem .\lib\*\dbatools.deps.json -Recurse | Remove-Item -Force |
| 21 | + |
| 22 | +if ($IsLinux -or $IsMacOs) { |
| 23 | + $tempdir = "/tmp" |
| 24 | +} else { |
| 25 | + $tempdir = "C:\temp" |
| 26 | +} |
| 27 | + |
| 28 | +$null = mkdir $tempdir -Force -ErrorAction Ignore |
| 29 | +$null = mkdir ./temp/dacfull -Force -ErrorAction Ignore |
| 30 | +$null = mkdir ./lib/sqlpackage/windows -Force -ErrorAction Ignore |
| 31 | +$null = mkdir ./lib/sqlpackage/mac -ErrorAction Ignore |
| 32 | +$null = mkdir ./temp/xe -ErrorAction Ignore |
| 33 | +$null = mkdir ./lib/third-party |
| 34 | +$null = mkdir ./lib/third-party/XESmartTarget |
| 35 | +$null = mkdir ./lib/third-party/bogus |
| 36 | +$null = mkdir ./lib/third-party/LumenWorks |
| 37 | +$null = mkdir ./lib/third-party/LumenWorks/netstandard2.0 |
| 38 | +$null = mkdir ./lib/third-party/LumenWorks/net461 |
| 39 | +$null = mkdir ./lib/third-party/bogus/netstandard2.0 |
| 40 | +$null = mkdir ./lib/third-party/bogus/net40 |
| 41 | +$null = mkdir ./temp/bogus |
| 42 | +$null = mkdir ./lib/net6.0/publish/win |
| 43 | + |
| 44 | +$ProgressPreference = "SilentlyContinue" |
| 45 | + |
| 46 | + |
| 47 | +Invoke-WebRequest -Uri https://aka.ms/sqlpackage-linux -OutFile .\temp\sqlpackage-linux.zip |
| 48 | +Invoke-WebRequest -Uri https://aka.ms/sqlpackage-macos -OutFile .\temp\sqlpackage-macos.zip |
| 49 | +Invoke-WebRequest -Uri https://aka.ms/dacfx-msi -OutFile .\temp\DacFramework.msi |
| 50 | +Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Bogus -OutFile .\temp\bogus.zip |
| 51 | +Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/LumenWorksCsvReader -OutFile .\temp\LumenWorksCsvReader.zip |
| 52 | +Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/v1.4.9/XESmartTarget_x64.msi -OutFile .\temp\XESmartTarget_x64.msi |
| 53 | + |
| 54 | +$ProgressPreference = "Continue" |
| 55 | + |
| 56 | +Expand-Archive -Path .\temp\sqlpackage-linux.zip -DestinationPath .\temp\linux |
| 57 | +Expand-Archive -Path .\temp\sqlpackage-macos.zip -DestinationPath .\temp\macos |
| 58 | +Expand-Archive -Path .\temp\LumenWorksCsvReader.zip -DestinationPath .\temp\LumenWorksCsvReader |
| 59 | +Expand-Archive -Path .\temp\bogus.zip -DestinationPath .\temp\bogus |
| 60 | + |
| 61 | +msiexec /a $(Resolve-Path .\temp\DacFramework.msi) /qb TARGETDIR=$(Resolve-Path .\temp\dacfull) |
| 62 | +Start-Sleep 3 |
| 63 | +msiexec /a $(Resolve-Path .\temp\XESmartTarget_x64.msi) /qb TARGETDIR=$(Resolve-Path .\temp\xe) |
| 64 | +Start-Sleep 3 |
| 65 | + |
| 66 | +$mac = 'libclrjit.dylib', 'libcoreclr.dylib', 'libhostfxr.dylib', 'libhostpolicy.dylib', 'libSystem.Native.dylib', 'libSystem.Security.Cryptography.Native.Apple.dylib', 'Microsoft.Data.Tools.Schema.Sql.dll', 'Microsoft.Data.Tools.Utilities.dll', 'Microsoft.IdentityModel.JsonWebTokens.dll', 'Microsoft.Win32.Primitives.dll', 'sqlpackage', 'sqlpackage.deps.json', 'sqlpackage.dll', 'sqlpackage.pdb', 'sqlpackage.runtimeconfig.json', 'sqlpackage.xml', 'System.Collections.Concurrent.dll', 'System.Collections.dll', 'System.Console.dll', 'System.Diagnostics.FileVersionInfo.dll', 'System.Diagnostics.StackTrace.dll', 'System.Diagnostics.TextWriterTraceListener.dll', 'System.Diagnostics.TraceSource.dll', 'System.Linq.dll', 'System.Memory.dll', 'System.Net.Http.Json.dll', 'System.Private.CoreLib.dll', 'System.Private.Xml.dll', 'System.Reflection.Metadata.dll', 'System.Runtime.dll', 'System.Runtime.Serialization.Json.dll', 'System.Security.Cryptography.Algorithms.dll', 'System.Security.Cryptography.Primitives.dll', 'System.Text.Json.dll', 'System.Threading.dll', 'System.Threading.Thread.dll', 'System.Xml.ReaderWriter.dll' |
| 67 | +$linux = 'libclrjit.so', 'libcoreclr.so', 'libcoreclrtraceptprovider.so', 'libhostfxr.so', 'libhostpolicy.so', 'libSystem.Native.so', 'libSystem.Security.Cryptography.Native.OpenSsl.so', 'Microsoft.Win32.Primitives.dll', 'System.Collections.Concurrent.dll', 'System.Collections.dll', 'System.Console.dll', 'System.Diagnostics.FileVersionInfo.dll', 'System.Diagnostics.StackTrace.dll', 'System.Diagnostics.TextWriterTraceListener.dll', 'System.Diagnostics.TraceSource.dll', 'System.Linq.dll', 'System.Memory.dll', 'System.Net.Http.Json.dll', 'System.Private.CoreLib.dll', 'System.Private.Xml.dll', 'System.Reflection.Metadata.dll', 'System.Runtime.dll', 'System.Runtime.Serialization.Json.dll', 'System.Security.Cryptography.Algorithms.dll', 'System.Text.Json.dll', 'System.Threading.dll', 'System.Threading.Thread.dll', 'System.Xml.ReaderWriter.dll', 'sqlpackage', 'sqlpackage.dll', 'sqlpackage.deps.json', 'sqlpackage.runtimeconfig.json' |
| 68 | +$winfull = 'Microsoft.Data.SqlClient.dll', 'Microsoft.Data.SqlClient.SNI.x64.dll', 'Microsoft.Data.SqlClient.SNI.x86.dll', 'System.Threading.Tasks.Dataflow.dll', 'Azure.Core.dll', 'Azure.Identity.dll', 'Microsoft.Build.dll', 'Microsoft.Build.Framework.dll', 'Microsoft.Data.Tools.Schema.Sql.dll', 'Microsoft.Data.Tools.Utilities.dll', 'Microsoft.SqlServer.Dac.dll', 'Microsoft.SqlServer.Dac.Extensions.dll', 'Microsoft.SqlServer.TransactSql.ScriptDom.dll', 'Microsoft.SqlServer.Types.dll', 'System.Memory.Data.dll', 'System.Resources.Extensions.dll', 'System.Security.SecureString.dll', 'sqlpackage.exe', 'sqlpackage.dll', 'libhostfxr.so', 'libhostpolicy.so', 'sqlpackage.runtimeconfig.json', 'sqlpackage.deps.json', 'hostpolicy.dll', 'hostfxr.dll', 'sqlpackage.dll' |
| 69 | + |
| 70 | +Get-ChildItem "./temp/dacfull/" -Recurse | Where-Object Name -in $winfull | Copy-Item -Destination lib/sqlpackage/windows |
| 71 | +Get-ChildItem "./temp/xe/*.dll" -Recurse | Copy-Item -Destination lib/third-party/XESmartTarget |
| 72 | +Get-ChildItem "./temp/bogus/*/netstandard2.0/bogus.dll" -Recurse | Copy-Item -Destination lib/third-party/bogus/netstandard2.0/bogus.dll |
| 73 | +Get-ChildItem "./temp/bogus/*/net40/bogus.dll" -Recurse | Copy-Item -Destination lib/third-party/bogus/net40/bogus.dll |
| 74 | + |
| 75 | +Copy-Item .\temp\LumenWorksCsvReader\lib\net461\LumenWorks.Framework.IO.dll -Destination ./lib/third-party/LumenWorks/net461/LumenWorks.Framework.IO.dll |
| 76 | + |
| 77 | +Copy-Item .\temp\LumenWorksCsvReader\lib\netstandard2.0\LumenWorks.Framework.IO.dll -Destination ./lib/third-party/LumenWorks/netstandard2.0/LumenWorks.Framework.IO.dll |
| 78 | + |
| 79 | +Get-ChildItem lib/net462/dbatools.dll | Remove-Item -Force |
| 80 | +Get-ChildItem lib/net6.0/dbatools.dll | Remove-Item -Force |
| 81 | +Get-ChildItem lib/net462/dbatools.dll.config | Remove-Item -Force |
| 82 | +Get-ChildItem lib/net6.0/dbatools.dll.config | Remove-Item -Force |
| 83 | + |
| 84 | +Get-ChildItem ./temp/linux | Where-Object Name -in $linux | Copy-Item -Destination lib/net6.0 |
| 85 | +Get-ChildItem ./temp/macos | Where-Object Name -in $mac | Copy-Item -Destination lib/sqlpackage/mac/ |
| 86 | + |
| 87 | +Register-PackageSource -provider NuGet -name nugetRepository -Location https://www.nuget.org/api/v2 -Trusted -ErrorAction Ignore |
| 88 | + |
| 89 | +$parms = @{ |
| 90 | + Provider = "Nuget" |
| 91 | + Destination = "$tempdir\nuget" |
| 92 | + Source = "nugetRepository" |
| 93 | + Scope = "CurrentUser" |
| 94 | + Force = $true |
| 95 | + SkipDependencies = $true |
| 96 | +} |
| 97 | + |
| 98 | +$parms.Name = "System.Resources.Extensions" |
| 99 | +$parms.RequiredVersion = "6.0.0.0" |
| 100 | +Install-Package @parms |
| 101 | + |
| 102 | +$parms.Name = "Microsoft.SqlServer.DacFx" |
| 103 | +$parms.RequiredVersion = "161.6319.0-preview" |
| 104 | +Install-Package @parms |
| 105 | + |
| 106 | +$parms.Name = "Microsoft.SqlServer.SqlManagementObjects" |
| 107 | +$parms.RequiredVersion = "170.7.0-preview" |
| 108 | +Install-Package @parms |
| 109 | + |
| 110 | +$parms.Name = "Microsoft.Data.SqlClient" |
| 111 | +$parms.RequiredVersion = "5.0.1" |
| 112 | +Install-Package @parms |
| 113 | + |
| 114 | +$parms.Name = "Microsoft.Data.SqlClient.SNI.runtime" |
| 115 | +$parms.RequiredVersion = "5.0.1" |
| 116 | +Install-Package @parms |
| 117 | + |
| 118 | +$parms.Name = "Microsoft.Identity.Client" |
| 119 | +$parms.RequiredVersion = "4.45.0" |
| 120 | +Install-Package @parms |
| 121 | + |
| 122 | +$parms.Name = "Azure.Identity" |
| 123 | +$parms.RequiredVersion = "1.6.0" |
| 124 | +Install-Package @parms |
| 125 | + |
| 126 | +Copy-Item "$tempdir\nuget\Microsoft.Data.SqlClient.5.0.1\runtimes\unix\lib\netcoreapp3.1\Microsoft.Data.SqlClient.dll" -Destination lib/net6.0/publish |
| 127 | +Copy-Item "$tempdir\nuget\Microsoft.Identity.Client.4.45.0\lib\net461\Microsoft.Identity.Client.dll" -Destination lib/net462/publish/ |
| 128 | +Copy-Item "$tempdir\nuget\Microsoft.Data.SqlClient.5.0.1\runtimes\win\lib\netcoreapp3.1\Microsoft.Data.SqlClient.dll" -Destination lib/net6.0/publish/win |
| 129 | +Copy-Item "$tempdir\nuget\Microsoft.Identity.Client.4.45.0\lib\netcoreapp2.1\Microsoft.Identity.Client.dll" -Destination lib/net6.0/publish/win |
| 130 | +Copy-Item "$tempdir\nuget\Microsoft.Data.SqlClient.SNI.runtime.5.0.1\runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" -Destination lib/net6.0/publish/win |
| 131 | +Copy-Item "$tempdir\nuget\Microsoft.Data.SqlClient.SNI.runtime.5.0.1\runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" -Destination lib/net462/publish/ |
| 132 | + |
| 133 | +Copy-Item "replication/Microsoft.SqlServer.Rmo.dll" -Destination lib/net462/publish/ |
| 134 | +Copy-Item "replication/Microsoft.SqlServer.Replication.dll" -Destination lib/net462/publish/ |
| 135 | +Copy-Item "replication/Microsoft.SqlServer.Rmo.dll" -Destination lib/net6.0/publish/ |
| 136 | +Copy-Item "replication/Microsoft.SqlServer.Replication.dll" -Destination lib/net6.0/publish/ |
| 137 | + |
| 138 | +Move-Item -Path lib/net6.0/publish/* -Destination lib/net6.0/ |
| 139 | +Move-Item -Path lib/net462/publish/* -Destination lib/net462/ |
| 140 | + |
| 141 | +Remove-Item -Path lib/net6.0/publish -Recurse -ErrorAction Ignore |
| 142 | +Remove-Item -Path lib/net462/publish -Recurse -ErrorAction Ignore |
| 143 | + |
| 144 | +Remove-Item -Path lib/*.xml -Recurse -ErrorAction Ignore |
| 145 | +Remove-Item -Path lib/*.pdb -Recurse -ErrorAction Ignore |
| 146 | + |
| 147 | +Get-ChildItem -Directory -Path .\lib\net462 | Where-Object Name -notin 'x64', 'x86', 'win', 'mac', 'macos' | Remove-Item -Recurse |
| 148 | +Get-ChildItem -Directory -Path .\lib\net6.0 | Where-Object Name -notin 'x64', 'x86', 'win', 'mac', 'macos' | Remove-Item -Recurse |
| 149 | + |
| 150 | +Import-Module ./dbatools-library/dbatools-library.psd1 -Force |
0 commit comments