プロジェクトからファイルを除外するには、アプリケーションまたはVisual Studioプラグインを作成する必要があります。
- 再帰的
- オープンXmlDocumentオブジェクト
- XPathを使用(たとえば、XmlDocumentオブジェクトにロードすることにより、cprojファイルをあなたのコードツリー内のすべての.csprojファイルを検索:個人的に私はちょうど次のようにしますアプリを作成します.SelectSingleNode()/ SelectNodes())を使用して、該当するファイルのタグを検索します。
- だから、このようなセクションになるだろうノードを削除し、XmlDocument.Save
を使用してディスクへ出て、ファイルを保存します。
<ItemGroup>
<EmbeddedResource Include="licenses.licx" />
<EmbeddedResource Include="img.jpeg" />
</ItemGroup>
は次のようになります。
<ItemGroup>
<EmbeddedResource Include="licenses.licx" />
</ItemGroup>
を
ノードを見つけるXPathコードのサンプル:
XmlDocument csprojDoc; // this is the document you loaded your csproj XML into
XmlNamespaceManager xnm; // you'll need to build one of these because csproj files use namspaces in the XML
XmlNode excludeNode =
csprojDoc.SelectSingleNode("//ns:ItemGroup/ns:EmbeddedResource[@Include='img.jpeg']", xnm);
excludeNode.ParentNode.ChildNodes.Remove(excludeNode);
これは私のPowerShellスクリプトよりもはるかに優れているようです:-) – Shoban