<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Sayed Ibrahim Hashimi - MSBuild, C#, Visual Studio, Training, and more</title>
    <link>http://sedodream.com/</link>
    <description>MSBuild, C#, Visual Studio and more</description>
    <language>en-us</language>
    <copyright>Sayed Ibrahim Hashimi</copyright>
    <lastBuildDate>Fri, 23 Jul 2010 07:24:45 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>sayed.hashimi@gmail.com</managingEditor>
    <webMaster>sayed.hashimi@gmail.com</webMaster>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Do you have a great idea for the next version of Visual Studio and you want to get
your voice heard? Now is your chance! Go to twitter and post a message stating your
request with the hash tag <a href="http://twitter.com/#search?q=%23vswish">#vswish</a> and
we will take a look at it. We are listening to that channel so please do submit your
feedback.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1" />
      </body>
      <title>Visual Studio Ideas</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1.aspx</guid>
      <link>http://sedodream.com/2010/07/23/VisualStudioIdeas.aspx</link>
      <pubDate>Fri, 23 Jul 2010 07:24:45 GMT</pubDate>
      <description>&lt;p&gt;
Do you have a great idea for the next version of Visual Studio and you want to get
your voice heard? Now is your chance! Go to twitter and post a message stating your
request with the hash tag &lt;a href="http://twitter.com/#search?q=%23vswish"&gt;#vswish&lt;/a&gt; and
we will take a look at it. We are listening to that channel so please do submit your
feedback.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1.aspx</comments>
      <category>feature-request</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=d1844a46-3319-401a-81f6-b4be5b3bc5c0</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,d1844a46-3319-401a-81f6-b4be5b3bc5c0.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,d1844a46-3319-401a-81f6-b4be5b3bc5c0.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d1844a46-3319-401a-81f6-b4be5b3bc5c0</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m happy to say that I was offered, and accepted, a position on the Web Platform
and Tools team with Microsoft. I will be a <a href="http://blogs.msdn.com/b/techtalk/archive/2005/12/16/504872.aspx">Program
Manager</a> on that team. In a nutshell I will be responsible for helping to make
development easier for web developers using .NET and Visual Studio. Its a very interesting
role and I’m gonna be pretty challenged in the next few months to adapt to my new
role. The Web Platform and Tools team has a bunch of tools that they are responsible
for, and one of the is the <a href="http://www.iis.net/download/webdeploy">Web Deployment
Tool</a>. I think that this will be one of the areas that I will be working in, so
if you have any ideas feel free to drop me a line here or privately at sayed –DOT—hashimi
[AT] gmail –DOT—com. I will start in this role in about 2 weeks.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=d1844a46-3319-401a-81f6-b4be5b3bc5c0" />
      </body>
      <title>Joining Microsoft</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,d1844a46-3319-401a-81f6-b4be5b3bc5c0.aspx</guid>
      <link>http://sedodream.com/2010/06/10/JoiningMicrosoft.aspx</link>
      <pubDate>Thu, 10 Jun 2010 03:50:30 GMT</pubDate>
      <description>&lt;p&gt;
I’m happy to say that I was offered, and accepted, a position on the Web Platform
and Tools team with Microsoft. I will be a &lt;a href="http://blogs.msdn.com/b/techtalk/archive/2005/12/16/504872.aspx"&gt;Program
Manager&lt;/a&gt; on that team. In a nutshell I will be responsible for helping to make
development easier for web developers using .NET and Visual Studio. Its a very interesting
role and I’m gonna be pretty challenged in the next few months to adapt to my new
role. The Web Platform and Tools team has a bunch of tools that they are responsible
for, and one of the is the &lt;a href="http://www.iis.net/download/webdeploy"&gt;Web Deployment
Tool&lt;/a&gt;. I think that this will be one of the areas that I will be working in, so
if you have any ideas feel free to drop me a line here or privately at sayed –DOT—hashimi
[AT] gmail –DOT—com. I will start in this role in about 2 weeks.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=d1844a46-3319-401a-81f6-b4be5b3bc5c0" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,d1844a46-3319-401a-81f6-b4be5b3bc5c0.aspx</comments>
      <category>Employment</category>
      <category>Microsoft</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=68b7ea19-35ad-4249-8106-b5c7e9299c3f</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,68b7ea19-35ad-4249-8106-b5c7e9299c3f.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,68b7ea19-35ad-4249-8106-b5c7e9299c3f.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=68b7ea19-35ad-4249-8106-b5c7e9299c3f</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <title>Visual Studio file encoding issues: ∩╗┐</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,68b7ea19-35ad-4249-8106-b5c7e9299c3f.aspx</guid>
      <link>http://sedodream.com/2010/06/10/VisualStudioFileEncodingIssues.aspx</link>
      <pubDate>Thu, 10 Jun 2010 03:24:01 GMT</pubDate>
      <description>&lt;p&gt;
Have you ever executed a .cmd file (or .bat) file and received a message that looks
like the following at the top of your script (including image for compatibility) &lt;strong&gt;&lt;font size="4"&gt;∩╗┐&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_thumb.png" width="52" height="34" /&gt;&lt;/a&gt; &lt;/font&gt;&lt;/strong&gt;?
This was really annoying to me until I find out what was happening. I noticed that
Visual Studio (2010 at least, but I think previous version as well but not sure) was
changing the encoding of my .cmd files to be UTF-8! For example consider this simple
script (sample.cmd) that I created with &lt;a href="http://en.wikipedia.org/wiki/Notepad_%28Windows%29"&gt;Notepad&lt;/a&gt;.
&lt;/p&gt;
&lt;pre class="brush: plain;"&gt;echo 'hello world'&lt;/pre&gt;
&lt;p&gt;
When I execute this .cmd file from the command line the results are as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_thumb_2.png" width="465" height="35" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
What I did then was to simply create a copy of that file and placed that in a file
named sample-vs.cmd and then edited the script using Visual Studio 2010 to have the
contents below.
&lt;/p&gt;
&lt;pre class="brush: plain;"&gt;echo 'hello world from Visual Studio'&lt;/pre&gt;
&lt;p&gt;
When I execute that .cmd file to my surprise the results shown below are displayed.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_thumb_3.png" width="632" height="51" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I was definitely not expecting that (&lt;em&gt;OK yeah I was because I created that script
for this blog post, but just go with it&lt;/em&gt;). I then opened the file in notepad and
it looked normal. So I edited it it notpad, saved it and the result was still the
same. The first line was not being processed correctly, it seemed. As I was editing
the file I noticed the encoding of the files were different. The encoding for the
sample.cmd file was set to ANSI and for sample-vs.cmd UTF-8. See for yourself from
the screen shots below.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_thumb_4.png" width="637" height="452" /&gt;&lt;/a&gt;&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_12.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudiofileencodingissues_1435C/image_thumb_5.png" width="637" height="450" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
So I switched the setting for the sample-vs.cmd file to ANSI, executed the script
and all was good!
&lt;/p&gt;
&lt;p&gt;
I’m not sure why Visual Studio is changing the encoding for these files, but it looks
like a bug to me. I have logged a bug with Microsoft at &lt;a title="https://connect.microsoft.com/VisualStudio/feedback/details/566322/vs-2010-changs-encoding-of-cmd-file-to-utf-8" href="https://connect.microsoft.com/VisualStudio/feedback/details/566322/vs-2010-changs-encoding-of-cmd-file-to-utf-8.&amp;rsquo;m"&gt;https://connect.microsoft.com/VisualStudio/feedback/details/566322/vs-2010-changs-encoding-of-cmd-file-to-utf-8.&lt;/a&gt; The
bug may not be visible yet, but hopefully it will become public so that you can vote
on it if you have been bitten by this bug.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=68b7ea19-35ad-4249-8106-b5c7e9299c3f" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,68b7ea19-35ad-4249-8106-b5c7e9299c3f.aspx</comments>
      <category>batch-file</category>
      <category>bug</category>
      <category>cmd-file</category>
      <category>connect</category>
      <category>Visual Studio</category>
      <category>Visual Studio 2010</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=610e67fd-a3e6-41cd-bab4-1e462ae76e8b</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,610e67fd-a3e6-41cd-bab4-1e462ae76e8b.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,610e67fd-a3e6-41cd-bab4-1e462ae76e8b.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=610e67fd-a3e6-41cd-bab4-1e462ae76e8b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are doing any kind of web development and you are not familiar with the <a href="http://www.microsoft.com/web/downloads/platform.aspx">Web
Platform Installer</a>(WPI) then you need to take a look at it. I just installed <a href="http://wordpress.org/">WordPress</a> on
IIS 7 with just a few clicks and  filled in a few text boxes. When you install <a href="http://wordpress.org/">WordPress</a> there
are some prerequisites like <a href="http://www.mysql.com/">mySql</a> and <a href="http://www.php.net/">php</a>.
The WPI was smart enough to realize that I had neither installed, downloaded those,
installed them and configured them. I was prompted for some info for those tools of
course. I’ve also installed a few other apps using the WPI like, <a href="http://www.iis.net/download/WebDeploy">MSDeploy</a> and <a href="http://www.dasblog.info/">dasBlog</a> and
I didn’t have any issues what so ever.
</p>
        <p>
When using the WPI there are two main categories that can be installed, <em>Web Platform</em> and <em>Web
Applications</em>. The Web Platform category includes items like frameworks (i.e.
ASP.NET, PHP), Database (i.e. mySql) and other high level shared components. The Web
Applications includes various web applications. Some others that I didn’t list previously
include; <a href="http://www.dotnetnuke.com/">DotNetNuke</a>, <a href="http://www.nopcommerce.com/">nopCommerce</a>,
and <a href="http://umbraco.org/">umbarco</a> just to name a few. I’m not sure how
many apps are available but it looks like at least 50.
</p>
        <p>
If you are an app creator and would like to share your app then you can visit the <a href="http://www.microsoft.com/web/gallery/developer.aspx">WPI
Developer</a> page for a starting point.
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=610e67fd-a3e6-41cd-bab4-1e462ae76e8b" />
      </body>
      <title>Installing web apps made easy: Web Platform Installer</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,610e67fd-a3e6-41cd-bab4-1e462ae76e8b.aspx</guid>
      <link>http://sedodream.com/2010/06/07/InstallingWebAppsMadeEasyWebPlatformInstaller.aspx</link>
      <pubDate>Mon, 07 Jun 2010 03:17:01 GMT</pubDate>
      <description>&lt;p&gt;
If you are doing any kind of web development and you are not familiar with the &lt;a href="http://www.microsoft.com/web/downloads/platform.aspx"&gt;Web
Platform Installer&lt;/a&gt;(WPI) then you need to take a look at it. I just installed &lt;a href="http://wordpress.org/"&gt;WordPress&lt;/a&gt; on
IIS 7 with just a few clicks and&amp;#160; filled in a few text boxes. When you install &lt;a href="http://wordpress.org/"&gt;WordPress&lt;/a&gt; there
are some prerequisites like &lt;a href="http://www.mysql.com/"&gt;mySql&lt;/a&gt; and &lt;a href="http://www.php.net/"&gt;php&lt;/a&gt;.
The WPI was smart enough to realize that I had neither installed, downloaded those,
installed them and configured them. I was prompted for some info for those tools of
course. I’ve also installed a few other apps using the WPI like, &lt;a href="http://www.iis.net/download/WebDeploy"&gt;MSDeploy&lt;/a&gt; and &lt;a href="http://www.dasblog.info/"&gt;dasBlog&lt;/a&gt; and
I didn’t have any issues what so ever.
&lt;/p&gt;
&lt;p&gt;
When using the WPI there are two main categories that can be installed, &lt;em&gt;Web Platform&lt;/em&gt; and &lt;em&gt;Web
Applications&lt;/em&gt;. The Web Platform category includes items like frameworks (i.e.
ASP.NET, PHP), Database (i.e. mySql) and other high level shared components. The Web
Applications includes various web applications. Some others that I didn’t list previously
include; &lt;a href="http://www.dotnetnuke.com/"&gt;DotNetNuke&lt;/a&gt;, &lt;a href="http://www.nopcommerce.com/"&gt;nopCommerce&lt;/a&gt;,
and &lt;a href="http://umbraco.org/"&gt;umbarco&lt;/a&gt; just to name a few. I’m not sure how
many apps are available but it looks like at least 50.
&lt;/p&gt;
&lt;p&gt;
If you are an app creator and would like to share your app then you can visit the &lt;a href="http://www.microsoft.com/web/gallery/developer.aspx"&gt;WPI
Developer&lt;/a&gt; page for a starting point.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=610e67fd-a3e6-41cd-bab4-1e462ae76e8b" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,610e67fd-a3e6-41cd-bab4-1e462ae76e8b.aspx</comments>
      <category>Deployment</category>
      <category>IIS</category>
      <category>MSDeploy</category>
      <category>web</category>
      <category>Web Platform Installer</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=45c89a49-fd37-463a-9d96-c795d7d68d96</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,45c89a49-fd37-463a-9d96-c795d7d68d96.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,45c89a49-fd37-463a-9d96-c795d7d68d96.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=45c89a49-fd37-463a-9d96-c795d7d68d96</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The past few days I was unable to <a href="http://msdn.microsoft.com/en-us/library/ms164926%28v=VS.100%29.aspx">Edit
