Skip to content

Instantly share code, notes, and snippets.

@CosminLazar
Created February 21, 2015 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CosminLazar/99f2b78057f06c8f9b18 to your computer and use it in GitHub Desktop.
Save CosminLazar/99f2b78057f06c8f9b18 to your computer and use it in GitHub Desktop.
How not to modify the project from Install.ps1
#This script edits the project file and marks the talkfx-c.dll files to always be copied to the output directory
param($installPath, $toolsPath, $package, $project)
# Load project XML.
$doc = New-Object System.Xml.XmlDocument
$doc.Load($project.FullName)
$namespace = 'http://schemas.microsoft.com/developer/msbuild/2003'
# Find the node containing the file. The tag "Content" may be replace by "None" depending of the case, check your .csproj file.
$talkFXDlls = Select-Xml "//msb:Project/msb:ItemGroup/msb:Content[contains(@Include, 'talkfx-c.dll')]" $doc -Namespace @{msb = $namespace}
foreach($xmlNode in $talkFXDlls)
{
$nodeName = "CopyToOutputDirectory"
#Check if the property already exists, just in case.
$property = $xmlNode.Node.SelectSingleNode($nodeName)
if($property -eq $null)
{
$property = $doc.CreateElement($nodeName, $namespace)
$property.AppendChild($doc.CreateTextNode("Always"))
$xmlNode.Node.AppendChild($property)
}
}
# Save changes.
$doc.Save($project.FullName)
Write-Warning "If Visual Studio prompts you wether to Save As... or Discard, you need to chose Discard changes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment