Install.ps1 1015 B

123456789101112131415161718
  1. param($installPath, $toolsPath, $package, $project)
  2. # This is the MSBuild targets file to add
  3. $targetsFile = [System.IO.Path]::Combine($toolsPath, $package.Id + '.targets')
  4. # Need to load MSBuild assembly if it's not loaded yet.
  5. Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  6. # Grab the loaded MSBuild project for the project
  7. $msbuild = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1
  8. # Make the path to the targets file relative.
  9. $projectUri = new-object Uri('file://' + $project.FullName)
  10. $targetUri = new-object Uri('file://' + $targetsFile)
  11. $relativePath = $projectUri.MakeRelativeUri($targetUri).ToString().Replace([System.IO.Path]::AltDirectorySeparatorChar, [System.IO.Path]::DirectorySeparatorChar)
  12. # Add the import and save the project
  13. $msbuild.Xml.AddImport($relativePath) | out-null
  14. $project.Save()