<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Sayed Ibrahim Hashimi - MSBuild, C#, Visual Studio, Training, and more</title>
  <link rel="alternate" type="text/html" href="http://sedodream.com/" />
  <link rel="self" href="http://sedodream.com/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2010-08-15T11:56:50.508-07:00</updated>
  <author>
    <name>Sayed Ibrahim Hashimi</name>
  </author>
  <subtitle>MSBuild, C#, Visual Studio and more</subtitle>
  <id>http://sedodream.com/</id>
  <generator uri="http://dasblog.info/" version="2.3.9074.18820">DasBlog</generator>
  <entry>
    <title>Web Deployment Tool (MSDeploy): How to exclude files from package based on Configuration</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/08/15/WebDeploymentToolMSDeployHowToExcludeFilesFromPackageBasedOnConfiguration.aspx" />
    <id>http://sedodream.com/PermaLink,guid,c926b957-b578-4d98-bbce-2260945de5cf.aspx</id>
    <published>2010-08-15T11:56:50.508-07:00</published>
    <updated>2010-08-15T11:56:50.508-07:00</updated>
    <category term="Deployment" label="Deployment" scheme="http://sedodream.com/CategoryView,category,Deployment.aspx" />
    <category term="MSBuild" label="MSBuild" scheme="http://sedodream.com/CategoryView,category,MSBuild.aspx" />
    <category term="MSDeploy" label="MSDeploy" scheme="http://sedodream.com/CategoryView,category,MSDeploy.aspx" />
    <category term="Web Deployment Tool" label="Web Deployment Tool" scheme="http://sedodream.com/CategoryView,category,WebDeploymentTool.aspx" />
    <category term="Web Publishing Pipeline" label="Web Publishing Pipeline" scheme="http://sedodream.com/CategoryView,category,WebPublishingPipeline.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A while back I posted an entry on <a href="http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx">How
to build a package including extra files or exclude files</a> a reader posted a question
to <a href="http://stackoverflow.com">StackOverflow.com</a> asking how to exclude
files from the created package based on the configuration for the project. He asked
me to take a look at it so I figured it would be a good blog post.
</p>
        <p>
From the previous <a href="http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx">post</a> we
can see that the way to exclude files from packaging is by declaring an item as follows.
</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>
So we need to extend this to only exclude files if the config is a certain value.
Since MSBuild supports <a href="http://msdn.microsoft.com/en-us/library/7szfhaft.aspx">conditions
on almost every element</a> this is going to be a breeze. As an example I have created
a sample web project with a scripts directory that has the following files.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/WebDeploymentToolMSDeployHowtoexcludefil_A290/image_4.png">
            <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/WebDeploymentToolMSDeployHowtoexcludefil_A290/image_thumb_1.png" width="244" height="214" />
          </a>
        </p>
        <p>
In that folder there I there are two files which have ‘debug’ in the name of the file.
We only want those to be included if the configuration is set to <strong>Debug</strong>,
or another way of putting it is we want to exclude those files if the configuration
is not Debug. So we need to create to add files to the <strong>ExcludeFromPackageFiles</strong> and
guard it with the condition that the configuration is not debug. Here is that.
</p>
        <pre class="brush: xml;">&lt;Target Name="CustomExlucdeFiles" BeforeTargets="ExcludeFilesFromPackage"&gt;
  &lt;ItemGroup Condition=" '$(Configuration)'!='Debug' "&gt;
    &lt;ExcludeFromPackageFiles Include="scripts\**\*debug*" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;Message Text="Configuration: $(Configuration)" /&gt;
  &lt;Message Text="ExcludeFromPackageFiles: @(ExcludeFromPackageFiles)" Importance="high" /&gt;
&lt;/Target&gt;</pre>
        <p>
