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

update library #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions build/build-core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ if (-not $scriptroot) {
$root = Split-Path -Path $scriptroot
Push-Location "$root/project"

dotnet clean
dotnet publish --configuration release --verbosity diag --framework net8.0 | Out-String -OutVariable build
dotnet test --configuration release --verbosity diag --framework net8.0 | Out-String -OutVariable test

dotnet publish --configuration release --framework net6.0 | Out-String -OutVariable build
dotnet test --framework net6.0 --verbosity normal | Out-String -OutVariable test
## the build is now in dbatools.library/lib
Pop-Location

Remove-Item -Path lib/dbatools.xml
Get-ChildItem -Path lib/net6.0 -File | Remove-Item
Move-Item -Path lib/net6.0/publish/* -Destination lib/ #-ErrorAction Ignore
Remove-Item -Path lib/net6.0 -Recurse -ErrorAction Ignore
Get-ChildItem -Path lib/net8.0 -File | Remove-Item
Move-Item -Path lib/net8.0/publish/* -Destination lib/ #-ErrorAction Ignore
Remove-Item -Path lib/net8.0 -Recurse -ErrorAction Ignore
#publish got moved to lib


Get-ChildItem ./lib -Recurse -Include *.pdb | Remove-Item
Get-ChildItem ./lib -Recurse -Include *.xml | Remove-Item
Expand All @@ -38,15 +42,18 @@ if ($IsLinux -or $IsMacOs) {
$null = mkdir ./temp
$null = mkdir ./temp/dacfull
$null = mkdir ./temp/xe
$null = mkdir ./temp/bogus
$null = mkdir ./temp/linux

$null = mkdir ./third-party
$null = mkdir ./third-party/XESmartTarget
$null = mkdir ./third-party/bogus
$null = mkdir ./third-party/LumenWorks
$null = mkdir ./temp/bogus
$null = mkdir ./temp/linux

$null = mkdir ./lib/win
$null = mkdir ./lib/mac
$null = mkdir ./lib/win-sqlclient
$null = mkdir ./lib/win-sqlclient-x86
} else {
$tempdir = "C:/temp"
$null = New-Item -ItemType Directory $tempdir -ErrorAction Ignore
Expand All @@ -60,6 +67,7 @@ if ($IsLinux -or $IsMacOs) {
$null = New-Item -ItemType Directory ./lib/win
$null = New-Item -ItemType Directory ./lib/mac
$null = New-Item -ItemType Directory ./lib/win-sqlclient
$null = New-Item -ItemType Directory ./lib/win-sqlclient-x86
}


Expand All @@ -69,10 +77,10 @@ $ProgressPreference = "SilentlyContinue"

Invoke-WebRequest -Uri https://aka.ms/sqlpackage-linux -OutFile ./temp/sqlpackage-linux.zip
Invoke-WebRequest -Uri https://aka.ms/sqlpackage-macos -OutFile ./temp/sqlpackage-macos.zip
Invoke-WebRequest -Uri https://aka.ms/dacfx-msi -OutFile .\temp\DacFramework.msi
Invoke-WebRequest -Uri https://aka.ms/dacfx-msi -OutFile ./temp/DacFramework.msi
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Bogus -OutFile ./temp/bogus.zip
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/LumenWorksCsvReader -OutFile ./temp/LumenWorksCsvReader.zip
Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/v1.4.9/XESmartTarget_x64.msi -OutFile ./temp/XESmartTarget_x64.msi
Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/v1.5.7/XESmartTarget_x64.msi -OutFile ./temp/XESmartTarget_x64.msi

$ProgressPreference = "Continue"

Expand Down Expand Up @@ -104,24 +112,47 @@ $parms = @{
}

$parms.Name = "Microsoft.Data.SqlClient"
$parms.RequiredVersion = "5.1.4"
$parms.RequiredVersion = "5.2.2"
$null = Install-Package @parms

$parms.Name = "Microsoft.Data.SqlClient.SNI.runtime"
$parms.RequiredVersion = "5.2.0"
$null = Install-Package @parms

$parms.Name = "Microsoft.Identity.Client"
$parms.RequiredVersion = "4.53.0"
$parms.RequiredVersion = "4.67.1"
$null = Install-Package @parms

$parms.Name = "Microsoft.IdentityModel.Abstractions"
$parms.RequiredVersion = "8.3.1"
$null = Install-Package @parms

Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.5.1.4/runtimes/unix/lib/net6.0/Microsoft.Data.SqlClient.dll" -Destination lib
Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.5.1.4/runtimes/win/lib/net6.0/Microsoft.Data.SqlClient.dll" -Destination lib/win-sqlclient/
Copy-Item "$tempdir/nuget/Microsoft.Identity.Client.4.53.0/lib/net6.0/Microsoft.Identity.Client.dll" -Destination lib/win-sqlclient/ #Maybe this will be a problem, i dont know
$parms.Name = "Azure.Core"
$parms.RequiredVersion = "1.38.0"
$null = Install-Package @parms


# README cl: this dll is already there, as we're building dbatools csproj whose dependencies are already included !?
Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.5.2.2/runtimes/unix/lib/net8.0/Microsoft.Data.SqlClient.dll" -Destination lib
# Copy to the 'x64' directory
Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.5.2.2/runtimes/win/lib/net8.0/Microsoft.Data.SqlClient.dll" -Destination lib/win-sqlclient/
Copy-Item "$tempdir/nuget/Microsoft.Identity.Client.4.67.1/lib/net8.0/Microsoft.Identity.Client.dll" -Destination lib/win-sqlclient/
Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.SNI.runtime.5.2.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll" -Destination lib/win-sqlclient/


# Copy to the 'x86' directory, but with a different SNI DLL file. Remember,the SNI file is not managed code, it's _native_.
Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.5.2.2/runtimes/win/lib/net8.0/Microsoft.Data.SqlClient.dll" -Destination lib/win-sqlclient-x86/
Copy-Item "$tempdir/nuget/Microsoft.Identity.Client.4.67.1/lib/net8.0/Microsoft.Identity.Client.dll" -Destination lib/win-sqlclient-x86/
Copy-Item "$tempdir/nuget/Microsoft.Data.SqlClient.SNI.runtime.5.2.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll" -Destination lib/win-sqlclient-x86/



Copy-Item "$tempdir/nuget/Azure.Core.1.38.0/lib/net6.0/Azure.Core.dll" -Destination lib/
Copy-Item "$tempdir/nuget/Microsoft.IdentityModel.Abstractions.8.3.1/lib/net8.0/Microsoft.IdentityModel.Abstractions.dll" -Destination lib/

Copy-Item ./temp/linux/* -Destination lib -Exclude (Get-ChildItem lib -Recurse) -Recurse -Include *.exe, *.config -Verbose


Copy-Item "./var/misc/core/*.dll" -Destination ./lib/
Copy-Item "./var/misc/both/*.dll" -Destination ./lib/
Copy-Item "./var/third-party-licenses" -Destination ./ -Recurse
Expand All @@ -131,7 +162,7 @@ $linux = 'libclrjit.so', 'libcoreclr.so', 'libhostfxr.so', 'libhostpolicy.so', '
$sqlp = Get-ChildItem ./temp/linux/* -Exclude (Get-ChildItem lib -Recurse) | Where-Object Name -in $linux
Copy-Item -Path $sqlp.FullName -Destination ./lib/

Get-ChildItem -Directory -Path ./lib | Where-Object Name -notin 'win-sqlclient', 'x64', 'x86', 'win', 'mac', 'macos' | Remove-Item -Recurse
Get-ChildItem -Directory -Path ./lib | Where-Object Name -notin 'win-sqlclient', 'win-sqlclient-x86', 'x64', 'x86', 'win', 'mac', 'macos' | Remove-Item -Recurse

Get-ChildItem ./lib, ./lib/win, ./lib/mac | Where-Object BaseName -in (Get-ChildItem /opt/microsoft/powershell/7).BaseName -OutVariable files

Expand All @@ -150,7 +181,7 @@ if ($xmlpdb) {
Remove-Item -Path $xmlpdb -Recurse -ErrorAction Ignore
}

#Import-Module ./dbatools.core.library.psd1
#Import-Module ./dbatools.library.psd1

<#
if ((Get-ChildItem -Path C:\gallery\dbatools.library\core -ErrorAction Ignore)) {
Expand Down
40 changes: 34 additions & 6 deletions build/build-full.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri https://aka.ms/dacfx-msi -OutFile .\temp\DacFramework.msi
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Bogus -OutFile .\temp\bogus.zip
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/LumenWorksCsvReader -OutFile .\temp\LumenWorksCsvReader.zip
Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/v1.4.9/XESmartTarget_x64.msi -OutFile .\temp\XESmartTarget_x64.msi
Invoke-WebRequest -Uri https://github.com/spaghettidba/XESmartTarget/releases/download/v1.5.7/XESmartTarget_x64.msi -OutFile .\temp\XESmartTarget_x64.msi

$ProgressPreference = "Continue"
7z x .\temp\LumenWorksCsvReader.zip "-o.\temp\LumenWorksCsvReader"
Expand Down Expand Up @@ -79,19 +79,32 @@ $parms = @{
}

$parms.Name = "Microsoft.Data.SqlClient"
$parms.RequiredVersion = "5.1.4"
$parms.RequiredVersion = "5.2.2"
$null = Install-Package @parms

$parms.Name = "Microsoft.Data.SqlClient.SNI.runtime"
$parms.RequiredVersion = "5.2.0"
$null = Install-Package @parms

$parms.Name = "Microsoft.Identity.Client"
$parms.RequiredVersion = "4.53.0"
$parms.RequiredVersion = "4.67.1"
$null = Install-Package @parms

Copy-Item "$tempdir\nuget\Microsoft.Identity.Client.4.53.0\lib\net461\Microsoft.Identity.Client.dll" -Destination lib/
$parms.Name = "Microsoft.IdentityModel.Abstractions"
$parms.RequiredVersion = "8.3.1"
$null = Install-Package @parms

$parms.Name = "Azure.Core"
$parms.RequiredVersion = "1.38.0"
$null = Install-Package @parms



Copy-Item "$tempdir\nuget\Microsoft.Identity.Client.4.67.1\lib\net462\Microsoft.Identity.Client.dll" -Destination lib/
Copy-Item "$tempdir\nuget\Microsoft.Data.SqlClient.SNI.runtime.5.2.0\runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" -Destination lib/
Copy-Item "$tempdir\nuget\Azure.Core.1.38.0\lib\net461\Azure.Core.dll" -Destination lib/
Copy-Item "$tempdir\nuget\Microsoft.IdentityModel.Abstractions.8.3.1\lib\net462\Microsoft.IdentityModel.Abstractions.dll" -Destination lib/



Copy-Item "./var/misc/core/*.dll" -Destination ./lib/
Expand All @@ -111,7 +124,7 @@ if ((Get-ChildItem -Path C:\gallery\dbatools.library -ErrorAction Ignore)) {
#$null = mkdir C:\gallery\dbatools.library\desktop\x86
#$null = mkdir C:\gallery\dbatools.library\desktop\x64
$null = robocopy c:\github\dbatools.library C:\gallery\dbatools.library /S /XF actions-build.ps1 .markdownlint.json *.psproj* *.git* *.yml *.md dac.ps1 build*.ps1 dbatools-core*.* /XD .git .github Tests .vscode project temp runtime runtimes replication var opt | Out-String | Out-Null

Remove-Item c:\gallery\dbatools.library\dac.ps1 -ErrorAction Ignore
Remove-Item c:\gallery\dbatools.library\dbatools.core.library.psd1 -ErrorAction Ignore
Copy-Item C:\github\dbatools.library\dbatools.library.psd1 C:\gallery\dbatools.library
Expand All @@ -134,4 +147,19 @@ already there
#>

#(Get-Item C:\github\dbatools.library\lib\Microsoft.Data.Tools.Schema.Sql.dll).VersionInfo.FileVersion
#(Get-Item C:\github\dbatools.library\lib\Microsoft.Data.Tools.Utilities.dll).VersionInfo.FileVersion
#(Get-Item C:\github\dbatools.library\lib\Microsoft.Data.Tools.Utilities.dll).VersionInfo.FileVersion

<#

$script:instance1 = $script:instance2 = "localhost"
Set-DbatoolsConfig -FullName sql.connection.trustcert -Value $true
$db = Get-DbaDatabase -SqlInstance $script:instance1 -Database dbatoolsci_publishdacpac
$publishprofile = New-DbaDacProfile -SqlInstance $script:instance1 -Database dbatoolsci_publishdacpac -Path C:\temp
$extractOptions = New-DbaDacOption -Action Export
$extractOptions.ExtractAllTableData = $true
$dacpac = Export-DbaDacPackage -SqlInstance $script:instance1 -Database dbatoolsci_publishdacpac -DacOption $extractOptions
$dacpac
$dacpac | Publish-DbaDacPackage -PublishXml $publishprofile.FileName -Database butt -SqlInstance $script:instance2 -Confirm:$false -Verbose
$Error | Select-Object *

#>
2 changes: 1 addition & 1 deletion dbatools.library.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
@{
# Version number of this module.
ModuleVersion = '2024.3.9'
ModuleVersion = '2025.1.30'

# ID used to uniquely identify this module
GUID = '00b61a37-6c36-40d8-8865-ac0180288c84'
Expand Down
10 changes: 5 additions & 5 deletions dbatools.library.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ if ($PSVersionTable.PSEdition -ne "Core") {
}

if ($IsWindows -and $PSVersionTable.PSEdition -eq "Core") {
$sqlclient = [System.IO.Path]::Combine($script:libraryroot, "lib", "win-sqlclient", "Microsoft.Data.SqlClient.dll")
if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
$sqlclient = [System.IO.Path]::Combine($script:libraryroot, "lib", "win-sqlclient-x86", "Microsoft.Data.SqlClient.dll")
} else {
$sqlclient = [System.IO.Path]::Combine($script:libraryroot, "lib", "win-sqlclient", "Microsoft.Data.SqlClient.dll")
}
} else {
$sqlclient = [System.IO.Path]::Combine($script:libraryroot, "lib", "Microsoft.Data.SqlClient.dll")
}
Expand All @@ -109,8 +113,6 @@ if ($PSVersionTable.PSEdition -eq "Core") {
'Microsoft.SqlServer.Dac',
'Microsoft.SqlServer.Smo',
'Microsoft.SqlServer.SmoExtended',
'Microsoft.SqlServer.SqlWmiManagement',
'Microsoft.SqlServer.WmiEnum',
'Microsoft.SqlServer.Management.RegisteredServers',
'Microsoft.SqlServer.Management.Collector',
'Microsoft.SqlServer.Management.XEvent',
Expand All @@ -126,8 +128,6 @@ if ($PSVersionTable.PSEdition -eq "Core") {
'Microsoft.SqlServer.Dac',
'Microsoft.SqlServer.Smo',
'Microsoft.SqlServer.SmoExtended',
'Microsoft.SqlServer.SqlWmiManagement',
'Microsoft.SqlServer.WmiEnum',
'Microsoft.SqlServer.Management.RegisteredServers',
'Microsoft.SqlServer.Management.IntegrationServices',
'Microsoft.SqlServer.Management.Collector',
Expand Down
2 changes: 1 addition & 1 deletion project/dbatools.Tests/dbatools.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Dataplat.Dbatools</RootNamespace>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
23 changes: 14 additions & 9 deletions project/dbatools/dbatools.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Dataplat.Dbatools</RootNamespace>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<AssemblyTitle>dbatools</AssemblyTitle>
<Company>Dataplat</Company>
<Product>dbatools</Product>
Expand Down Expand Up @@ -42,23 +42,28 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Identity.Client" Version="4.56.0" />
<PackageReference Include="System.Resources.Extensions" Version="7.0.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="7.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.4" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="170.18.0" />
<PackageReference Include="Microsoft.SqlServer.XEvent.XELite" Version="2023.1.30.3" />
<PackageReference Include="Microsoft.SqlServer.DacFx" Version="162.0.52" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.67.1" />
<PackageReference Include="System.Resources.Extensions" Version="9.0.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="9.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="172.52.0" />
<PackageReference Include="Microsoft.SqlServer.XEvent.XELite" Version="2024.2.5.1" />
<PackageReference Include="Microsoft.SqlServer.DacFx" Version="162.5.57" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Management.Automation" Version="7.2.6" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="System.Management.Automation">
<Version>7.4.6</Version>
</PackageReference>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion project/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.419"
"version": "8.0.*"
}
}
Loading