and Continue</a> in Visual Studio 2010 Ultimate from my home machine, which is running
Windows 7 64bit. I knew there were <a href="http://blogs.msdn.com/stevejs/archive/2005/11/15/493018.aspx">some
issues</a> with this on 64bit, I figured one of my projects was not targeting x86
so I just ignored it. Then today I was really getting annoyed at seeing the dialog.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="edit-and-continue" border="0" alt="edit-and-continue" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue_thumb.png" />
          </a>
        </p>
        <p>
So I started playing around with the configuration settings made sure that everything
was in order and still no dice.
</p>
        <p>
After that I performed a repair of Visual Studio, and then reset all the settings
under Tools&gt;Import and Export Settings and that still didn’t solve the problem.
Then I remembered that I change my IntelliTrace settings the other day so I went to
disable it and to my surprise I saw the dialog box shown below.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue2_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="edit-and-continue2" border="0" alt="edit-and-continue2" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue2_thumb.png" />
          </a>
        </p>
        <p>
When I changed the IntelliTrace setting to collect call information I didn’t notice
the warning stating “Edit and continue is disabled when collecting Call Information”!
So I changed the setting and everything was good. Microsoft should add this to the
Edit and Continue dialog box not available, I’ll ping a few people I know about that.
FYI I created this <a href="http://stackoverflow.com/questions/2795795/cant-edit-and-continue-when-using-visual-studio-2010-on-a-64-bit-machine-app-ta">question</a> on <a href="http://stackoverflow.com">Stackoverflow</a> before
I resolved it myself.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=45c89a49-fd37-463a-9d96-c795d7d68d96" />
      </body>
      <title>Visual Studio: Unable to Edit and Continue?</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,45c89a49-fd37-463a-9d96-c795d7d68d96.aspx</guid>
      <link>http://sedodream.com/2010/05/08/VisualStudioUnableToEditAndContinue.aspx</link>
      <pubDate>Sat, 08 May 2010 23:19:38 GMT</pubDate>
      <description>&lt;p&gt;
The past few days I was unable to &lt;a href="http://msdn.microsoft.com/en-us/library/ms164926%28v=VS.100%29.aspx"&gt;Edit
and Continue&lt;/a&gt; in Visual Studio 2010 Ultimate from my home machine, which is running
Windows 7 64bit. I knew there were &lt;a href="http://blogs.msdn.com/stevejs/archive/2005/11/15/493018.aspx"&gt;some
issues&lt;/a&gt; with this on 64bit, I figured one of my projects was not targeting x86
so I just ignored it. Then today I was really getting annoyed at seeing the dialog.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="edit-and-continue" border="0" alt="edit-and-continue" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue_thumb.png" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
So I started playing around with the configuration settings made sure that everything
was in order and still no dice.
&lt;/p&gt;
&lt;p&gt;
After that I performed a repair of Visual Studio, and then reset all the settings
under Tools&amp;gt;Import and Export Settings and that still didn’t solve the problem.
Then I remembered that I change my IntelliTrace settings the other day so I went to
disable it and to my surprise I saw the dialog box shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue2_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="edit-and-continue2" border="0" alt="edit-and-continue2" src="http://sedodream.com/content/binary/WindowsLiveWriter/VisualStudioUnabletoEditandContinue_10F39/edit-and-continue2_thumb.png" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
When I changed the IntelliTrace setting to collect call information I didn’t notice
the warning stating “Edit and continue is disabled when collecting Call Information”!
So I changed the setting and everything was good. Microsoft should add this to the
Edit and Continue dialog box not available, I’ll ping a few people I know about that.
FYI I created this &lt;a href="http://stackoverflow.com/questions/2795795/cant-edit-and-continue-when-using-visual-studio-2010-on-a-64-bit-machine-app-ta"&gt;question&lt;/a&gt; on &lt;a href="http://stackoverflow.com"&gt;Stackoverflow&lt;/a&gt; before
I resolved it myself.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=45c89a49-fd37-463a-9d96-c795d7d68d96" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,45c89a49-fd37-463a-9d96-c795d7d68d96.aspx</comments>
      <category>Edit and Continue</category>
      <category>IntelliTrace</category>
      <category>Visual Studio</category>
      <category>Visual Studio 2010</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=9bd5e258-32d5-4e39-9f1e-24949efac3e3</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,9bd5e258-32d5-4e39-9f1e-24949efac3e3.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,9bd5e258-32d5-4e39-9f1e-24949efac3e3.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9bd5e258-32d5-4e39-9f1e-24949efac3e3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently I had the chance to work on a <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation">WPF</a> app
and it was behaving very strangely when I built and ran the application. For instance
I tried to debug the application from Visual Studio and I received an error staging
“<em>Visual Studio cannot start debugging because the debug target ‘PATH HERE’ is
missing. Please build the project and retry, or set the OutputPath and AssemblyName
properties appropriately to point at the correct location for the target assembly.</em>”
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/vs-build-error-01_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs-build-error-01" border="0" alt="vs-build-error-01" src="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/vs-build-error-01_thumb_1.png" />
          </a>
        </p>
        <p>
So I checked the properties, every thing looked good. I even built the project from
the command line and it built fine. Anywayz at some point after that I was able to
debug the app. But then I noticed that the UI was not getting updated with my changes.
So I started digging a bit deeper. I noticed that when I ran a Clean from Visual Studio
the output files for that particular project. 
</p>
        <p>
I then rebuilt the solution in Visual Studio. From the Output window I selected all
the text,copied it, and then pasted that into an editor. After looking at the message
</p>
        <p>
------ Skipped Clean: Project: R…ion: Debug Any CPU ------ 
<br />
Project not selected to build for this solution configuration 
<br />
------ Skipped Clean: Project: R…Admin.Wpf, Configuration: Debug x86 ------ 
<br /><u><strong>Project not selected to build for this solution configuration </strong></u><br />
------ Clean started: Project: Test…er, Configuration: Debug Any CPU ------ 
<br />
Build started 5/8/2010 1:10:02 AM.
</p>
        <p>
I immediately knew that there was an incorrect value in the build configuration manager.
You can find the configuration manager from the toolbar.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_thumb_1.png" width="176" height="98" />
          </a>
        </p>
        <p>
Here is what I found.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_thumb_2.png" />
          </a>
        </p>
        <p>
In this dialog there are two project set not to build for Debug builds; the DB project
and the Wpf project. The DB project is OK to not build on Debug if there are a small
% of DB changes versus code changes. If that is the case the devs can just build the
DB project manually when the change it. In the case of the Wpf project, it should
be set to build and the fact that it wasn’t was causing all the issues. So I checked
the build check box, clicked the Close button and it was all good. You should also
make sure that all other configuration as setup correctly. You don’t want to get bitten
by this again.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=9bd5e258-32d5-4e39-9f1e-24949efac3e3" />
      </body>
      <title>Visual Studio projects not building anymore?</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,9bd5e258-32d5-4e39-9f1e-24949efac3e3.aspx</guid>
      <link>http://sedodream.com/2010/05/08/VisualStudioProjectsNotBuildingAnymore.aspx</link>
      <pubDate>Sat, 08 May 2010 05:33:26 GMT</pubDate>
      <description>&lt;p&gt;
Recently I had the chance to work on a &lt;a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation"&gt;WPF&lt;/a&gt; app
and it was behaving very strangely when I built and ran the application. For instance
I tried to debug the application from Visual Studio and I received an error staging
“&lt;em&gt;Visual Studio cannot start debugging because the debug target ‘PATH HERE’ is
missing. Please build the project and retry, or set the OutputPath and AssemblyName
properties appropriately to point at the correct location for the target assembly.&lt;/em&gt;”
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/vs-build-error-01_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs-build-error-01" border="0" alt="vs-build-error-01" src="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/vs-build-error-01_thumb_1.png" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
So I checked the properties, every thing looked good. I even built the project from
the command line and it built fine. Anywayz at some point after that I was able to
debug the app. But then I noticed that the UI was not getting updated with my changes.
So I started digging a bit deeper. I noticed that when I ran a Clean from Visual Studio
the output files for that particular project. 
&lt;/p&gt;
&lt;p&gt;
I then rebuilt the solution in Visual Studio. From the Output window I selected all
the text,copied it, and then pasted that into an editor. After looking at the message
&lt;/p&gt;
&lt;p&gt;
------ Skipped Clean: Project: R…ion: Debug Any CPU ------ 
&lt;br /&gt;
Project not selected to build for this solution configuration 
&lt;br /&gt;
------ Skipped Clean: Project: R…Admin.Wpf, Configuration: Debug x86 ------ 
&lt;br /&gt;
&lt;u&gt;&lt;strong&gt;Project not selected to build for this solution configuration &lt;/strong&gt;&lt;/u&gt; 
&lt;br /&gt;
------ Clean started: Project: Test…er, Configuration: Debug Any CPU ------ 
&lt;br /&gt;
Build started 5/8/2010 1:10:02 AM.
&lt;/p&gt;
&lt;p&gt;
I immediately knew that there was an incorrect value in the build configuration manager.
You can find the configuration manager from the toolbar.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_thumb_1.png" width="176" height="98" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Here is what I found.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sedodream.com/content/binary/WindowsLiveWriter/Projectsnotbuildinganymore_131B/image_thumb_2.png" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In this dialog there are two project set not to build for Debug builds; the DB project
and the Wpf project. The DB project is OK to not build on Debug if there are a small
% of DB changes versus code changes. If that is the case the devs can just build the
DB project manually when the change it. In the case of the Wpf project, it should
be set to build and the fact that it wasn’t was causing all the issues. So I checked
the build check box, clicked the Close button and it was all good. You should also
make sure that all other configuration as setup correctly. You don’t want to get bitten
by this again.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=9bd5e258-32d5-4e39-9f1e-24949efac3e3" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,9bd5e258-32d5-4e39-9f1e-24949efac3e3.aspx</comments>
      <category>Visual Studio</category>
      <category>Visual Studio 2010</category>
      <category>WPF</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=803d77d7-a220-4cee-a803-f6291cd4ba71</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,803d77d7-a220-4cee-a803-f6291cd4ba71.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,803d77d7-a220-4cee-a803-f6291cd4ba71.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=803d77d7-a220-4cee-a803-f6291cd4ba71</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are using Visual Studio 2010 then you may already be aware that <a href="http://www.iis.net/download/WebDeploy">Web
Deployment Tool</a> (aka MSDeploy) is integrated into Visual Studio. I’ve posted a
few blog entries already about this tool. Two of the common questions that I get discussing
this with people are
</p>
        <ol>
          <li>
How do I exclude files from being placed in the package? 
</li>
          <li>
How do I add other files to the created package? 
</li>
        </ol>
        <p>
I will address these two questions here, first we look at the easier one, how to exclude
files but we will go over a bit of background first.
</p>
        <h3>Web Publishing Pipeline
</h3>
        <p>
With Visual Studio 2010 a new concept has been created which is known as the Web Publishing
Pipeline. In a nutshell this is a process which will take your web application, build
it and eventually create a package that you can use to deploy your application. This
process is fully captured in MSBuild. With VS 2010 many targets and many tasks are
shipped to support this process. Since its captured in MSBuild format, you can customize
and extend to your hearts desire. So what we need to do is hook into this process
to perform the customizations that we need. This process is captured in the following
files.
</p>
        <pre class="brush: plain;">%program files%\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets
%program files%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets</pre>
        <p>
        </p>
        <p>
The Microsoft.WebApplication.targets file is imported by the web applications projects
file, then that file imports the Microsoft.Web.Publishing.targets file.
</p>
        <h3>Excluding files from being packaged
</h3>
        <p>
If you open the project file of a web application created with VS 2010 towards the
bottom of it you will find a line with.
</p>
        <pre class="brush: xml;">&lt;Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /&gt;</pre>
        <p>
BTW you can open the project file inside of VS. Right click on the project pick <em>Unload
Project</em>. Then right click on the unloaded project and select <em>Edit Project</em>.
</p>
        <p>
This statement will include all the targets and tasks that we need. Most of our customizations
should be <strong>after</strong> that import, if you are not sure put if after! So
if you have files to exclude there is an item name, <strong>ExcludeFromPackageFiles</strong>,
that can be used to do so. For example let’s say that you have file named Sample.Debug.js
which included in your web application but you want that file to be excluded from
the created packages. You can place the snippet below after that import statement.
</p>
        <pre class="brush: xml;">&lt;ItemGroup&gt;
  &lt;ExcludeFromPackageFiles Include="Sample.Debug.xml"&gt;
    &lt;FromTarget&gt;Project&lt;/FromTarget&gt;
  &lt;/ExcludeFromPackageFiles&gt;