You can see the item group defined above which does what we want. Please note that
I put this inside of a target, CustomExcludeFiles, I will discuss why in a bit but
let’s stay on topic now. So this is pretty straight forward when the item group is
evaluated all files under <em>scripts</em> which have <em>debug</em> in the file name
will be excluded if the configuration is not set to <em>Debug</em>. Let’s see if it
works, I will build the deployment package once in both debug &amp; release then examine
the contents of the Package folder.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/WebDeploymentToolMSDeployHowtoexcludefil_A290/image_6.png">
            <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/WebDeploymentToolMSDeployHowtoexcludefil_A290/image_thumb_2.png" width="709" height="465" />
          </a>
        </p>
        <p>
So we can see that the files were excluded from the Release package. Now back to why
I declared the item group in a target instead of directly in the project file itself.
I noticed that if I declare that item in the project file there are some visual issues
with the representation in the Solution Explorer. To be specific the files show up
as dups, see image below.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/WebDeploymentToolMSDeployHowtoexcludefil_A290/image_8.png">
            <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/WebDeploymentToolMSDeployHowtoexcludefil_A290/image_thumb_3.png" width="244" height="233" />
          </a>
        </p>
        <p>
I have reported this to the right people, but for now this is a harmless issue with
an easy workaround.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=c926b957-b578-4d98-bbce-2260945de5cf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>MSBuild: Empty Metadata versus no metadata, inline task to solve</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/08/04/MSBuildEmptyMetadataVersusNoMetadataInlineTaskToSolve.aspx" />
    <id>http://sedodream.com/PermaLink,guid,62f78f75-c505-4f65-ad44-072f9cf58365.aspx</id>
    <published>2010-08-03T23:17:20.316-07:00</published>
    <updated>2010-08-03T23:24:06.096-07:00</updated>
    <category term="inline task" label="inline task" scheme="http://sedodream.com/CategoryView,category,inlineTask.aspx" />
    <category term="MSBuild" label="MSBuild" scheme="http://sedodream.com/CategoryView,category,MSBuild.aspx" />
    <category term="MSBuild 4.0" label="MSBuild 4.0" scheme="http://sedodream.com/CategoryView,category,MSBuild40.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently there was a question on an internal mailing list asking the question can
you tell the difference between
</p>
        <pre class="brush: xml;">&lt;ItemGroup&gt;
  &lt;Content Include="Sample-DefinedEmpty.sdf"&gt;
    &lt;SubPath&gt;&lt;/SubPath&gt;
  &lt;/Content&gt;
&lt;/ItemGroup&gt;</pre>
        <p>
and
</p>
        <pre class="brush: xml;">&lt;ItemGroup&gt;
  &lt;Content Include="Sample-NotDefined.sdf"&gt;
  &lt;/Content&gt;
&lt;/ItemGroup&gt;</pre>
        <p>
You cannot detect this out of the box, but you can by creating a custom task. Better
would be to create an inline task so that you don’t have to deal with the headache
of maintaining a .dll for something like this, unless you are using it on many different
project files. Basically the task that we will create will need two parameters; the
Item itself (single value) and MetadataName (metadata name to check for). It will
have one output parameter, MetadataDefined, which we can check to see if the metadata
value was defined or not.
</p>
        <p>
