MSBuild 拡張パックを使用して、.proj ファイルの行を置き換えています。複数の行を複数の行に置き換えています。変換を行っても、出力している行の最後にまだセミコロンがあります。
<ItemGroup>
    <TestFile Include="regextest.xml" />
    <MyLines Include ="%3CItemGroup%3E%0A"/>
    <MyLines Include ="%09%3CReference Include=%22Stuff%22%3E%0A" />
    <MyLines Include ="%09%09%3CHintPath%3E..\..\packages\secret.dll%3C/HintPath%3E%0A" />
    <MyLines Include ="%09%09%3CPrivate%3ETrue%3C/Private%3E%0A" />
    <MyLines Include ="%09%3C/Reference%3E%0A" />
    <MyLines Include ="%3C/ItemGroup%3E%0A" />
</ItemGroup>
<Target Name="Default">
    <MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace" 
      TextEncoding="ASCII" 
      RegexPattern="%3CProjectReference"
      RegexOptionList="IgnoreCase"
      Replacement="@(MyLines->'%(Identity)')"
      Files="@(TestFile)" />
</Target>
そして、これは出力です:
<ItemGroup>
;   <Reference Include="Stuff">
;       <HintPath>..\..\packages\secret.dll</HintPath>
;       <Private>True</Private>
;   </Reference>
;</ItemGroup>
変換せずにそれを行うと、それらもそこにあります。