&lt;/ItemGroup&gt;</pre>
        <p>
By declaring populating this item the files will automatically be excluded. Note the
usage of the FromTarget metadata here. I will not get into that here, but you should
know to always specify that.
</p>
        <h3>Including extra files into the package
</h3>
        <p>
Including extra files into the package is a bit harder but still no bigee if you are
comfortable with MSBuild, and if you are not then <a href="http://www.amazon.com/gp/product/0735626286?ie=UTF8&amp;tag=sedodream-20&amp;linkCode=xm2&amp;camp=1789&amp;creativeASIN=0735626286">read
this</a>.  In order to do this we need to hook into the part of the process that
collects the files for packaging. The target we need to extend is called <strong>CopyAllFilesToSingleFolder</strong>.
This target has a dependency property, <em>PipelinePreDeployCopyAllFilesToOneFolderDependsOn</em>,
that we can tap into and inject our own target. So we will create a target named <em>CustomCollectFiles</em> and
inject that into the process. We achieve this with the following (<strong>remember
after the import statement</strong>).
</p>
        <pre class="brush: xml;">&lt;PropertyGroup&gt;
  &lt;CopyAllFilesToSingleFolderForPackageDependsOn&gt;
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  &lt;/CopyAllFilesToSingleFolderForPackageDependsOn&gt;
&lt;/PropertyGroup&gt;</pre>
        <p>
This will add our target to the process, now we need to define the target itself.
Let’s assume that you have a folder named Extra Files that sits 1 level above your
web project. You want to include all of those files. Here is the <em>CustomCollectFiles</em> target
and we discuss after that.
</p>
        <pre class="brush: xml;">&lt;Target Name="CustomCollectFiles"&gt;
  &lt;ItemGroup&gt;
    &lt;_CustomFiles Include="..\Extra Files\**\*" /&gt;

    &lt;FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)"&gt;
      &lt;DestinationRelativePath&gt;Extra Files\%(RecursiveDir)%(Filename)%(Extension)&lt;/DestinationRelativePath&gt;
    &lt;/FilesForPackagingFromProject&gt;
  &lt;/ItemGroup&gt;
&lt;/Target&gt;</pre>
        <p>
Here what I did was create the item <em>_CustomFiles</em> and in the Include attribute
told it to pick up all the files in that folder and any folder underneath it. Then
I use this item to populate the FilesForPackagingFromProject item. This is the item
that MSDeploy actually uses to add extra files. Also notice that I declared the metadata <em>DestinationRelativePath</em> value.
This will determine the relative path that it will be placed in the package. I used
the statement <em>Extra Files%(RecursiveDir)%(Filename)%(Extension)</em> here. What
that is saying is to place it in the same relative location in the package as it is
under the Extra Files folder.
</p>
        <p>
Admittedly this could be easier, but its not too bad, and its pretty flexible.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=803d77d7-a220-4cee-a803-f6291cd4ba71" />
      </body>
      <title>Web Deployment Tool (MSDeploy) : Build Package including extra files or excluding specific files</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,803d77d7-a220-4cee-a803-f6291cd4ba71.aspx</guid>
      <link>http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx</link>
      <pubDate>Sat, 01 May 2010 03:09:16 GMT</pubDate>
      <description>&lt;p&gt;
If you are using Visual Studio 2010 then you may already be aware that &lt;a href="http://www.iis.net/download/WebDeploy"&gt;Web
Deployment Tool&lt;/a&gt; (aka MSDeploy) is integrated into Visual Studio. I’ve posted a
few blog entries already about this tool. Two of the common questions that I get discussing
this with people are
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
How do I exclude files from being placed in the package? 
&lt;/li&gt;
&lt;li&gt;
How do I add other files to the created package? 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I will address these two questions here, first we look at the easier one, how to exclude
files but we will go over a bit of background first.
&lt;/p&gt;
&lt;h3&gt;Web Publishing Pipeline
&lt;/h3&gt;
&lt;p&gt;
With Visual Studio 2010 a new concept has been created which is known as the Web Publishing
Pipeline. In a nutshell this is a process which will take your web application, build
it and eventually create a package that you can use to deploy your application. This
process is fully captured in MSBuild. With VS 2010 many targets and many tasks are
shipped to support this process. Since its captured in MSBuild format, you can customize
and extend to your hearts desire. So what we need to do is hook into this process
to perform the customizations that we need. This process is captured in the following
files.
&lt;/p&gt;
&lt;pre class="brush: plain;"&gt;%program files%\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets
%program files%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The Microsoft.WebApplication.targets file is imported by the web applications projects
file, then that file imports the Microsoft.Web.Publishing.targets file.
&lt;/p&gt;
&lt;h3&gt;Excluding files from being packaged
&lt;/h3&gt;
&lt;p&gt;
If you open the project file of a web application created with VS 2010 towards the
bottom of it you will find a line with.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;Import Project=&amp;quot;$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;p&gt;
BTW you can open the project file inside of VS. Right click on the project pick &lt;em&gt;Unload
Project&lt;/em&gt;. Then right click on the unloaded project and select &lt;em&gt;Edit Project&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
This statement will include all the targets and tasks that we need. Most of our customizations
should be &lt;strong&gt;after&lt;/strong&gt; that import, if you are not sure put if after! So
if you have files to exclude there is an item name, &lt;strong&gt;ExcludeFromPackageFiles&lt;/strong&gt;,
that can be used to do so. For example let’s say that you have file named Sample.Debug.js
which included in your web application but you want that file to be excluded from
the created packages. You can place the snippet below after that import statement.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;ItemGroup&amp;gt;
  &amp;lt;ExcludeFromPackageFiles Include=&amp;quot;Sample.Debug.xml&amp;quot;&amp;gt;
    &amp;lt;FromTarget&amp;gt;Project&amp;lt;/FromTarget&amp;gt;
  &amp;lt;/ExcludeFromPackageFiles&amp;gt;
&amp;lt;/ItemGroup&amp;gt;&lt;/pre&gt;
&lt;p&gt;
By declaring populating this item the files will automatically be excluded. Note the
usage of the FromTarget metadata here. I will not get into that here, but you should
know to always specify that.
&lt;/p&gt;
&lt;h3&gt;Including extra files into the package
&lt;/h3&gt;
&lt;p&gt;
Including extra files into the package is a bit harder but still no bigee if you are
comfortable with MSBuild, and if you are not then &lt;a href="http://www.amazon.com/gp/product/0735626286?ie=UTF8&amp;amp;tag=sedodream-20&amp;amp;linkCode=xm2&amp;amp;camp=1789&amp;amp;creativeASIN=0735626286"&gt;read
this&lt;/a&gt;.&amp;#160; In order to do this we need to hook into the part of the process that
collects the files for packaging. The target we need to extend is called &lt;strong&gt;CopyAllFilesToSingleFolder&lt;/strong&gt;.
This target has a dependency property, &lt;em&gt;PipelinePreDeployCopyAllFilesToOneFolderDependsOn&lt;/em&gt;,
that we can tap into and inject our own target. So we will create a target named &lt;em&gt;CustomCollectFiles&lt;/em&gt; and
inject that into the process. We achieve this with the following (&lt;strong&gt;remember
after the import statement&lt;/strong&gt;).
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;PropertyGroup&amp;gt;
  &amp;lt;CopyAllFilesToSingleFolderForPackageDependsOn&amp;gt;
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  &amp;lt;/CopyAllFilesToSingleFolderForPackageDependsOn&amp;gt;
&amp;lt;/PropertyGroup&amp;gt;&lt;/pre&gt;
&lt;p&gt;
This will add our target to the process, now we need to define the target itself.
Let’s assume that you have a folder named Extra Files that sits 1 level above your
web project. You want to include all of those files. Here is the &lt;em&gt;CustomCollectFiles&lt;/em&gt; target
and we discuss after that.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;Target Name=&amp;quot;CustomCollectFiles&amp;quot;&amp;gt;
  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;_CustomFiles Include=&amp;quot;..\Extra Files\**\*&amp;quot; /&amp;gt;

    &amp;lt;FilesForPackagingFromProject  Include=&amp;quot;%(_CustomFiles.Identity)&amp;quot;&amp;gt;
      &amp;lt;DestinationRelativePath&amp;gt;Extra Files\%(RecursiveDir)%(Filename)%(Extension)&amp;lt;/DestinationRelativePath&amp;gt;
    &amp;lt;/FilesForPackagingFromProject&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;
&amp;lt;/Target&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Here what I did was create the item &lt;em&gt;_CustomFiles&lt;/em&gt; and in the Include attribute
told it to pick up all the files in that folder and any folder underneath it. Then
I use this item to populate the FilesForPackagingFromProject item. This is the item
that MSDeploy actually uses to add extra files. Also notice that I declared the metadata &lt;em&gt;DestinationRelativePath&lt;/em&gt; value.
This will determine the relative path that it will be placed in the package. I used
the statement &lt;em&gt;Extra Files%(RecursiveDir)%(Filename)%(Extension)&lt;/em&gt; here. What
that is saying is to place it in the same relative location in the package as it is
under the Extra Files folder.
&lt;/p&gt;
&lt;p&gt;
Admittedly this could be easier, but its not too bad, and its pretty flexible.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=803d77d7-a220-4cee-a803-f6291cd4ba71" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,803d77d7-a220-4cee-a803-f6291cd4ba71.aspx</comments>
      <category>MSBuild</category>
      <category>MSBuild 4.0</category>
      <category>MSDeploy</category>
      <category>Visual Studio</category>
      <category>Visual Studio 2010</category>
      <category>Web Deployment Tool</category>
      <category>Web Publishing Pipeline</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=6cced95a-0f4a-4740-9dba-03782008d8d3</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,6cced95a-0f4a-4740-9dba-03782008d8d3.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,6cced95a-0f4a-4740-9dba-03782008d8d3.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6cced95a-0f4a-4740-9dba-03782008d8d3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">If you are using <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx">MSBuild
4.0</a> then you may be interested in knowing that there are a couple new switches
that you can pass to msbuild.exe when you kick off a build. The new switches, <em><strong>/preprocess(/pp)</strong></em> and <em><strong>/detailedsummary(/ds)</strong></em>,
are more convenient then necessary. 
<h2>/preprocess (/pp)
</h2><p>
Since you can import other MSBuild files using the <a href="http://msdn.microsoft.com/en-us/library/92x05xfs.aspx">Import
Element</a> sometimes locating where a target, property or item is being defined can
lead to a search that takes you through several files. It can be even more confusing
if more than 1 file defines the property or target that you are interested in, because
you may have thought that you found the right target but you may one that was overridden
by another file. Now with MSBuild 4.0 you don’t have to search through all of those
files. You can use the switch /preprocess switch. Here is the snippet from msbuild.exe
/? describing it.
</p><pre class="brush: plain;">/preprocess[:file] 
 Creates a single, aggregated project file by inlining all the files that would be imported during a build, with their boundaries marked. This can be useful for figuring out what files are being imported and from where, and what they will contribute to the build. By default the output is written to the console window. If the path to an output file is provided that will be used instead.
 (Short form: /pp)
 Example:
   /pp:out.txt</pre><p>
When you use this the full logical project file is dumped to the console, or optionally
to a file, and it includes references to where the elements are defined. For example
I created the following very simple project files.
</p><h3>import-01.proj
</h3><pre class="brush: xml;">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;Target Name="TargetOne"&gt;
        &lt;Message Text="From import-02.proj - TargetOne"/&gt;
    &lt;/Target&gt;
&lt;/Project&gt;</pre><h3>import-02.proj
</h3><pre class="brush: xml;">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;Target Name="TargetTwo"&gt;
        &lt;Message Text="From import-02.proj - TargetTwo"/&gt;
    &lt;/Target&gt;
&lt;/Project&gt;</pre><h3>master.proj
</h3><pre class="brush: xml;">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Project ToolsVersion="4.0" DefaultTargets="TargetOne;TargetTwo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

    &lt;Target Name="TargetOne"&gt;
        &lt;Message Text="From master.proj - TargetOne"/&gt;
    &lt;/Target&gt;

    &lt;Target Name="TargetTwo"&gt;
        &lt;Message Text="From master.proj - TargetTwo"/&gt;
    &lt;/Target&gt;

    &lt;Import Project="import-01.proj"/&gt;
    &lt;Import Project="import-02.proj"/&gt;