This is a pretty easy task to create because we just look at the <a href="http://msdn.microsoft.com/en-us/library/microsoft.build.framework.itaskitem.metadatanames.aspx">MetadataNames</a> property
on the <a href="http://msdn.microsoft.com/en-us/library/microsoft.build.framework.itaskitem.aspx">ITaskItem</a> interface.
The task as well as a sample target is shown below.
</p>
        <pre class="brush: xml;">&lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  
  &lt;UsingTask TaskFactory="CodeTaskFactory"
             TaskName="MetadataExists"
             AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"&gt;
    &lt;ParameterGroup&gt;
      &lt;MetadataName Required="true"/&gt;
      &lt;Item ParameterType="Microsoft.Build.Framework.ITaskItem"/&gt;
      &lt;MetadataDefined ParameterType="System.Boolean" Output="true" /&gt;      
    &lt;/ParameterGroup&gt;
    &lt;Task&gt;
      &lt;Code&gt;
        &lt;![CDATA[
            this.MetadataDefined = false;
            if (this.Item != null)
            {
                foreach (string name in this.Item.MetadataNames)
                {
                    if (string.Compare(this.MetadataName, name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        this.MetadataDefined = true;
                        break;
                    }
                }
            }          
        ]]&gt;
      &lt;/Code&gt;
    &lt;/Task&gt;
  &lt;/UsingTask&gt;

  &lt;Target Name="CheckForMetadata"&gt;

&lt;ItemGroup&gt;
  &lt;Content Include="Sample-DefinedEmpty.sdf"&gt;
    &lt;SubPath&gt;&lt;/SubPath&gt;
  &lt;/Content&gt;
  &lt;Content Include="Sample-NotDefined.sdf"&gt;
  &lt;/Content&gt;
&lt;/ItemGroup&gt;

    &lt;Message Text="Starting - Content"/&gt;

    &lt;!-- Create an Item which has exactly 1 value to pass to the task --&gt;
    &lt;ItemGroup&gt;
      &lt;_Content Remove="@(_Content)"/&gt;
      &lt;_Content Include="@(Content)" Condition=" '%(Content.Identity)' == 'Sample-DefinedEmpty.sdf' "/&gt;
    &lt;/ItemGroup&gt;
    &lt;MetadataExists MetadataName="SubPath" Item="@(_Content)"&gt;
      &lt;Output PropertyName="existsResult" TaskParameter="MetadataDefined"/&gt;
    &lt;/MetadataExists&gt;

    &lt;Message Text="existsResult: $(existsResult)" /&gt;


    &lt;Message Text="Starting - Content2"/&gt;
    &lt;!-- Create an Item which has exactly 1 value to pass to the task --&gt;
    &lt;ItemGroup&gt;
      &lt;_Content Remove="@(_Content)"/&gt;
      &lt;_Content Include="@(Content)" Condition=" '%(Content.Identity)' == 'Sample-NotDefined.sdf' "/&gt;
    &lt;/ItemGroup&gt;
    &lt;MetadataExists MetadataName="SubPath" Item="@(_Content)"&gt;
      &lt;Output PropertyName="existsResult" TaskParameter="MetadataDefined"/&gt;
    &lt;/MetadataExists&gt;

    &lt;Message Text="existsResult: $(existsResult)" /&gt;
  &lt;/Target&gt;
&lt;/Project&gt;</pre>
        <p>
Here you can take a look at the MetadataExists task and its usage. The only thing
that really needs to be pointed out here is that since this task accepts a single
item value we will have to take the item group Content and pick from it a specific
value which is passed to the task. That is what I am doing when I create the temp
item <strong>_Content</strong>. If you execute the CheckForMetadata target with the
command <strong>msbuild CheckMetadata01.proj /t:CheckForMetadata</strong> the result
will be what is shown below.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/MSBuildEmptyMetadataversusnometadatainli_14566/CheckMetadata_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="CheckMetadata" border="0" alt="CheckMetadata" src="http://sedodream.com/content/binary/WindowsLiveWriter/MSBuildEmptyMetadataversusnometadatainli_14566/CheckMetadata_2.png" />
          </a>
        </p>
        <p>
So from the output you can see that we were able to tell the difference!
</p>
        <p>
BTW, if you were wondering if you can do the same with properties, the answer is no.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=62f78f75-c505-4f65-ad44-072f9cf58365" />
      </div>
    </content>
  </entry>
  <entry>
    <title>MSBuild 4 : Inline Tasks Part 3, tasks in JavaScript</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/07/31/MSBuild4InlineTasksPart3TasksInJavaScript.aspx" />
    <id>http://sedodream.com/PermaLink,guid,69f95d98-09e1-4f33-bd6c-5e131a591296.aspx</id>
    <published>2010-07-30T21:22:28.053-07:00</published>
    <updated>2010-07-30T22:35:23.409-07:00</updated>
    <category term="inline task" label="inline task" scheme="http://sedodream.com/CategoryView,category,inlineTask.aspx" />
    <category term="MSBuild" label="MSBuild" scheme="http://sedodream.com/CategoryView,category,MSBuild.aspx" />
    <category term="MSBuild 4.0" label="MSBuild 4.0" scheme="http://sedodream.com/CategoryView,category,MSBuild40.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A while back I talked about the new feature available in MSBuild 4 Inline Tasks in.
</p>
        <ul>
          <li>
            <a href="http://sedodream.com/2010/01/20/MSBuild40InlineTasks.aspx">MSBuild 4.0: Inline
Tasks</a>
          </li>
          <li>
            <a href="http://sedodream.com/2010/01/22/MSBuild40InlineTasksPart2.aspx">MSBuild 4.0:
Inline Tasks Part 2</a>
          </li>
        </ul>
        <p>
In the previous examples I have use <a href="http://msdn.microsoft.com/en-us/vcsharp/default.aspx">C#</a> as
my language of choice. C# is not your only choice you can also use VB.Net but you
can also use JavaScript! When MSBuild creates the class for the inline task it uses
CodeDom to do so, and JavaScript is one of its supported languages. Perhaps its actually
called JScript. In any case take a look at the project file below which shows this
in action.
</p>
        <pre class="brush: js;">&lt;Project ToolsVersion="4.0" DefaultTargets="PrintValues" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

  &lt;UsingTask
    TaskName="Jsex01"
    TaskFactory="CodeTaskFactory"
    AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"&gt;
    &lt;ParameterGroup&gt;
      &lt;Files ParameterType="Microsoft.Build.Framework.ITaskItem[]"/&gt;
    &lt;/ParameterGroup&gt;
    &lt;Task&gt;
      &lt;Code Type="Fragment" Language="javascript"&gt;
        &lt;![CDATA[
          function printMessageFor(item : Microsoft.Build.Framework.ITaskItem) {
            Log.LogMessage(item.ItemSpec + "fullpath: " + item.GetMetadata("FullPath"));
          }
          
          for(var i = 0; i&lt;Files.length; i++) {
            printMessageFor(Files[0]);
          }
          
        ]]&gt;
      &lt;/Code&gt;
    &lt;/Task&gt;
  &lt;/UsingTask&gt;

  &lt;ItemGroup&gt;
    &lt;Source Include="one.cs"/&gt;
    &lt;Source Include="two.cs"/&gt;
    &lt;Source Include="three.cs"/&gt;
    &lt;Source Include="four.cs"/&gt;
  &lt;/ItemGroup&gt;
  
  &lt;Target Name="PrintValues"&gt;
    &lt;Jsex01 Files="@(Source)" /&gt;
  &lt;/Target&gt;

&lt;/Project&gt;</pre>
        <p>
Here you can see that I created a new inline task called, Jsex01 and its written in
Javascript. Then inside of the PrintValues target this task is called. If you execute
the PrintValues target the result will be what you see below.
</p>
        <p>
          <a href="http://sedodream.com/content/binary/WindowsLiveWriter/MSBuild4InlineTasksPart3_128AF/image_4.png">
            <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/MSBuild4InlineTasksPart3_128AF/image_thumb_1.png" width="792" height="252" />
          </a>
        </p>
        <p>
So if you prefer JavaScript to C# or VB.Net then you should try this out!
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
        <img width="0" height="0" src="http://sedodream.com/aggbug.ashx?id=69f95d98-09e1-4f33-bd6c-5e131a591296" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio Ideas</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/07/23/VisualStudioIdeas.aspx" />
    <id>http://sedodream.com/PermaLink,guid,b5f5aad1-e3b0-4a57-a923-e6c8997ff2e1.aspx</id>
    <published>2010-07-23T00:24:45.569-07:00</published>
    <updated>2010-07-23T00:24:45.569-07:00</updated>
    <category term="feature-request" label="feature-request" scheme="http://sedodream.com/CategoryView,category,featurerequest.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://sedodream.com/CategoryView,category,VisualStudio.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Joining Microsoft</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/06/10/JoiningMicrosoft.aspx" />
    <id>http://sedodream.com/PermaLink,guid,d1844a46-3319-401a-81f6-b4be5b3bc5c0.aspx</id>
    <published>2010-06-09T20:50:30.729-07:00</published>
    <updated>2010-06-09T20:50:52.507-07:00</updated>
    <category term="Employment" label="Employment" scheme="http://sedodream.com/CategoryView,category,Employment.aspx" />
    <category term="Microsoft" label="Microsoft" scheme="http://sedodream.com/CategoryView,category,Microsoft.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio file encoding issues: ∩╗┐</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/06/10/VisualStudioFileEncodingIssues.aspx" />
    <id>http://sedodream.com/PermaLink,guid,68b7ea19-35ad-4249-8106-b5c7e9299c3f.aspx</id>
    <published>2010-06-09T20:24:01.915-07:00</published>
    <updated>2010-06-09T20:26:20.598-07:00</updated>
    <category term="batch-file" label="batch-file" scheme="http://sedodream.com/CategoryView,category,batchfile.aspx" />
    <category term="bug" label="bug" scheme="http://sedodream.com/CategoryView,category,bug.aspx" />
    <category term="cmd-file" label="cmd-file" scheme="http://sedodream.com/CategoryView,category,cmdfile.aspx" />
    <category term="connect" label="connect" scheme="http://sedodream.com/CategoryView,category,connect.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://sedodream.com/CategoryView,category,VisualStudio.aspx" />
    <category term="Visual Studio 2010" label="Visual Studio 2010" scheme="http://sedodream.com/CategoryView,category,VisualStudio2010.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="html">&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;</content>
  </entry>
  <entry>
    <title>Installing web apps made easy: Web Platform Installer</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/06/07/InstallingWebAppsMadeEasyWebPlatformInstaller.aspx" />
    <id>http://sedodream.com/PermaLink,guid,610e67fd-a3e6-41cd-bab4-1e462ae76e8b.aspx</id>
    <published>2010-06-06T20:17:01.318637-07:00</published>
    <updated>2010-06-06T20:17:01.318637-07:00</updated>
    <category term="Deployment" label="Deployment" scheme="http://sedodream.com/CategoryView,category,Deployment.aspx" />
    <category term="IIS" label="IIS" scheme="http://sedodream.com/CategoryView,category,IIS.aspx" />
    <category term="MSDeploy" label="MSDeploy" scheme="http://sedodream.com/CategoryView,category,MSDeploy.aspx" />
    <category term="web" label="web" scheme="http://sedodream.com/CategoryView,category,web.aspx" />
    <category term="Web Platform Installer" label="Web Platform Installer" scheme="http://sedodream.com/CategoryView,category,WebPlatformInstaller.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio: Unable to Edit and Continue?</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/05/08/VisualStudioUnableToEditAndContinue.aspx" />
    <id>http://sedodream.com/PermaLink,guid,45c89a49-fd37-463a-9d96-c795d7d68d96.aspx</id>
    <published>2010-05-08T16:19:38.141-07:00</published>
    <updated>2010-05-08T16:19:38.141-07:00</updated>
    <category term="Edit and Continue" label="Edit and Continue" scheme="http://sedodream.com/CategoryView,category,EditAndContinue.aspx" />
    <category term="IntelliTrace" label="IntelliTrace" scheme="http://sedodream.com/CategoryView,category,IntelliTrace.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://sedodream.com/CategoryView,category,VisualStudio.aspx" />
    <category term="Visual Studio 2010" label="Visual Studio 2010" scheme="http://sedodream.com/CategoryView,category,VisualStudio2010.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio projects not building anymore?</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/05/08/VisualStudioProjectsNotBuildingAnymore.aspx" />
    <id>http://sedodream.com/PermaLink,guid,9bd5e258-32d5-4e39-9f1e-24949efac3e3.aspx</id>
    <published>2010-05-07T22:33:26.873-07:00</published>
    <updated>2010-05-07T22:36:06.886-07:00</updated>
    <category term="Visual Studio" label="Visual Studio" scheme="http://sedodream.com/CategoryView,category,VisualStudio.aspx" />
    <category term="Visual Studio 2010" label="Visual Studio 2010" scheme="http://sedodream.com/CategoryView,category,VisualStudio2010.aspx" />
    <category term="WPF" label="WPF" scheme="http://sedodream.com/CategoryView,category,WPF.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Web Deployment Tool (MSDeploy) : Build Package including extra files or excluding specific files</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx" />
    <id>http://sedodream.com/PermaLink,guid,803d77d7-a220-4cee-a803-f6291cd4ba71.aspx</id>
    <published>2010-04-30T20:09:16.612-07:00</published>
    <updated>2010-04-30T20:09:16.612-07:00</updated>
    <category term="MSBuild" label="MSBuild" scheme="http://sedodream.com/CategoryView,category,MSBuild.aspx" />
    <category term="MSBuild 4.0" label="MSBuild 4.0" scheme="http://sedodream.com/CategoryView,category,MSBuild40.aspx" />
    <category term="MSDeploy" label="MSDeploy" scheme="http://sedodream.com/CategoryView,category,MSDeploy.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://sedodream.com/CategoryView,category,VisualStudio.aspx" />
    <category term="Visual Studio 2010" label="Visual Studio 2010" scheme="http://sedodream.com/CategoryView,category,VisualStudio2010.aspx" />
    <category term="Web Deployment Tool" label="Web Deployment Tool" scheme="http://sedodream.com/CategoryView,category,WebDeploymentTool.aspx" />
    <category term="Web Publishing Pipeline" label="Web Publishing Pipeline" scheme="http://sedodream.com/CategoryView,category,WebPublishingPipeline.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>MSBuild 4.0: New command line switches</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/04/30/MSBuild40NewCommandLineSwitches.aspx" />
    <id>http://sedodream.com/PermaLink,guid,6cced95a-0f4a-4740-9dba-03782008d8d3.aspx</id>
    <published>2010-04-29T17:38:03.007-07:00</published>
    <updated>2010-04-29T17:38:03.007-07:00</updated>
    <category term="MSBuild" label="MSBuild" scheme="http://sedodream.com/CategoryView,category,MSBuild.aspx" />
    <category term="MSBuild 4.0" label="MSBuild 4.0" scheme="http://sedodream.com/CategoryView,category,MSBuild40.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" /></div>
    </content>
  </entry>
  <entry>
    <title>Config transformations outside of web app builds</title>
    <link rel="alternate" type="text/html" href="http://sedodream.com/2010/04/26/ConfigTransformationsOutsideOfWebAppBuilds.aspx" />
    <id>http://sedodream.com/PermaLink,guid,ff6dfe05-99e8-421b-aedd-d57babdeed66.aspx</id>
    <published>2010-04-25T21:22:06.695-07:00</published>
    <updated>2010-04-25T21:23:50.631-07:00</updated>
    <category term="Config-Transformation" label="Config-Transformation" scheme="http://sedodream.com/CategoryView,category,ConfigTransformation.aspx" />
    <category term="MSBuild" label="MSBuild" scheme="http://sedodream.com/CategoryView,category,MSBuild.aspx" />
    <category term="MSBuild 4.0" label="MSBuild 4.0" scheme="http://sedodream.com/CategoryView,category,MSBuild40.aspx" />
    <category term="MSDeploy" label="MSDeploy" scheme="http://sedodream.com/CategoryView,category,MSDeploy.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://sedodream.com/CategoryView,category,VisualStudio.aspx" />
    <category term="Visual Studio 2010" label="Visual Studio 2010" scheme="http://sedodream.com/CategoryView,category,VisualStudio2010.aspx" />
    <author>
      <name>Ibrahim</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
</feed>