3

I need to write NuGet package install.ps1 script that will copy native dll files to output directory, but I can't find the way to get the output folder path.

I think the solution is to use something like the following:

$solutionDir = [System.IO.Path]::GetDirectoryName($dte.Solution.FullName) + "\"

How can I get the output directory path through PowerShell?

2 Answers 2

3

By "output directory" do you mean output directory for a project? If so, you can iterate through the projects to find one by index and then grab the project's base dir like so (assuming you've determined the project you're interested in is at index 3:

 $project = $dte.Solution.Projects.Item(3)
 ($project.Properties | Where Name -match FullPath).Value

Then to get the build path (bin\debug or bin\release) you do this:

($project.ConfigurationManager.ActiveConfiguration.Properties | Where Name -match OutputPath).Value

You can also access the active project in the solution like so:

 $project = $dte.ActiveSolutionProjects
Sign up to request clarification or add additional context in comments.

Comments

1

I started "walking up" until I found it:

param($installPath, $toolsPath, $package, $project)
if ($project -eq $null) {
$project = Get-Project
}


Write-Host "installPath:" "${installPath}"
Write-Host "toolsPath:" "${toolsPath}"
Write-Host "package:" "${package}"
<# Write-Host "project:" "${project}" #>
Write-Host " "

<# Recursively look for a .sln file starting with the installPath #>
$parentFolder = (get-item $installPath)
do {
        $parentFolderFullName = $parentFolder.FullName

        $latest = Get-ChildItem -Path $parentFolderFullName -File -Filter *.sln | Select-Object -First 1
        if ($latest -ne $null) {
            $latestName = $latest.name
            Write-Host "${latestName}"
        }

        if ($latest -eq $null) {
            $parentFolder = $parentFolder.parent    
        }
}
while ($parentFolder -ne $null -and $latest -eq $null)
<# End recursive search for .sln file #>


if ( $parentFolder -ne $null -and $latest -ne $null )
{
    <# Create a base directory to store Solution-Level items #>
    $myFolderFullName = $parentFolder.FullName
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.