&lt;/Project&gt;</pre><p>
After executing the command msbuild.exe master.proj /pp:out.xml the following was
written to the out.xml file.
</p><pre class="brush: xml;">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!--
============================================================================================================================================
C:\temp\MSBuild\import\master.proj
============================================================================================================================================
--&gt;
&lt;Project ToolsVersion="4.0" DefaultTargets="TargetOne;TargetTwo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  &lt;Target Name="TargetOne"&gt;
    &lt;Message Text="From master.proj - TargetOne" /&gt;
  &lt;/Target&gt;
  &lt;Target Name="TargetTwo"&gt;
    &lt;Message Text="From master.proj - TargetTwo" /&gt;
  &lt;/Target&gt;
  &lt;!--
============================================================================================================================================
  &lt;Import Project="import-01.proj"&gt;

C:\temp\MSBuild\import\import-01.proj
============================================================================================================================================
--&gt;
  &lt;Target Name="TargetOne"&gt;
    &lt;Message Text="From import-02.proj - TargetOne" /&gt;
  &lt;/Target&gt;
  &lt;!--
============================================================================================================================================
  &lt;/Import&gt;

C:\temp\MSBuild\import\master.proj
============================================================================================================================================
--&gt;
  &lt;!--
============================================================================================================================================
  &lt;Import Project="import-02.proj"&gt;

C:\temp\MSBuild\import\import-02.proj
============================================================================================================================================
--&gt;
  &lt;Target Name="TargetTwo"&gt;
    &lt;Message Text="From import-02.proj - TargetTwo" /&gt;
  &lt;/Target&gt;
  &lt;!--
============================================================================================================================================
  &lt;/Import&gt;

C:\temp\MSBuild\import\master.proj
============================================================================================================================================
--&gt;
&lt;/Project&gt;</pre><p>
As you can see with /pp it is very easy to see exactly what is defined where and at
what location.
</p><h2>/detailedsummary (/ds)
</h2><p>
Another new feature with MSBuild 4.0 is the <strong><em>/detailedsummary (/ds)</em></strong> command
line switch. When you use this switch you will be shown a detailed summary (<em>haha</em>)
of build execution. This summary includes the amount of time spent build each project
file as well as the node utilization. I just preformed a build with the command <strong>msbuild
RuleStack.Engine.sln /m /ds</strong> and the summary is shown below.
</p><pre class="brush: plain;">============================== Build Hierarchy (IDs represent configurations) =====================================================
 Id                  : Exclusive Time   Total Time   Path (Targets)
 -----------------------------------------------------------------------------------------------------------------------------------
 0                   : 0.020s           1.211s       C:\...\RuleStack.Engine.sln ()
 | 1                 : 0.667s           0.667s       C:\...\RuleStack.Engine.Common\RuleStack.Engine.Common.csproj ()
 | 3                 : 0.255s           0.718s       C:\...\Unittest\RuleStack.Engine.Tests\RuleStack.Engine.Tests.csproj ()
 | | 6               : 0.000s           0.000s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder .csproj ()
 | | 5               : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | 1               : 0.000s           0.000s       C:\...\RuleStack.Engine.Common\RuleStack.Engine.Common.csproj ()
 | | 2               : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | | 8               : 0.292s           0.460s       C:\...\RuleStack.Engine.Admin.Web\RuleStack.Engine.Admin.Web.csproj ()
 | | | 24            : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( GetNativeManifest)
 | | | 5             : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | . 2             : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | . 36              : 0.003s           0.003s       C:\...\RuleStack.Engine.Admin.Web\RuleStack.Engine.Admin.Web.csproj (GetNativeManifest)
 | 2                 : 0.319s           0.390s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | | 6               : 0.000s           0.000s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj ()
 | | 5               : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | 17              : 0.002s           0.002s       C:\...\RuleStack.Data\RuleStack.Data.csproj (GetNativeManifest)
 | . 21              : 0.001s           0.001s       C:\...\RuleStack.Data\RuleStack.Data.csproj (GetCopyToOutputDirectoryItems)
 | 4                 : 0.382s           0.567s       C:\...\RuleStack.Services\RuleStack.Services.csproj ()
 | | 5               : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | 2               : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | | 24              : 0.002s           0.002s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( GetNativeManifest)
 | . 29              : 0.001s           0.001s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( GetCopyToOutputDirectoryItems)
 | 7                 : 0.333s           0.337s       C:\...\ObjectBinder\Test_RuleStack.ObjectBinder\Test_RuleStack.ObjectBinder.csproj ()
 | | 6               : 0.000s           0.000s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj ()
 | | 13              : 0.001s           0.001s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj (GetNativeManifest)
 | . 19              : 0.001s           0.001s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj (GetCopyToOutputDirectoryItems)
 | 6                 : 0.210s           0.210s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj ()
 | 5                 : 0.277s           0.277s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | . 12              : 0.000s           0.000s       C:\...\RuleStack.Engine.Common\RuleStack.Engine.Common.csproj (GetNativeManifest)
 . 43                : 0.002s           0.002s       C:\...\RuleStack.Engine.Admin.Web\RuleStack.Engine.Admin.Web.csproj.metaproj ()

 ============================== Node Utilization (IDs represent configurations) ====================================================
 Timestamp:            1       2       3       4       5       6       7       8        Duration   Cumulative
 -----------------------------------------------------------------------------------------------------------------------------------
 634081842447519669:   0       x       x       x       x       x       x       x        0.018s     0.018s
 634081842447699679:   1       x       x       x       x       x       x       x        0.461s     0.479s #########
 634081842452309943:   |       6       7       5       3       4       2       x        0.130s     0.609s ##
 634081842453610018:   |       |       |       |       8       |       |       x        0.086s     0.695s #
 634081842454470067:   |       |       |       |       |       |       |       x        0.001s     0.696s
 634081842454480067:   x       |       |       |       |       |       |       x        0.001s     0.697s
 634081842454490068:   x       |       x       |       |       x       |       x        0.001s     0.698s
 634081842454500068:   x       |       x       |       |       x       x       x        0.001s     0.699s
 634081842454510069:   x       x       7       |       |       x       x       x        0.002s     0.701s
 634081842454530070:   12      x       |       |       |       x       x       x        0.002s     0.703s
 634081842454550071:   |       13      x       |       |       x       x       x        0.001s     0.704s
 634081842454560072:   |       x       7       |       |       x       x       x        0.008s     0.712s
 634081842454640076:   |       x       |       |       x       x       x       x        0.054s     0.766s #
 634081842455180107:   |       x       |       x       x       x       2       x        0.003s     0.769s
 634081842455210109:   |       x       |       17      x       x       x       x        0.002s     0.771s
 634081842455230110:   |       x       |       x       x       x       2       x        0.036s     0.807s
 634081842455590131:   |       19      x       x       x       x       |       x        0.001s     0.808s
 634081842455600131:   |       x       7       x       x       x       |       x        0.018s     0.826s
 634081842455780142:   |       x       x       x       x       x       |       x        0.036s     0.862s
 634081842456140162:   |       x       x       21      x       x       x       x        0.001s     0.863s
 634081842456150163:   |       x       x       x       x       x       2       x        0.016s     0.879s
 634081842456310172:   |       x       x       x       8       4       x       x        0.003s     0.882s
 634081842456340174:   |       x       x       x       |       x       24      x        0.001s     0.883s
 634081842456350174:   |       x       x       x       x       x       |       x        0.001s     0.884s
 634081842456360175:   |       x       x       x       8       4       x       x        0.148s     1.032s ##
 634081842457840259:   |       x       x       x       |       x       29      x        0.001s     1.033s
 634081842457850260:   |       x       x       x       |       4       x       x        0.023s     1.056s
 634081842458080273:   |       x       x       x       |       x       x       x        0.013s     1.069s
 634081842458210281:   |       x       x       x       3       x       x       x        0.004s     1.073s
 634081842458250283:   |       x       x       x       36      x       x       x        0.003s     1.076s
 634081842458280285:   |       x       x       x       3       x       x       x        0.131s     1.207s ##
 634081842459590360:   0       x       x       x       x       x       x       x        0.001s     1.208s
 634081842459600360:   43      x       x       x       x       x       x       x        0.002s     1.210s
 634081842459620361:   0       x       x       x       x       x       x       x        0.001s     1.211s
 -----------------------------------------------------------------------------------------------------------------------------------
 Utilization:          57.8    30.3    46.9    39.6    76.5    53.6    45.4    .0       Average Utilization: 43.8</pre><p>
In the snippet above you should know that I replace the path to the files with <strong>…</strong> to
reduce the width of the output. Also the machine that I’m currently using has 8 cores
so it shows 8 nodes, on your machine you may have a different number of columns for
the node utilization table.
</p><p>
Sayed Ibrahim Hashimi
</p><img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=6cced95a-0f4a-4740-9dba-03782008d8d3" /></body>
      <title>MSBuild 4.0: New command line switches</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,6cced95a-0f4a-4740-9dba-03782008d8d3.aspx</guid>
      <link>http://sedodream.com/2010/04/30/MSBuild40NewCommandLineSwitches.aspx</link>
      <pubDate>Fri, 30 Apr 2010 00:38:03 GMT</pubDate>
      <description>If you are using &lt;a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx"&gt;MSBuild
4.0&lt;/a&gt; then you may be interested in knowing that there are a couple new switches
that you can pass to msbuild.exe when you kick off a build. The new switches, &lt;em&gt;&lt;strong&gt;/preprocess(/pp)&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;/detailedsummary(/ds)&lt;/strong&gt;&lt;/em&gt;,
are more convenient then necessary. 
&lt;h2&gt;/preprocess (/pp)
&lt;/h2&gt;
&lt;p&gt;
Since you can import other MSBuild files using the &lt;a href="http://msdn.microsoft.com/en-us/library/92x05xfs.aspx"&gt;Import
Element&lt;/a&gt; sometimes locating where a target, property or item is being defined can
lead to a search that takes you through several files. It can be even more confusing
if more than 1 file defines the property or target that you are interested in, because
you may have thought that you found the right target but you may one that was overridden
by another file. Now with MSBuild 4.0 you don’t have to search through all of those
files. You can use the switch /preprocess switch. Here is the snippet from msbuild.exe
/? describing it.
&lt;/p&gt;
&lt;pre class="brush: plain;"&gt;/preprocess[:file] 
 Creates a single, aggregated project file by inlining all the files that would be imported during a build, with their boundaries marked. This can be useful for figuring out what files are being imported and from where, and what they will contribute to the build. By default the output is written to the console window. If the path to an output file is provided that will be used instead.
 (Short form: /pp)
 Example:
   /pp:out.txt&lt;/pre&gt;
&lt;p&gt;
When you use this the full logical project file is dumped to the console, or optionally
to a file, and it includes references to where the elements are defined. For example
I created the following very simple project files.
&lt;/p&gt;
&lt;h3&gt;import-01.proj
&lt;/h3&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;Project ToolsVersion=&amp;quot;4.0&amp;quot; xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
    &amp;lt;Target Name=&amp;quot;TargetOne&amp;quot;&amp;gt;
        &amp;lt;Message Text=&amp;quot;From import-02.proj - TargetOne&amp;quot;/&amp;gt;
    &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/pre&gt;
&lt;h3&gt;import-02.proj
&lt;/h3&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;Project ToolsVersion=&amp;quot;4.0&amp;quot; xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
    &amp;lt;Target Name=&amp;quot;TargetTwo&amp;quot;&amp;gt;
        &amp;lt;Message Text=&amp;quot;From import-02.proj - TargetTwo&amp;quot;/&amp;gt;
    &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/pre&gt;
&lt;h3&gt;master.proj
&lt;/h3&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;Project ToolsVersion=&amp;quot;4.0&amp;quot; DefaultTargets=&amp;quot;TargetOne;TargetTwo&amp;quot; xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;

    &amp;lt;Target Name=&amp;quot;TargetOne&amp;quot;&amp;gt;
        &amp;lt;Message Text=&amp;quot;From master.proj - TargetOne&amp;quot;/&amp;gt;
    &amp;lt;/Target&amp;gt;

    &amp;lt;Target Name=&amp;quot;TargetTwo&amp;quot;&amp;gt;
        &amp;lt;Message Text=&amp;quot;From master.proj - TargetTwo&amp;quot;/&amp;gt;
    &amp;lt;/Target&amp;gt;

    &amp;lt;Import Project=&amp;quot;import-01.proj&amp;quot;/&amp;gt;
    &amp;lt;Import Project=&amp;quot;import-02.proj&amp;quot;/&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/pre&gt;
&lt;p&gt;
After executing the command msbuild.exe master.proj /pp:out.xml the following was
written to the out.xml file.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;!--
============================================================================================================================================
C:\temp\MSBuild\import\master.proj
============================================================================================================================================
--&amp;gt;
&amp;lt;Project ToolsVersion=&amp;quot;4.0&amp;quot; DefaultTargets=&amp;quot;TargetOne;TargetTwo&amp;quot; xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
  &amp;lt;Target Name=&amp;quot;TargetOne&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;From master.proj - TargetOne&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;Target Name=&amp;quot;TargetTwo&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;From master.proj - TargetTwo&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;!--
