Private/Cs/SolnProj/Edit-ProjectAddReference.ps1
<############################################################################ # Add csproj as reference to another csproj ############################################################################> Function Edit-ProjectAddReferencePrivate([string]$thisCsprojFile, [string]$referenceCsprojFile) { # Convert full path $referenceCsprojFile to path relative to $thisCsprojFile # Keep final subdir and file name, put ".." in the front [string]$referenceCsprojFileRelative = ".." + $referenceCsprojFile.substring((split-path (split-path $referenceCsprojFile)).length) Write-Host "### Fix $($thisCsprojFile) as dependent on $referenceCsprojFileRelative" $csprojXml = [xml] (type $thisCsprojFile) [xml]$useProjXml = @" <ItemGroup> <ProjectReference Include="$($referenceCsprojFileRelative)" /> </ItemGroup> "@ $csprojXml.project.AppendChild($csprojXml.ImportNode($useProjXml.ItemGroup, $true)) $csprojXml.Save($thisCsprojFile) } |