Nuget Powershell: how to add native dependencies? how to add files to a project inside a folder?
The SqlServerCompact package did something similar, copying the relevant dlls to the bin folder in the post build event. Here the relevant code:
File:install.ps1
param($installPath, $toolsPath, $package, $project)
. (Join-Path $toolsPath "GetSqlCEPostBuildCmd.ps1")
# Get the current Post Build Event cmd
$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value
# Append our post build command if it's not already there
if (!$currentPostBuildCmd.Contains($SqlCEPostBuildCmd)) {
$project.Properties.Item("PostBuildEvent").Value += $SqlCEPostBuildCmd
}
File:GetSqlCEPostBuildCmd.ps1
$solutionDir = [System.IO.Path]::GetDirectoryName($dte.Solution.FullName) + "\"
$path = $installPath.Replace($solutionDir, "`$(SolutionDir)")
$NativeAssembliesDir = Join-Path $path "NativeBinaries"
$x86 = $(Join-Path $NativeAssembliesDir "x86\*.*")
$x64 = $(Join-Path $NativeAssembliesDir "amd64\*.*")
$SqlCEPostBuildCmd = "
if not exist `"`$(TargetDir)x86`" md `"`$(TargetDir)x86`"
xcopy /s /y `"$x86`" `"`$(TargetDir)x86`"
if not exist `"`$(TargetDir)amd64`" md `"`$(TargetDir)amd64`"
xcopy /s /y `"$x64`" `"`$(TargetDir)amd64`""
I'd suggest you open the 4.0.8852.1 version of the SqlServerCompact Nuget package with NuGet Package Explorer (Microsoft Store, GitHub) and use it as a template. It worked for me.