============================================================================================================================================
  &amp;lt;Import Project=&amp;quot;import-01.proj&amp;quot;&amp;gt;

C:\temp\MSBuild\import\import-01.proj
============================================================================================================================================
--&amp;gt;
  &amp;lt;Target Name=&amp;quot;TargetOne&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;From import-02.proj - TargetOne&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;!--
============================================================================================================================================
  &amp;lt;/Import&amp;gt;

C:\temp\MSBuild\import\master.proj
============================================================================================================================================
--&amp;gt;
  &amp;lt;!--
============================================================================================================================================
  &amp;lt;Import Project=&amp;quot;import-02.proj&amp;quot;&amp;gt;

C:\temp\MSBuild\import\import-02.proj
============================================================================================================================================
--&amp;gt;
  &amp;lt;Target Name=&amp;quot;TargetTwo&amp;quot;&amp;gt;
    &amp;lt;Message Text=&amp;quot;From import-02.proj - TargetTwo&amp;quot; /&amp;gt;
  &amp;lt;/Target&amp;gt;
  &amp;lt;!--
============================================================================================================================================
  &amp;lt;/Import&amp;gt;

C:\temp\MSBuild\import\master.proj
============================================================================================================================================
--&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/pre&gt;
&lt;p&gt;
As you can see with /pp it is very easy to see exactly what is defined where and at
what location.
&lt;/p&gt;
&lt;h2&gt;/detailedsummary (/ds)
&lt;/h2&gt;
&lt;p&gt;
Another new feature with MSBuild 4.0 is the &lt;strong&gt;&lt;em&gt;/detailedsummary (/ds)&lt;/em&gt;&lt;/strong&gt; command
line switch. When you use this switch you will be shown a detailed summary (&lt;em&gt;haha&lt;/em&gt;)
of build execution. This summary includes the amount of time spent build each project
file as well as the node utilization. I just preformed a build with the command &lt;strong&gt;msbuild
RuleStack.Engine.sln /m /ds&lt;/strong&gt; and the summary is shown below.
&lt;/p&gt;
&lt;pre class="brush: plain;"&gt;============================== Build Hierarchy (IDs represent configurations) =====================================================
 Id                  : Exclusive Time   Total Time   Path (Targets)
 -----------------------------------------------------------------------------------------------------------------------------------
 0                   : 0.020s           1.211s       C:\...\RuleStack.Engine.sln ()
 | 1                 : 0.667s           0.667s       C:\...\RuleStack.Engine.Common\RuleStack.Engine.Common.csproj ()
 | 3                 : 0.255s           0.718s       C:\...\Unittest\RuleStack.Engine.Tests\RuleStack.Engine.Tests.csproj ()
 | | 6               : 0.000s           0.000s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder .csproj ()
 | | 5               : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | 1               : 0.000s           0.000s       C:\...\RuleStack.Engine.Common\RuleStack.Engine.Common.csproj ()
 | | 2               : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | | 8               : 0.292s           0.460s       C:\...\RuleStack.Engine.Admin.Web\RuleStack.Engine.Admin.Web.csproj ()
 | | | 24            : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( GetNativeManifest)
 | | | 5             : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | . 2             : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | . 36              : 0.003s           0.003s       C:\...\RuleStack.Engine.Admin.Web\RuleStack.Engine.Admin.Web.csproj (GetNativeManifest)
 | 2                 : 0.319s           0.390s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | | 6               : 0.000s           0.000s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj ()
 | | 5               : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | 17              : 0.002s           0.002s       C:\...\RuleStack.Data\RuleStack.Data.csproj (GetNativeManifest)
 | . 21              : 0.001s           0.001s       C:\...\RuleStack.Data\RuleStack.Data.csproj (GetCopyToOutputDirectoryItems)
 | 4                 : 0.382s           0.567s       C:\...\RuleStack.Services\RuleStack.Services.csproj ()
 | | 5               : 0.000s           0.000s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | | 2               : 0.000s           0.000s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( )
 | | 24              : 0.002s           0.002s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( GetNativeManifest)
 | . 29              : 0.001s           0.001s       C:\...\RuleStack.Engine.Backend\RuleStack.Engine.Backend.csproj ( GetCopyToOutputDirectoryItems)
 | 7                 : 0.333s           0.337s       C:\...\ObjectBinder\Test_RuleStack.ObjectBinder\Test_RuleStack.ObjectBinder.csproj ()
 | | 6               : 0.000s           0.000s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj ()
 | | 13              : 0.001s           0.001s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj (GetNativeManifest)
 | . 19              : 0.001s           0.001s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj (GetCopyToOutputDirectoryItems)
 | 6                 : 0.210s           0.210s       C:\...\ObjectBinder\RuleStack.ObjectBinder\RuleStack.ObjectBinder.csproj ()
 | 5                 : 0.277s           0.277s       C:\...\RuleStack.Data\RuleStack.Data.csproj ()
 | . 12              : 0.000s           0.000s       C:\...\RuleStack.Engine.Common\RuleStack.Engine.Common.csproj (GetNativeManifest)
 . 43                : 0.002s           0.002s       C:\...\RuleStack.Engine.Admin.Web\RuleStack.Engine.Admin.Web.csproj.metaproj ()

 ============================== Node Utilization (IDs represent configurations) ====================================================
 Timestamp:            1       2       3       4       5       6       7       8        Duration   Cumulative
 -----------------------------------------------------------------------------------------------------------------------------------
 634081842447519669:   0       x       x       x       x       x       x       x        0.018s     0.018s
 634081842447699679:   1       x       x       x       x       x       x       x        0.461s     0.479s #########
 634081842452309943:   |       6       7       5       3       4       2       x        0.130s     0.609s ##
 634081842453610018:   |       |       |       |       8       |       |       x        0.086s     0.695s #
 634081842454470067:   |       |       |       |       |       |       |       x        0.001s     0.696s
 634081842454480067:   x       |       |       |       |       |       |       x        0.001s     0.697s
 634081842454490068:   x       |       x       |       |       x       |       x        0.001s     0.698s
 634081842454500068:   x       |       x       |       |       x       x       x        0.001s     0.699s
 634081842454510069:   x       x       7       |       |       x       x       x        0.002s     0.701s
 634081842454530070:   12      x       |       |       |       x       x       x        0.002s     0.703s
 634081842454550071:   |       13      x       |       |       x       x       x        0.001s     0.704s
 634081842454560072:   |       x       7       |       |       x       x       x        0.008s     0.712s
 634081842454640076:   |       x       |       |       x       x       x       x        0.054s     0.766s #
 634081842455180107:   |       x       |       x       x       x       2       x        0.003s     0.769s
 634081842455210109:   |       x       |       17      x       x       x       x        0.002s     0.771s
 634081842455230110:   |       x       |       x       x       x       2       x        0.036s     0.807s
 634081842455590131:   |       19      x       x       x       x       |       x        0.001s     0.808s
 634081842455600131:   |       x       7       x       x       x       |       x        0.018s     0.826s
 634081842455780142:   |       x       x       x       x       x       |       x        0.036s     0.862s
 634081842456140162:   |       x       x       21      x       x       x       x        0.001s     0.863s
 634081842456150163:   |       x       x       x       x       x       2       x        0.016s     0.879s
 634081842456310172:   |       x       x       x       8       4       x       x        0.003s     0.882s
 634081842456340174:   |       x       x       x       |       x       24      x        0.001s     0.883s
 634081842456350174:   |       x       x       x       x       x       |       x        0.001s     0.884s
 634081842456360175:   |       x       x       x       8       4       x       x        0.148s     1.032s ##
 634081842457840259:   |       x       x       x       |       x       29      x        0.001s     1.033s
 634081842457850260:   |       x       x       x       |       4       x       x        0.023s     1.056s
 634081842458080273:   |       x       x       x       |       x       x       x        0.013s     1.069s
 634081842458210281:   |       x       x       x       3       x       x       x        0.004s     1.073s
 634081842458250283:   |       x       x       x       36      x       x       x        0.003s     1.076s
 634081842458280285:   |       x       x       x       3       x       x       x        0.131s     1.207s ##
 634081842459590360:   0       x       x       x       x       x       x       x        0.001s     1.208s
 634081842459600360:   43      x       x       x       x       x       x       x        0.002s     1.210s
 634081842459620361:   0       x       x       x       x       x       x       x        0.001s     1.211s
 -----------------------------------------------------------------------------------------------------------------------------------
 Utilization:          57.8    30.3    46.9    39.6    76.5    53.6    45.4    .0       Average Utilization: 43.8&lt;/pre&gt;
&lt;p&gt;
In the snippet above you should know that I replace the path to the files with &lt;strong&gt;…&lt;/strong&gt; to
reduce the width of the output. Also the machine that I’m currently using has 8 cores
so it shows 8 nodes, on your machine you may have a different number of columns for
the node utilization table.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=6cced95a-0f4a-4740-9dba-03782008d8d3" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,6cced95a-0f4a-4740-9dba-03782008d8d3.aspx</comments>
      <category>MSBuild</category>
      <category>MSBuild 4.0</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=ff6dfe05-99e8-421b-aedd-d57babdeed66</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,ff6dfe05-99e8-421b-aedd-d57babdeed66.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,ff6dfe05-99e8-421b-aedd-d57babdeed66.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ff6dfe05-99e8-421b-aedd-d57babdeed66</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are using Visual Studio 2010 then you may already be familiar with the <a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx">Web.config
transformations</a> that are now available. What you might not know is that you can
use that same technology to transform config files outside of the build process. You
will need Visual Studio 2010 installed on the machine where you perform these transformations.
It is very easy to perform these transformation as well. Let’s say that we start with
the app.config file shown below.
</p>
        <pre class="brush: xml;">&lt;configuration&gt;
    &lt;connectionStrings&gt;
        &lt;clear/&gt;
        &lt;add name="Default" connectionString="Data Source=localhost;Initial Catalog=Sample01;Integrated Security=True;" /&gt;
    &lt;/connectionStrings&gt;
    
    &lt;appSettings&gt;
        &lt;add key="contactEmail" value="contact@demo.example.com"/&gt;
        &lt;add key="siteUrl" value="http://demo.example.com"/&gt;
    &lt;/appSettings&gt;
    
&lt;/configuration&gt;</pre>
        <p>
Then we create another file, transform.xml, which contains our transformations. That
file is shown below.
</p>
        <pre class="brush: xml;">&lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt;
    &lt;connectionStrings&gt;
        &lt;clear/&gt;
        &lt;add name="Default" connectionString="Data Source=NOT-localhost;Initial Catalog=Sample01;Integrated Security=True;" 
             xdt:Locator="Match(name)" xdt:Transform="Replace"/&gt;
    &lt;/connectionStrings&gt;

    &lt;appSettings&gt;
        &lt;add key="contactEmail" value="contact@example.com" xdt:Locator="Match(key)" xdt:Transform="Replace"/&gt;
        &lt;add key="siteUrl" value="http://example.com" xdt:Locator="Match(key)" xdt:Transform="Replace"/&gt;
    &lt;/appSettings&gt;

&lt;/configuration&gt;</pre>
        <p>
Then we can easily execute the transformations by using MSBuild. So I created a file
named trans.proj and it is shown below.
</p>
        <pre class="brush: xml;">&lt;Project ToolsVersion="4.0" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;UsingTask TaskName="TransformXml"
             AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/&gt;

    &lt;Target Name="Demo"&gt;
        &lt;TransformXml Source="app.config"
                      Transform="Transform.xml"
                      Destination="app.prod.config"/&gt;
    &lt;/Target&gt;
&lt;/Project&gt;</pre>
        <p>
This MSBuild file uses the TransformXml task which is shipped with Visual Studio 2010.
We specify the source file, transform file and the destination. Pretty straight forward.
</p>
        <p>
In order to execute this I open a Visual Studio 2010 command prompt, browse to the
directory containing both files, and enter the following command 
</p>
        <pre class="brush: plain;">msbuild trans.proj /t:Demo</pre>
        <p>
Once you do this then you will find the file app.prod.config with the following contents.
</p>
        <pre class="brush: xml;">&lt;configuration&gt;
    &lt;connectionStrings&gt;
        &lt;clear/&gt;
        &lt;add name="Default" connectionString="Data Source=NOT-localhost;Initial Catalog=Sample01;Integrated Security=True;"/&gt;
    &lt;/connectionStrings&gt;
    
    &lt;appSettings&gt;
        &lt;add key="contactEmail" value="contact@example.com"/&gt;
        &lt;add key="siteUrl" value="http://example.com"/&gt;
    &lt;/appSettings&gt;
    
