Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dhayhak on github.
  • I am dlouhichi (https://keybase.io/dlouhichi) on keybase.
  • I have a public key ASB66p5pW1VODybEkhaUUWBWwV19sI0jLmKsPSziBkE7IAo

To claim this, I am signing this object:

Get-ChildItem *.csproj -Recurse | ForEach-Object {
$content = [xml] (Get-Content $_)
$xmlNameSpace = new-object System.Xml.XmlNamespaceManager($content.NameTable)
$xmlNameSpace.AddNamespace("p", "http://schemas.microsoft.com/developer/msbuild/2003")
# Set the ruleset file name in CodeAnalysisRuleSet, if not found
if (-not $content.Project.PropertyGroup[0].CodeAnalysisRuleSet) {
Write-Host "Setting CodeAnalysisRuleSet Variable in $_"
$featureElt = $content.CreateElement("CodeAnalysisRuleSet")
$featureElt.set_InnerText("codeAnalysis.ruleset")
<CodeAnalysisRuleSet>codeAnalysis.ruleset</CodeAnalysisRuleSet>
<Target Name="CodeAnalysisRuleset" BeforeTargets="PreBuildEvent">
<Exec Command="xcopy /Y &quot;$(SolutionDir)\PATH_TO_RULE_SET\codeAnalysis.ruleset&quot; &quot;$(ProjectDir)&quot;" />
</Target>