Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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