&lt;/configuration&gt;</pre>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=ff6dfe05-99e8-421b-aedd-d57babdeed66" />
      </body>
      <title>Config transformations outside of web app builds</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,ff6dfe05-99e8-421b-aedd-d57babdeed66.aspx</guid>
      <link>http://sedodream.com/2010/04/26/ConfigTransformationsOutsideOfWebAppBuilds.aspx</link>
      <pubDate>Mon, 26 Apr 2010 04:22:06 GMT</pubDate>
      <description>&lt;p&gt;
If you are using Visual Studio 2010 then you may already be familiar with the &lt;a href="http://msdn.microsoft.com/en-us/library/dd465326.aspx"&gt;Web.config
transformations&lt;/a&gt; that are now available. What you might not know is that you can
use that same technology to transform config files outside of the build process. You
will need Visual Studio 2010 installed on the machine where you perform these transformations.
It is very easy to perform these transformation as well. Let’s say that we start with
the app.config file shown below.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;configuration&amp;gt;
    &amp;lt;connectionStrings&amp;gt;
        &amp;lt;clear/&amp;gt;
        &amp;lt;add name=&amp;quot;Default&amp;quot; connectionString=&amp;quot;Data Source=localhost;Initial Catalog=Sample01;Integrated Security=True;&amp;quot; /&amp;gt;
    &amp;lt;/connectionStrings&amp;gt;
    
    &amp;lt;appSettings&amp;gt;
        &amp;lt;add key=&amp;quot;contactEmail&amp;quot; value=&amp;quot;contact@demo.example.com&amp;quot;/&amp;gt;
        &amp;lt;add key=&amp;quot;siteUrl&amp;quot; value=&amp;quot;http://demo.example.com&amp;quot;/&amp;gt;
    &amp;lt;/appSettings&amp;gt;
    
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Then we create another file, transform.xml, which contains our transformations. That
file is shown below.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;configuration xmlns:xdt=&amp;quot;http://schemas.microsoft.com/XML-Document-Transform&amp;quot;&amp;gt;
    &amp;lt;connectionStrings&amp;gt;
        &amp;lt;clear/&amp;gt;
        &amp;lt;add name=&amp;quot;Default&amp;quot; connectionString=&amp;quot;Data Source=NOT-localhost;Initial Catalog=Sample01;Integrated Security=True;&amp;quot; 
             xdt:Locator=&amp;quot;Match(name)&amp;quot; xdt:Transform=&amp;quot;Replace&amp;quot;/&amp;gt;
    &amp;lt;/connectionStrings&amp;gt;

    &amp;lt;appSettings&amp;gt;
        &amp;lt;add key=&amp;quot;contactEmail&amp;quot; value=&amp;quot;contact@example.com&amp;quot; xdt:Locator=&amp;quot;Match(key)&amp;quot; xdt:Transform=&amp;quot;Replace&amp;quot;/&amp;gt;
        &amp;lt;add key=&amp;quot;siteUrl&amp;quot; value=&amp;quot;http://example.com&amp;quot; xdt:Locator=&amp;quot;Match(key)&amp;quot; xdt:Transform=&amp;quot;Replace&amp;quot;/&amp;gt;
    &amp;lt;/appSettings&amp;gt;

&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Then we can easily execute the transformations by using MSBuild. So I created a file
named trans.proj and it is shown below.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;Project ToolsVersion=&amp;quot;4.0&amp;quot; DefaultTargets=&amp;quot;Demo&amp;quot; xmlns=&amp;quot;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&amp;gt;
    &amp;lt;UsingTask TaskName=&amp;quot;TransformXml&amp;quot;
             AssemblyFile=&amp;quot;$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll&amp;quot;/&amp;gt;

    &amp;lt;Target Name=&amp;quot;Demo&amp;quot;&amp;gt;
        &amp;lt;TransformXml Source=&amp;quot;app.config&amp;quot;
                      Transform=&amp;quot;Transform.xml&amp;quot;
                      Destination=&amp;quot;app.prod.config&amp;quot;/&amp;gt;
    &amp;lt;/Target&amp;gt;
&amp;lt;/Project&amp;gt;&lt;/pre&gt;
&lt;p&gt;
This MSBuild file uses the TransformXml task which is shipped with Visual Studio 2010.
We specify the source file, transform file and the destination. Pretty straight forward.
&lt;/p&gt;
&lt;p&gt;
In order to execute this I open a Visual Studio 2010 command prompt, browse to the
directory containing both files, and enter the following command 
&lt;/p&gt;
&lt;pre class="brush: plain;"&gt;msbuild trans.proj /t:Demo&lt;/pre&gt;
&lt;p&gt;
Once you do this then you will find the file app.prod.config with the following contents.
&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;configuration&amp;gt;
    &amp;lt;connectionStrings&amp;gt;
        &amp;lt;clear/&amp;gt;
        &amp;lt;add name=&amp;quot;Default&amp;quot; connectionString=&amp;quot;Data Source=NOT-localhost;Initial Catalog=Sample01;Integrated Security=True;&amp;quot;/&amp;gt;
    &amp;lt;/connectionStrings&amp;gt;
    
    &amp;lt;appSettings&amp;gt;
        &amp;lt;add key=&amp;quot;contactEmail&amp;quot; value=&amp;quot;contact@example.com&amp;quot;/&amp;gt;
        &amp;lt;add key=&amp;quot;siteUrl&amp;quot; value=&amp;quot;http://example.com&amp;quot;/&amp;gt;
    &amp;lt;/appSettings&amp;gt;
    
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=ff6dfe05-99e8-421b-aedd-d57babdeed66" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,ff6dfe05-99e8-421b-aedd-d57babdeed66.aspx</comments>
      <category>Config-Transformation</category>
      <category>MSBuild</category>
      <category>MSBuild 4.0</category>
      <category>MSDeploy</category>
      <category>Visual Studio</category>
      <category>Visual Studio 2010</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=47388dd7-92bb-4984-b8d9-e55568342230</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,47388dd7-92bb-4984-b8d9-e55568342230.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,47388dd7-92bb-4984-b8d9-e55568342230.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=47388dd7-92bb-4984-b8d9-e55568342230</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">The other day I was working on a site which
required a pager, so I searched around a bit and I a <a href="http://weblogs.asp.net/gunnarpeipman/archive/2010/02/21/simple-pager-for-asp-net-mvc.aspx">pager</a>by <a href="http://weblogs.asp.net/gunnarpeipman/">Gunnar
Peipman</a> that looked promising. I found a few others but decided against them.
Some of them loaded all of the data into memory and then paged from there, and others
just flat out didn't work! In any case I had a good experience with Gunnar's. I wanted
to take what Gunnar had and create a view helper using my <a href="http://mvcviewhelpers.codeplex.com/">custom
view helpers</a>. Along the way I found myself writing some code using the <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.tagbuilder.aspx">TagBuilder</a>class
that just didn't sit well with me. Take a look at the snippet below which. <pre class="brush: csharp;">
TagBuilder startTag = new TagBuilder("a");
startTag.Attributes.Add("href", string.Format("{0}/{1}", this.UrlPrefix, 1));
startTag.SetInnerText("&lt;&lt;");
startTag.Attributes.Add("title", "first page");
httpResponse.Write(startTag.ToString(TagRenderMode.Normal));

TagBuilder previous = new TagBuilder("a");
previous.Attributes.Add("href", string.Format("{0}/{1}", this.UrlPrefix, this.CurrentPage - 1));
previous.SetInnerText("&lt;");
previous.Attributes.Add("title", "previous page");
httpResponse.Write(previous.ToString(TagRenderMode.Normal));
</pre>
I didn't like the fact that I had to make a bunch of calls to the tag builder to build
the HTML for me, it was just uglier than what I wanted. So I decided to create a new
tag builder which places an <a href="http://en.wikipedia.org/wiki/Fluent_interface">Fluent
interface</a> on top of it (ok, maybe its just <a href="http://en.wikipedia.org/wiki/Method_chaining">method
chaining</a>). The end result was the <a href="FluentTagBuilder">FluentTagBuilder</a>class.
I couldn't extend <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.tagbuilder.aspx">TagBuilder</a>because
I wanted to change the return types, so instead I created the class to just contain
one and to just pass the calls through to it. What I did was to declare all the same
properties and methods that the TagBuilder had, but just change the ones who returned
void to return the same object itself. So for example I created methods like. <pre class="brush: csharp;">
public FluentTagBuilder AddCssClass(string value)
{
    this.TagBuilder.AddCssClass(value);
    return this;
}

public FluentTagBuilder SetInnerHtml(string innerHtml)
{
    this.TagBuilder.InnerHtml = innerHtml;
    return this;
}
</pre>
With this I can chain different method calls together and create code which looks
better. If you've used <a href="http://jquery.com/">jQuery</a>then you are used to
this. With this in place I was able to convert the snippet above into the following. <pre class="brush: csharp;">
FluentTagBuilder startTag =
    new FluentTagBuilder("a")
    .AddAttribute("href", string.Format("{0}/{1}", this.UrlPrefix, 1))
    .SetInnerText("&lt;&lt;")
    .AddAttribute("title", "first page");

httpResponse.Write(startTag.ToString(TagRenderMode.Normal));

FluentTagBuilder previous =
    new FluentTagBuilder("a")
    .AddAttribute("href", string.Format("{0}/{1}", this.UrlPrefix, this.CurrentPage - 1))
    .SetInnerText("&lt;")
    .AddAttribute("title", "previous page");

httpResponse.Write(previous.ToString(TagRenderMode.Normal));
</pre>
To me this is a lot easier to read, and to create. If you agree you can grab the class
and include it in your projects. Links to full source files are below. 
<ol><li><a href="http://sedotech.com/Content/files/FluentTagBuilder.cs.txt">FluentTagBuilder.cs</a></li><li><a href="http://sedotech.com/Content/files/Pager.cs.txt">Pager.cs</a></li></ol>
Sayed Ibrahim Hashimi<img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=47388dd7-92bb-4984-b8d9-e55568342230" /></body>
      <title>ASP.NET MVC a better TagBuilder</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,47388dd7-92bb-4984-b8d9-e55568342230.aspx</guid>
      <link>http://sedodream.com/2010/04/20/ASPNETMVCABetterTagBuilder.aspx</link>
      <pubDate>Tue, 20 Apr 2010 04:10:14 GMT</pubDate>
      <description>The other day I was working on a site which required a pager, so I searched around a bit and I a &lt;a href="http://weblogs.asp.net/gunnarpeipman/archive/2010/02/21/simple-pager-for-asp-net-mvc.aspx"&gt;pager&lt;/a&gt;by &lt;a href="http://weblogs.asp.net/gunnarpeipman/"&gt;Gunnar
Peipman&lt;/a&gt; that looked promising. I found a few others but decided against them.
Some of them loaded all of the data into memory and then paged from there, and others
just flat out didn't work! In any case I had a good experience with Gunnar's. I wanted
to take what Gunnar had and create a view helper using my &lt;a href="http://mvcviewhelpers.codeplex.com/"&gt;custom
view helpers&lt;/a&gt;. Along the way I found myself writing some code using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.tagbuilder.aspx"&gt;TagBuilder&lt;/a&gt;class
that just didn't sit well with me. Take a look at the snippet below which. &lt;pre class="brush: csharp;"&gt;
TagBuilder startTag = new TagBuilder(&amp;quot;a&amp;quot;);
startTag.Attributes.Add(&amp;quot;href&amp;quot;, string.Format(&amp;quot;{0}/{1}&amp;quot;, this.UrlPrefix, 1));
startTag.SetInnerText(&amp;quot;&amp;lt;&amp;lt;&amp;quot;);
startTag.Attributes.Add(&amp;quot;title&amp;quot;, &amp;quot;first page&amp;quot;);
httpResponse.Write(startTag.ToString(TagRenderMode.Normal));

TagBuilder previous = new TagBuilder(&amp;quot;a&amp;quot;);
previous.Attributes.Add(&amp;quot;href&amp;quot;, string.Format(&amp;quot;{0}/{1}&amp;quot;, this.UrlPrefix, this.CurrentPage - 1));
previous.SetInnerText(&amp;quot;&amp;lt;&amp;quot;);
previous.Attributes.Add(&amp;quot;title&amp;quot;, &amp;quot;previous page&amp;quot;);
httpResponse.Write(previous.ToString(TagRenderMode.Normal));
&lt;/pre&gt;
I didn't like the fact that I had to make a bunch of calls to the tag builder to build
the HTML for me, it was just uglier than what I wanted. So I decided to create a new
tag builder which places an &lt;a href="http://en.wikipedia.org/wiki/Fluent_interface"&gt;Fluent
interface&lt;/a&gt; on top of it (ok, maybe its just &lt;a href="http://en.wikipedia.org/wiki/Method_chaining"&gt;method
chaining&lt;/a&gt;). The end result was the &lt;a href="FluentTagBuilder"&gt;FluentTagBuilder&lt;/a&gt;class.
I couldn't extend &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.tagbuilder.aspx"&gt;TagBuilder&lt;/a&gt;because
I wanted to change the return types, so instead I created the class to just contain
one and to just pass the calls through to it. What I did was to declare all the same
properties and methods that the TagBuilder had, but just change the ones who returned
void to return the same object itself. So for example I created methods like. &lt;pre class="brush: csharp;"&gt;
public FluentTagBuilder AddCssClass(string value)
{
    this.TagBuilder.AddCssClass(value);
    return this;
}

