You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SCJMapper-V2/packages/SharpDX.2.6.3/tools/Install.ps1

37 lines
1.7 KiB
PowerShell

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

param($installPath, $toolsPath, $package, $project)
"Installing [{0}] to project [{1}]" -f $package.Id, $project.FullName | Write-Host
# Load MSBuild assembly if its not loaded yet.
Add-Type -AssemblyName "Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
# Check that SharpDX.targets was correctly imported
$buildProject = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
$importsToRemove = $buildProject.Xml.Imports | Where-Object { $_.Project.Endswith('SharpDX.targets') }
if (!$importsToRemove)
{
throw ("SharpDX.targets import not found in project [{0}]" -f $project.FullName)
}
$sharpdx_package_bin_dir = $buildProject.GetProperty("SharpDXPackageBinDir").EvaluatedValue
$sharpdx_assembly_path = "{0}\{1}.dll" -f $sharpdx_package_bin_dir, $package.Id
# Add the assembly through the project in order for VS to update correctly the references in the IDE
$project.Object.References.Add($sharpdx_assembly_path)
# Find the references we just added
$sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude -eq $package.Id }
if (!$sharpdx_reference)
{
$sharpdx_reference = $buildProject.GetItems("Reference") | Where-Object { $_.EvaluatedInclude.StartsWith("{0}," -f $package.Id) }
}
if (!$sharpdx_reference)
{
throw ("Unable to find reference in project for assembly [{0}]" -f $package.Id)
}
# Replace the HintPath using the $(SharpDXPackageBinDir) variable provided by the SharpDX.targets
$sharpdx_reference.SetMetadataValue("HintPath", '$(SharpDXPackageBinDir)\{0}.dll' -f $package.Id)
# Save the project
$project.Save()