<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'Visual Studio' and 'XML'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Visual+Studio,XML&amp;orTags=0</link><description>Search results matching tags 'Visual Studio' and 'XML'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Querying Visual Studio project files using T-SQL and Powershell</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2011/01/17/querying-visual-studio-project-files.aspx</link><pubDate>Mon, 17 Jan 2011 21:11:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:32686</guid><dc:creator>jamiet</dc:creator><description>&lt;P&gt;Earlier today I had a need to get some information out of a Visual Studio project file and in this blog post I’m going to share a couple of ways of going about that because I’m pretty sure I won’t be the only person that ever wants to do this. The specific problem I was trying to solve was finding out how many objects in my database project (i.e. in my .dbproj file) had any warnings suppressed but the techniques discussed below will work pretty well for any Visual Studio project file because every such file is simply an XML document, hence it can be queried by anything that can query XML documents.&lt;/P&gt;
&lt;P&gt;Ever heard the phrase “when all you’ve got is hammer everything looks like a nail”? Well that’s me with querying stuff – if I can write SQL then I’m writing SQL. Here’s a little noddy database project I put together for demo purposes:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/image_003D882B.png"&gt;&lt;IMG style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title=image border=0 alt=image src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7E208961.png" width=211 height=244&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Two views and a stored procedure, nothing fancy. I suppressed warnings for [View1] &amp;amp; [Procedure1] and hence the pertinent part my project file looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;ItemGroup&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;nbsp;&lt;FONT color=#ff0000&gt;Include&lt;/FONT&gt;=&lt;FONT color=#000000&gt;"&lt;/FONT&gt;Schema Objects\Schemas\dbo\Views\View1.view.sql&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;Code&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT size=3&gt;&amp;lt;&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;4151,3276&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;Include&lt;/FONT&gt;=&lt;FONT color=#000000&gt;"&lt;/FONT&gt;Schema Objects\Schemas\dbo\Views\View2.view.sql&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;Code&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;Include&lt;/FONT&gt;=&lt;FONT color=#000000&gt;"&lt;/FONT&gt;Schema Objects\Schemas\dbo\Programmability\Stored Procedures\Procedure1.proc.sql&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;Code&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT size=3&gt;&amp;lt;&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;4151&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;ItemGroup&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;ItemGroup&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Note the &lt;STRONG&gt;&amp;lt;&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt; &lt;/STRONG&gt;elements – those are the bits of information that I am after.&lt;/P&gt;
&lt;P&gt;With &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/sqlxml/thread/2337b9bf-e123-4004-8af3-06d2b851c7e1/" target=_blank&gt;a lot of help&lt;/A&gt; from folks on the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/sqlxml/threads" target=_blank&gt;SQL Server XML forum&lt;/A&gt;&amp;nbsp; I came up with the following query that nailed what I was after. It reads the contents of the .dbproj file into a variable of type XML and then shreds it using T-SQL’s &lt;A href="http://msdn.microsoft.com/en-us/library/ms190798.aspx" target=_blank&gt;XML data type methods&lt;/A&gt;: &lt;/P&gt;
&lt;TABLE cellSpacing=0 cellPadding=2&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;CODE style="FONT-SIZE:12px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;DECLARE &lt;/SPAN&gt;&lt;SPAN style="COLOR:#434343;"&gt;@xml &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;XML&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT &lt;/SPAN&gt;&lt;SPAN style="COLOR:#434343;"&gt;@xml &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;CAST&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;pkgblob.BulkColumn &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS XML&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&amp;nbsp;&amp;nbsp; OPENROWSET&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;BULK &lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'C:\temp\QueryingProjectFileDemo\QueryingProjectFileDemo.dbproj' &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;-- &amp;lt;-Change this path! &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;single_blob&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;pkgblob &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;WITH &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;XMLNAMESPACES&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'http://schemas.microsoft.com/developer/msbuild/2003' &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;ns&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;REVERSE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;SUBSTRING&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;REVERSE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;ObjectPath&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;CHARINDEX&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'\'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;REVERSE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;ObjectPath&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)))) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[ObjectName] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[SuppressedWarnings] &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;( &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build.query&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'.'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[_node] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build.value&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'ns:SuppressWarnings[1]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'nvarchar(100)'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[SuppressedWarnings] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build.value&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'@Include'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'nvarchar(1000)'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[ObjectPath] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#434343;"&gt;@xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;.nodes&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'//ns:Build[ns:SuppressWarnings]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;R&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;q &lt;BR&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;And here’s the output:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/image_4E826AD5.png"&gt;&lt;IMG style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title=image border=0 alt=image src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7B9757A3.png" width=533 height=164&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And that’s it – an easy way of discovering which warnings have been suppressed and for which objects in your database projects. I won’t bother going over the code as it is fairly self-explanatory – peruse it at your leisure.&lt;/P&gt;
&lt;P&gt;Once I had the SQL above I figured I’d share it around a little in case it was ever useful to anyone else; hence I’m writing this blog post and I also posted it on the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vstsdb/threads" target=_blank&gt;Visual Studio Database Development Tools forum&lt;/A&gt; at &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/8eacbe76-c6d1-40e2-af15-044903a98c1d/?prof=required" target=_blank&gt;FYI: Discover which objects have had warnings suppressed&lt;/A&gt;. Luckily &lt;A href="http://social.msdn.microsoft.com/profile/kevin%20goode/?type=forum&amp;amp;referrer=http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/8eacbe76-c6d1-40e2-af15-044903a98c1d/?prof=required" target=_blank&gt;Kevin Goode&lt;/A&gt; saw the thread and he posted a different solution to the same problem, one that uses Powershell. The advantage of Kevin’s Powershell approach is that it is easy to analyse many .dbproj files at the same time. Below is Kevin’s code which I have tweaked &lt;EM&gt;ever so slightly&lt;/EM&gt; so that it produces the same results as my SQL script (I just want any object that had had a warning suppressed whereas Kevin was querying specifically for warning 4151):&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;cd&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;C:\Temp\QueryingProjectFileDemo\&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;cls&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$projects&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;ls&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-r&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-i&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; *.dbproj
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;Foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$project&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$projects&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;)
{
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;new-object&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;System.Xml.XmlDocument&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:#8b4513;"&gt;set_PreserveWhiteSpace&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$true&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; )
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:#8b4513;"&gt;Load&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$project&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;)

  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;#&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;$xpath = @{Start="/e:Project/e:ItemGroup/e:Build[e:SuppressWarnings=4151]/@Include"}&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;#&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;$xpath = @{Start="/e:Project/e:ItemGroup/e:Build[contains(e:SuppressWarnings,'4151')]/@Include"}&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xpath&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; @{Start&lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;/e:Project/e:ItemGroup/e:Build[e:SuppressWarnings]/@Include&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;}
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$ns&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; @{ e &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; }

  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; | &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;Select-Xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-XPath&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xpath&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;.Start  &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-Namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$ns&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; |&lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-Expand&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;Node&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; | &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-expand&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
}

&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;and here’s the output:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/image_60EABB8A.png"&gt;&lt;IMG style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title=image border=0 alt=image src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4716855B.png" width=765 height=102&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Nice reusable Powershell and SQL scripts – not bad for an evening’s work. Thank you to Kevin for allowing me to share his code.&lt;/P&gt;
&lt;P&gt;Don’t forget that these techniques can easily be adapted to query &lt;EM&gt;any&lt;/EM&gt; Visual Studio project file, they’re only XML documents after all! Doubtless many people out there already have code for doing this but nonetheless here is another offering to the great script library in the sky. Have fun!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://twitter.com/jamiet"&gt;@Jamiet&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This blog post was mentioned on &lt;/EM&gt;&lt;A href="http://channel9.msdn.com/Shows/This+Week+On+Channel+9/TWC9-AutoTuneNET-Portable-Libraries-Facebook--Azure-SQLR2-BI"&gt;&lt;EM&gt;This Week on Channel 9&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;. Fast forward to 10m49s.&lt;/EM&gt;&lt;/P&gt;</description></item></channel></rss>