public FluentTagBuilder SetInnerHtml(string innerHtml)
{
    this.TagBuilder.InnerHtml = innerHtml;
    return this;
}
&lt;/pre&gt;
With this I can chain different method calls together and create code which looks
better. If you've used &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;then you are used to
this. With this in place I was able to convert the snippet above into the following. &lt;pre class="brush: csharp;"&gt;
FluentTagBuilder startTag =
    new FluentTagBuilder(&amp;quot;a&amp;quot;)
    .AddAttribute(&amp;quot;href&amp;quot;, string.Format(&amp;quot;{0}/{1}&amp;quot;, this.UrlPrefix, 1))
    .SetInnerText(&amp;quot;&amp;lt;&amp;lt;&amp;quot;)
    .AddAttribute(&amp;quot;title&amp;quot;, &amp;quot;first page&amp;quot;);

httpResponse.Write(startTag.ToString(TagRenderMode.Normal));

FluentTagBuilder previous =
    new FluentTagBuilder(&amp;quot;a&amp;quot;)
    .AddAttribute(&amp;quot;href&amp;quot;, string.Format(&amp;quot;{0}/{1}&amp;quot;, this.UrlPrefix, this.CurrentPage - 1))
    .SetInnerText(&amp;quot;&amp;lt;&amp;quot;)
    .AddAttribute(&amp;quot;title&amp;quot;, &amp;quot;previous page&amp;quot;);

httpResponse.Write(previous.ToString(TagRenderMode.Normal));
&lt;/pre&gt;
To me this is a lot easier to read, and to create. If you agree you can grab the class
and include it in your projects. Links to full source files are below. 
&lt;ol&gt;
&lt;li&gt;
&lt;a href="http://sedotech.com/Content/files/FluentTagBuilder.cs.txt"&gt;FluentTagBuilder.cs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://sedotech.com/Content/files/Pager.cs.txt"&gt;Pager.cs&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
Sayed Ibrahim Hashimi&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=47388dd7-92bb-4984-b8d9-e55568342230" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,47388dd7-92bb-4984-b8d9-e55568342230.aspx</comments>
      <category>ASP.NET MVC</category>
      <category>Fluent interface</category>
      <category>View helpers</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=a33d943a-3ad7-48a9-aa25-3e3d6b20572e</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,a33d943a-3ad7-48a9-aa25-3e3d6b20572e.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,a33d943a-3ad7-48a9-aa25-3e3d6b20572e.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a33d943a-3ad7-48a9-aa25-3e3d6b20572e</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today a friend of mine asked me to explain (<em>via email</em>) a few things to another
developer regarding some things I have done with the Entity Framework (EF). I figured
since I already typed it up I might as well share it here as well. So here it is.
</p>
        <p>
I have had 2 issues with using EF4 which I have found creative and effective work
around for.
</p>
        <p>
          <b>
            <u>Externalizing filters</u>
          </b>
        </p>
        <p>
The first issue, which also exists when using other frameworks, is that you end up
with an explosion of methods (<i>and usually a lot of duplicated code</i>). For instance
let’s say you have a table to store users. This table has an ID, and Email field and,
and let’s and OpenIdUrl. So you end up with the following methods.
</p>
        <pre class="brush: csharp;">User GetUserById(long id)

User GetUserByEmail(string email)

User GetUserByOpenIdUrl(string openIdUrl)</pre>
        <p>
Usually you’ll find that each of these methods have the exact same implementation
except a different where clause. Now there is a bigger problem in the fact that you
cannot anticipate everything that the user may want to filter on. Because of this
and the dynamic nature of IQueryable I have employed a technique using Expression
Trees to allow the user to declare the exact filter to be used via a lambda expression.
So for the users it’s very slick. For example I could create the following method
</p>
        <pre class="brush: csharp;">public User GetUser(Expression&lt;Func&lt;User, bool&gt;&gt; filter)
{
    if (filter == null)
    {
        filter = Const&lt;User&gt;.LinqExpression.LinqExpressionFuncAlwaysTrue;
    }

    User foundUser = null;
    using (InlineTasksContext dbContext = new InlineTasksContext())
    {
        dbContext.Connection.Open();
        foundUser = dbContext.Users.Where(filter).SingleIfExists();
    }

    return foundUser;
}</pre>
        <p>
In this case I’m allowing the user to pass in a filter that is applied to the query.
Here is how I could implement those three if I chose to as well.
</p>
        <pre class="brush: csharp;">public User GetUserById(long id)
{
    return this.GetUser(user =&gt; user.Id == id);
}
public User GetUserByEmail(string email)
{
    if (email == null) { throw new System.ArgumentNullException("email"); }

    return GetUser(user =&gt; user.Email == email);
}
public User GetUserByOpenIdUrl(string openIdUrl)
{
    if (string.IsNullOrEmpty(openIdUrl)) { throw new ArgumentNullException("openIdUrl"); }

    return GetUser(user =&gt; user.OpenIdUrl == openIdUrl);
}</pre>
        <p>
Note in the first method I am using some other helpers I created. Specifically the <strong><em>Const&lt;User&gt;.LinqExpression.LinqExpressionFuncAlwaysTrue</em></strong> as
well as the <strong><em>SingleIfExists</em></strong></p>
        <p>
extension method. I use the <strong><em>AlwaysTrue</em></strong> expression so that
way I don’t have to be worried about doing an if and having to maintain 2 select statements.
And the other (<strong><em>SingleIfExists</em></strong>) is used to just return null
instead of blowing up if no elements exist in the sequence.
</p>
        <p>
Since they are not the purpose of this email I’ve just put them at the bottom so that
you can read if you are interested.
</p>
        <p>
As Keith mentioned to me a while back Expression trees are not serializable so you
still end up with this problem if you are using a service based solution. But you
could try and use the sample <a href="http://code.msdn.microsoft.com/exprserialization">Expression
Tree Serialization</a> to take care of this for you, I’ve never tried it, but it’s
on my TODO list.
</p>
        <p>
          <b>
            <u>.Include</u>
          </b>
        </p>
        <p>
My next issue is that you are forced to declare what navigation properties (i.e. table
links) should be included in the query. This is done using the .Include method. So
back to our GetUser example, how can a framework know what tables values should be
extracted for? The end result is that the framework creator just includes a bunch
of tables and 90% of the time the result is just wasted resources because the other
data is never touched. Better is to provide a default which only includes the most
commonly used tables and another method that allows them to specify what they want.
Here is a sample for a <strong><em>GetTasksByUserId</em></strong> method
</p>
        <pre class="brush: csharp;">public IList&lt;Task&gt; GetTasksByUserId(long userId, IEnumerable&lt;string&gt; includeList)
{
    using (InlineTasksContext dbContext = new InlineTasksContext())
    {
        var result = (from t in dbContext.Tasks
                        .Include(includeList)
                        .Where(t=&gt;t.User.Id == 1)
                        select t)
                        .ToList();
        return result;
    }
}
 In this example I’m using an extension method for.Include which is defined as follows.
public static ObjectQuery&lt;T&gt; Include&lt;T&gt;(this ObjectQuery&lt;T&gt; query, IEnumerable&lt;string&gt; includes)
{
    if (query == null) { throw new System.ArgumentNullException("query"); }

    if (includes != null)
    {
        foreach (string include in includes)
        {
            query.Include(include);
        }
    }
    return query;
}</pre>
        <p>
So the idea is to create a framework which is both robust and easy to use, but at
the same time is not overly assumptive about what the users want. I think a lot more
can be done with EF and its dynamic nature.
</p>
        <p>
Does that cover what you were intending Keith? Any questions/comments please send
them my way.
</p>
        <p>
          <b>
            <u>Here are those methods I mentioned above.</u>
          </b>
        </p>
        <pre class="brush: csharp;">public static class LinqExtensions
{
    public static T SingleIfExists&lt;T&gt;(this IQueryable&lt;T&gt; query)
    {
        if (query == null) { throw new System.ArgumentNullException("query"); }

        T result = default(T);
        if (query.Count() &gt; 0)
        {
            result = query.Single();
        }

        return result;
    }
}
//----------------------------------------------------------------------------------------------------
public class Const&lt;T&gt;
{
    public static class Predicate
    {
        public static Predicate&lt;T&gt; AlwaysTrue
        {
            get
            {
                return x =&gt; true;
            }
        }

        public static Predicate&lt;T&gt; AlwaysFalse
        {
            get
            {
                return x =&gt; false;
            }
        }
    }

    public class LinqExpression
    {
        public static Expression&lt;Func&lt;T, bool&gt;&gt; LinqExpressionFuncAlwaysTrue
        {
            get
            {
                return x =&gt; true;
            }
        }
    }
}</pre>
Sayed Ibrahim Hashimi<img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=a33d943a-3ad7-48a9-aa25-3e3d6b20572e" /></body>
      <title>Entity Framework: Externalizing filters and dynamic includes</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,a33d943a-3ad7-48a9-aa25-3e3d6b20572e.aspx</guid>
      <link>http://sedodream.com/2010/04/09/EntityFrameworkExternalizingFiltersAndDynamicIncludes.aspx</link>
      <pubDate>Fri, 09 Apr 2010 01:49:32 GMT</pubDate>
      <description>&lt;p&gt;
Today a friend of mine asked me to explain (&lt;em&gt;via email&lt;/em&gt;) a few things to another
developer regarding some things I have done with the Entity Framework (EF). I figured
since I already typed it up I might as well share it here as well. So here it is.
&lt;/p&gt;
&lt;p&gt;
I have had 2 issues with using EF4 which I have found creative and effective work
around for.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;&lt;u&gt;Externalizing filters&lt;/u&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
The first issue, which also exists when using other frameworks, is that you end up
with an explosion of methods (&lt;i&gt;and usually a lot of duplicated code&lt;/i&gt;). For instance
let’s say you have a table to store users. This table has an ID, and Email field and,
and let’s and OpenIdUrl. So you end up with the following methods.
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;User GetUserById(long id)

User GetUserByEmail(string email)

User GetUserByOpenIdUrl(string openIdUrl)&lt;/pre&gt;
&lt;p&gt;
Usually you’ll find that each of these methods have the exact same implementation
except a different where clause. Now there is a bigger problem in the fact that you
cannot anticipate everything that the user may want to filter on. Because of this
and the dynamic nature of IQueryable I have employed a technique using Expression
Trees to allow the user to declare the exact filter to be used via a lambda expression.
So for the users it’s very slick. For example I could create the following method
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public User GetUser(Expression&amp;lt;Func&amp;lt;User, bool&amp;gt;&amp;gt; filter)
{
    if (filter == null)
    {
        filter = Const&amp;lt;User&amp;gt;.LinqExpression.LinqExpressionFuncAlwaysTrue;
    }

    User foundUser = null;
    using (InlineTasksContext dbContext = new InlineTasksContext())
    {
        dbContext.Connection.Open();
        foundUser = dbContext.Users.Where(filter).SingleIfExists();
    }

    return foundUser;
}&lt;/pre&gt;
&lt;p&gt;
In this case I’m allowing the user to pass in a filter that is applied to the query.
Here is how I could implement those three if I chose to as well.
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public User GetUserById(long id)
{
    return this.GetUser(user =&amp;gt; user.Id == id);
}
public User GetUserByEmail(string email)
{
    if (email == null) { throw new System.ArgumentNullException("email"); }

    return GetUser(user =&amp;gt; user.Email == email);
}
public User GetUserByOpenIdUrl(string openIdUrl)
{
    if (string.IsNullOrEmpty(openIdUrl)) { throw new ArgumentNullException("openIdUrl"); }

    return GetUser(user =&amp;gt; user.OpenIdUrl == openIdUrl);
}&lt;/pre&gt;
&lt;p&gt;
Note in the first method I am using some other helpers I created. Specifically the &lt;strong&gt;&lt;em&gt;Const&amp;lt;User&amp;gt;.LinqExpression.LinqExpressionFuncAlwaysTrue&lt;/em&gt;&lt;/strong&gt; as
well as the &lt;strong&gt;&lt;em&gt;SingleIfExists&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
extension method. I use the &lt;strong&gt;&lt;em&gt;AlwaysTrue&lt;/em&gt;&lt;/strong&gt; expression so that
way I don’t have to be worried about doing an if and having to maintain 2 select statements.
And the other (&lt;strong&gt;&lt;em&gt;SingleIfExists&lt;/em&gt;&lt;/strong&gt;) is used to just return null
instead of blowing up if no elements exist in the sequence.
&lt;/p&gt;
&lt;p&gt;
Since they are not the purpose of this email I’ve just put them at the bottom so that
you can read if you are interested.
&lt;/p&gt;
&lt;p&gt;
As Keith mentioned to me a while back Expression trees are not serializable so you
still end up with this problem if you are using a service based solution. But you
could try and use the sample &lt;a href="http://code.msdn.microsoft.com/exprserialization"&gt;Expression
Tree Serialization&lt;/a&gt; to take care of this for you, I’ve never tried it, but it’s
on my TODO list.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;&lt;u&gt;.Include&lt;/u&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
My next issue is that you are forced to declare what navigation properties (i.e. table
links) should be included in the query. This is done using the .Include method. So
back to our GetUser example, how can a framework know what tables values should be
extracted for? The end result is that the framework creator just includes a bunch
of tables and 90% of the time the result is just wasted resources because the other
data is never touched. Better is to provide a default which only includes the most
commonly used tables and another method that allows them to specify what they want.
Here is a sample for a &lt;strong&gt;&lt;em&gt;GetTasksByUserId&lt;/em&gt;&lt;/strong&gt; method
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public IList&amp;lt;Task&amp;gt; GetTasksByUserId(long userId, IEnumerable&amp;lt;string&amp;gt; includeList)
{
    using (InlineTasksContext dbContext = new InlineTasksContext())
    {
        var result = (from t in dbContext.Tasks
                        .Include(includeList)
                        .Where(t=&amp;gt;t.User.Id == 1)
                        select t)
                        .ToList();
        return result;
    }
}
 In this example I’m using an extension method for.Include which is defined as follows.
public static ObjectQuery&amp;lt;T&amp;gt; Include&amp;lt;T&amp;gt;(this ObjectQuery&amp;lt;T&amp;gt; query, IEnumerable&amp;lt;string&amp;gt; includes)
{
    if (query == null) { throw new System.ArgumentNullException("query"); }

    if (includes != null)
    {
        foreach (string include in includes)
        {
            query.Include(include);
        }
    }
    return query;
}&lt;/pre&gt;
&lt;p&gt;
So the idea is to create a framework which is both robust and easy to use, but at
the same time is not overly assumptive about what the users want. I think a lot more
can be done with EF and its dynamic nature.
&lt;/p&gt;
&lt;p&gt;
Does that cover what you were intending Keith? Any questions/comments please send
them my way.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;&lt;u&gt;Here are those methods I mentioned above.&lt;/u&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public static class LinqExtensions
{
    public static T SingleIfExists&amp;lt;T&amp;gt;(this IQueryable&amp;lt;T&amp;gt; query)
    {
        if (query == null) { throw new System.ArgumentNullException("query"); }

        T result = default(T);
        if (query.Count() &amp;gt; 0)
        {
            result = query.Single();
        }

        return result;
    }
}
//----------------------------------------------------------------------------------------------------
public class Const&amp;lt;T&amp;gt;
{
    public static class Predicate
    {
        public static Predicate&amp;lt;T&amp;gt; AlwaysTrue
        {
            get
            {
                return x =&amp;gt; true;
            }
        }

        public static Predicate&amp;lt;T&amp;gt; AlwaysFalse
        {
            get
            {
                return x =&amp;gt; false;
            }
        }
    }

    public class LinqExpression
    {
        public static Expression&amp;lt;Func&amp;lt;T, bool&amp;gt;&amp;gt; LinqExpressionFuncAlwaysTrue
        {
            get
            {
                return x =&amp;gt; true;
            }
        }
    }
}&lt;/pre&gt;
Sayed Ibrahim Hashimi&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=a33d943a-3ad7-48a9-aa25-3e3d6b20572e" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,a33d943a-3ad7-48a9-aa25-3e3d6b20572e.aspx</comments>
      <category>Entity</category>
      <category>Entity Framework</category>
      <category>LINQ</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=beb40727-c878-440d-bb2d-80501bb77312</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,beb40727-c878-440d-bb2d-80501bb77312.aspx</pingback:target>
      <dc:creator>Ibrahim</dc:creator>
      <wfw:comment>http://sedodream.com/CommentView,guid,beb40727-c878-440d-bb2d-80501bb77312.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=beb40727-c878-440d-bb2d-80501bb77312</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The story around <a href="http://msdn.microsoft.com/en-us/library/cc668201%28VS.100%29.aspx">routing</a> in
ASP.NET MVC is pretty good. When a resource is requested the action that it is routed
to is determined and the parameters to the action are initialized. Counter to that
when you build a link you specify the argument values and it creates the url for you.
So if your routes happen to change your application shouldn’t be bothered by that.
One area which can be problematic for this is if you are making any ajax requests.
What I’ve done to minimize the impact of route changes to Ajax requests is to have
the script make a call to determine the correct route. In the most trivial case this
is extremely easy. You call an action, which has a known route, passing into it the
name of the action and controller. It returns to you the url for the route. This works
really good, but the problem is when your routes have parameters, how do you handle
those?
</p>
        <p>
First let’s take a look at the Javascript and then the definition of the action method
which it calls.
</p>
        <pre class="brush: js;">// wire up the event for the enter button
$("#searchText").keypress(function (event) {
    if (event.keyCode == 13) {
        // grab the text that is inside the box
        var text = $("#searchText").val();

        var routData = {
            controllerName: 'Search',
            actionName: 'Search',
            paramValues: "{ criteria: '" + text + "' }"
        };

        $.ajax({
            url: "/Home/MapRoute",
            data: routData,
            success: function (data) {
                window.location.href = data;
            },
            error: function (data) {
                alert('there was a failure on the internets');
            }
        });

    }
});</pre>
        <p>
Here I am building a Javascript object named routeData. This is declared in <a href="http://json.org/">JSON</a>.
One thing to pay attention to is the fact that the value for <em><strong>paramValues</strong></em> is
a string containing JSON. This is passed to the controller action.
</p>
        <p>
I’m using <a href="http://jquery.com/">jQuery</a> to make an Ajax request to <em>/Home/MapRoute</em>.
This maps to the method shown below.
</p>
        <pre class="brush: csharp;">public JsonResult MapRoute(string actionName, string controllerName, string paramValues)
{
    JavaScriptSerializer jss = new JavaScriptSerializer();

    Dictionary&lt;string, string&gt; parameters = jss.Deserialize&lt;Dictionary&lt;string, string&gt;&gt;(paramValues);

    RouteValueDictionary rd = new RouteValueDictionary();
    foreach (string key in parameters.Keys)
    {
        rd.Add(key, parameters[key]);
    }

    UrlHelper urlHelper = new UrlHelper(this.Request.RequestContext);
    string url = urlHelper.Action(actionName, controllerName, rd);

    return Json(url, JsonRequestBehavior.AllowGet);
}</pre>
        <p>
Here I’m using the <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx">JavaScriptSerializer</a> to
convert the JSON string into a dictionary, with string as key and value. I use that
dictionary to create a <a href="http://msdn.microsoft.com/en-us/library/system.web.routing.routevaluedictionary.aspx">RouteValueDictionary</a> which
is passed, along with other parameters, into the <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx">UrlHelper</a> to
generate the url. When you return the Json result you must specify <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.jsonrequestbehavior%28VS.100%29.aspx">JsonRequestBehavior</a>.AllowGet,
otherwise a <strong><em>500 internal service error</em></strong> will be returned.
I think this is new with ASP.NET 2.
</p>
        <p>
When the action method returns, you can use that url. The drawback to this approach
is that you will make an extra request to determine the url, but you will be sure
that those urls are correct. Also you could cache the results with <a href="http://www.asp.net/learn/mvc/tutorial-15-cs.aspx">Output
Caching</a> since the routes won’t change.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=beb40727-c878-440d-bb2d-80501bb77312" />
      </body>
      <title>ASP.NET MVC Route + Ajax + jQuery</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,beb40727-c878-440d-bb2d-80501bb77312.aspx</guid>
      <link>http://sedodream.com/2010/04/02/ASPNETMVCRouteAjaxJQuery.aspx</link>
      <pubDate>Fri, 02 Apr 2010 05:24:30 GMT</pubDate>
      <description>&lt;p&gt;
The story around &lt;a href="http://msdn.microsoft.com/en-us/library/cc668201%28VS.100%29.aspx"&gt;routing&lt;/a&gt; in
ASP.NET MVC is pretty good. When a resource is requested the action that it is routed
to is determined and the parameters to the action are initialized. Counter to that
when you build a link you specify the argument values and it creates the url for you.
So if your routes happen to change your application shouldn’t be bothered by that.
One area which can be problematic for this is if you are making any ajax requests.
What I’ve done to minimize the impact of route changes to Ajax requests is to have
the script make a call to determine the correct route. In the most trivial case this
is extremely easy. You call an action, which has a known route, passing into it the
name of the action and controller. It returns to you the url for the route. This works
really good, but the problem is when your routes have parameters, how do you handle
those?
&lt;/p&gt;
&lt;p&gt;
First let’s take a look at the Javascript and then the definition of the action method
which it calls.
&lt;/p&gt;
&lt;pre class="brush: js;"&gt;// wire up the event for the enter button
$(&amp;quot;#searchText&amp;quot;).keypress(function (event) {
    if (event.keyCode == 13) {
        // grab the text that is inside the box
        var text = $(&amp;quot;#searchText&amp;quot;).val();

        var routData = {
            controllerName: 'Search',
            actionName: 'Search',
            paramValues: &amp;quot;{ criteria: '&amp;quot; + text + &amp;quot;' }&amp;quot;
        };

        $.ajax({
            url: &amp;quot;/Home/MapRoute&amp;quot;,
            data: routData,
            success: function (data) {
                window.location.href = data;
            },
            error: function (data) {
                alert('there was a failure on the internets');
            }
        });

    }
});&lt;/pre&gt;
&lt;p&gt;
Here I am building a Javascript object named routeData. This is declared in &lt;a href="http://json.org/"&gt;JSON&lt;/a&gt;.
One thing to pay attention to is the fact that the value for &lt;em&gt;&lt;strong&gt;paramValues&lt;/strong&gt;&lt;/em&gt; is
a string containing JSON. This is passed to the controller action.
&lt;/p&gt;
&lt;p&gt;
I’m using &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt; to make an Ajax request to &lt;em&gt;/Home/MapRoute&lt;/em&gt;.
This maps to the method shown below.
&lt;/p&gt;
&lt;pre class="brush: csharp;"&gt;public JsonResult MapRoute(string actionName, string controllerName, string paramValues)
{
    JavaScriptSerializer jss = new JavaScriptSerializer();

    Dictionary&amp;lt;string, string&amp;gt; parameters = jss.Deserialize&amp;lt;Dictionary&amp;lt;string, string&amp;gt;&amp;gt;(paramValues);

    RouteValueDictionary rd = new RouteValueDictionary();
    foreach (string key in parameters.Keys)
    {
        rd.Add(key, parameters[key]);
    }

    UrlHelper urlHelper = new UrlHelper(this.Request.RequestContext);
    string url = urlHelper.Action(actionName, controllerName, rd);

    return Json(url, JsonRequestBehavior.AllowGet);
}&lt;/pre&gt;
&lt;p&gt;
Here I’m using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx"&gt;JavaScriptSerializer&lt;/a&gt; to
convert the JSON string into a dictionary, with string as key and value. I use that
dictionary to create a &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.routing.routevaluedictionary.aspx"&gt;RouteValueDictionary&lt;/a&gt; which
is passed, along with other parameters, into the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx"&gt;UrlHelper&lt;/a&gt; to
generate the url. When you return the Json result you must specify &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.jsonrequestbehavior%28VS.100%29.aspx"&gt;JsonRequestBehavior&lt;/a&gt;.AllowGet,
otherwise a &lt;strong&gt;&lt;em&gt;500 internal service error&lt;/em&gt;&lt;/strong&gt; will be returned.
I think this is new with ASP.NET 2.
&lt;/p&gt;
&lt;p&gt;
When the action method returns, you can use that url. The drawback to this approach
is that you will make an extra request to determine the url, but you will be sure
that those urls are correct. Also you could cache the results with &lt;a href="http://www.asp.net/learn/mvc/tutorial-15-cs.aspx"&gt;Output
Caching&lt;/a&gt; since the routes won’t change.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=beb40727-c878-440d-bb2d-80501bb77312" /&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,beb40727-c878-440d-bb2d-80501bb77312.aspx</comments>
      <category>ASP.NET MVC</category>
      <category>Javascript</category>
      <category>jQuery</category>
      <category>routing</category>
    </item>
  </channel>
</rss>