<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>MSBuild Team Blog</title><link>http://blogs.msdn.com/b/msbuild/</link><description>&amp;quot;Coding ... the boring bit between builds&amp;quot;</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Second edition of the MSBuild and Team Foundation Build book released</title><link>http://blogs.msdn.com/b/msbuild/archive/2011/01/05/second-edition-of-the-msbuild-and-team-foundation-build-book-released.aspx</link><pubDate>Wed, 05 Jan 2011 09:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10112881</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10112881</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2011/01/05/second-edition-of-the-msbuild-and-team-foundation-build-book-released.aspx#comments</comments><description>&lt;p&gt;&lt;span&gt;
&lt;p&gt;Not many books that are reviewed like this on Amazon:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5545.clip_5F00_image001_5F00_6FE4C8D4.png"&gt;&lt;img height="36" width="173" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8765.clip_5F00_image001_5F00_thumb_5F00_44900C00.png" alt="clip_image001" border="0" title="clip_image001" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now the heavily augmented second edition has just come out, written by several people at Microsoft and reviewed by the product team.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;New extensive coverage of building C++ with MSBuild&lt;/li&gt;
&lt;li&gt;Complete rewrite of the Team Build sections to cover the new Windows Workflow Foundation build orchestration&lt;/li&gt;
&lt;li&gt;Detail on new MSBuild 4.0 features like inline tasks, and item and property functions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7282.image_5F00_22C4336F.png"&gt;&lt;img height="244" width="200" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5148.image_5F00_thumb_5F00_4538C22A.png" alt="image" border="0" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you need a reference to Team Build or MSBuild, you should get it.&lt;/p&gt;
&lt;p&gt;-- Dan,&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;VS Solution/Project/Build dev lead&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&amp;nbsp;&lt;/strong&gt;Here's a&amp;nbsp;&lt;a target="_blank" href="http://www.amazon.com/Inside-Microsoft-Build-Engine-Foundation/dp/0735645248/ref=sr_1_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1294270965&amp;amp;sr=8-2"&gt;link to the book on Amazon&lt;/a&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10112881" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Dan+Moseley/">Dan Moseley</category></item><item><title>Incorrect solution build ordering when using MSBuild.exe</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe.aspx</link><pubDate>Tue, 21 Dec 2010 09:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10112880</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10112880</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe.aspx#comments</comments><description>&lt;p&gt;&lt;span&gt;
&lt;p&gt;We've had a few reports of cases where Visual Studio, and previous versions of MSBuild, will build the projects in the solution in the correct order, but the 4.0 version of MSBuild.exe gets the order wrong.&lt;/p&gt;
&lt;p&gt;Here's a full description of what's going on, why it began in 4.0, and the fix we recommend to your projects to solve the problem. If you're not interested in the "why", skip ahead to the workaround.&lt;/p&gt;
&lt;h4&gt;Archetypical case exhibiting the problem&lt;/h4&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5873.dep1b_5F00_49F1FB10.png"&gt;&lt;img height="388" width="266" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4300.dep1b_5F00_thumb_5F00_6DBA86D0.png" align="left" alt="dep1b" border="0" title="dep1b" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This diagram shows a solution file containing three projects, A, B, and C. Let's say they are C# projects.&lt;/p&gt;
&lt;p&gt;A has a regular project reference to B, so it will invoke B, then when B comes back done, it will build itself. At the same time in the solution file, there is a manually specified dependency: B depends on C.&lt;/p&gt;
&lt;p&gt;I've shown regular project references with solid lines, and the information in the solution with dotted lines.&lt;/p&gt;
&lt;p&gt;This manually specified dependency was set up in the solution by right clicking on the solution and choosing Project Dependencies&amp;hellip;, then checking a box. Below I've shown the context menu and what you see in the dialog when you have this setup.&lt;/p&gt;
&lt;p&gt;The build ordering you expect here is C, then B, then A, and Visual Studio shows that correctly in the Build Order tab, as you see below.&lt;/p&gt;
&lt;p&gt;Of course a real case would have more projects in it, but it would boil down to this case.&lt;/p&gt;
&lt;h4&gt;&amp;nbsp;&lt;/h4&gt;
&lt;h4&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5873.image_5F00_0C24C7BA.png"&gt;&lt;img height="390" width="380" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3716.image_5F00_thumb_5F00_42B272FE.png" alt="image" border="0" title="image" /&gt;&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8585.image_5F00_0B1CB210.png"&gt;&lt;img height="354" width="381" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1256.image_5F00_thumb_5F00_6950D97E.png" alt="image" border="0" title="image" /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5873.image_5F00_7499EDBB.png"&gt;&lt;img height="352" width="379" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2727.image_5F00_thumb_5F00_3246D578.png" alt="image" border="0" title="image" /&gt;&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;Why does this happen (skip ahead if you just want the "fix")&lt;/h4&gt;
&lt;p&gt;Essentially the problem is that MSBuild doesn't know anything about the project files until it starts to build them.&lt;/p&gt;
&lt;p&gt;Solution files, as you know, are not in MSBuild format (yet). On the command line, MSBuild.exe is on its own, so it parses them and generates one or more in-memory MSBuild format files that are essentially a translation. If you want to see these ugly files, set an environment variable MSBUILDEMITSOLUTION=1 then build the solution. You'll see a&amp;nbsp;&lt;strong&gt;.sln.metaproj&lt;/strong&gt;&amp;nbsp;file emitted next to your solution file, and possibly one or more files with an extension like&amp;nbsp;&lt;strong&gt;.csproj.metaproj&lt;/strong&gt;&amp;nbsp;next to some of your projects.&lt;/p&gt;
&lt;p&gt;The .metaproj generated for B.csproj is how MSBuild makes sure that the solution dependency is respected -- at least, it's created so that the solution itself does not invoke B until C is built. It does this by invoking the B metaproj instead of B directly, and in the B metaproj, it builds C before B. This is exactly equivalent to someone going into B and adding a project reference to C, instead of a solution dependency, but it means that we don't have to edit the B project directly.&lt;/p&gt;
&lt;p&gt;Here's what it looks like after this translation:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5270.dep2_5F00_2976CD2C.png"&gt;&lt;img height="427" width="399" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7026.dep2_5F00_thumb_5F00_67FC1AD2.png" align="left" alt="dep2" border="0" title="dep2" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Why doesn't that work in this case? In short, the problem is the project reference from A to B. Here's what happens: the solution invokes A.csproj, B.metaproj, and C.csproj concurrently (or at least, in undefined order), which would normally be fine. B.metaproj invokes C.csproj, and waits, then invokes B.csproj. However in the meantime, A.csproj was invoked, and because it has a project reference to B.csproj, it invokes B.csproj -- it "goes around the back". C.csproj hasn't necessarily built yet, so the build breaks.&lt;/p&gt;
&lt;h4&gt;Why did this work in previous versions of MSBuild?&lt;/h4&gt;
&lt;p&gt;In previous versions, we loaded and scanned every project file listed in the solution, and any they referenced, in order to draw a complete graph. Then we used the graph to create the MSBuild format equivalent of the solution file. The reason we did all this scanning was not actually to address this problem, it was to make interop with old-style non-MSBuild VC projects (".vcproj") work correctly. It was also slow, especially for large solutions.&lt;/p&gt;
&lt;p&gt;In VS2010, VC projects converted to MSBuild, so in 4.0 we took out this complex interop code. After making .metaproj's to express any dependencies stored in the solution file, we could now simply invoke all the projects in the solution and the build would order itself. That was potentially much faster, because we didn't need to load any projects (potentially hundreds) to scan them before building anything. (Of course, when MSBuild 4.0 is fed a VS2005 or VS2008 solution file, it still calls into the old code in the old assembly to do it the old way, since they may contain .vcproj's. So those guys don't have this problem.) The oversight was this case -- where a project reference "goes behind the back" of a solution-expressed dependency.&lt;/p&gt;
&lt;p&gt;To fix this we would have to revert to loading and scanning, which slows things down -- the correct approach is to use project references instead of solution dependencies, as I explain below.&lt;/p&gt;
&lt;h4&gt;How to fix this&lt;/h4&gt;
&lt;p&gt;Follow this principle: do not use dependencies expressed in the solution file at all! Better to express dependencies in the file that has the dependency: put a project reference in the project, instead. In our example, that would be a project reference from B to C.&lt;/p&gt;
&lt;p&gt;You may not have done that before because you didn't want to reference the target of the project reference, but merely order the build. However, in 4.0 you can create a project reference that only orders the build without adding a reference. It would look like this - note the metadata element, and all this is inside an &amp;lt;ItemGroup&amp;gt; tag of course:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&amp;lt;ProjectReference Include="... foo.csproj"&amp;gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ReferenceOutputAssembly&amp;gt;false&amp;lt;/ReferenceOutputAssembly&amp;gt;&amp;nbsp;&lt;br /&gt;&amp;lt;/ProjectReference&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note that you have to add the child element with a text editor -- Visual Studio can add a project reference, but doesn't expose UI for this metadata.&lt;/p&gt;
&lt;p&gt;I can tidy up by removing the dependency in the solution file as well - removing now-unnecessary lines like this -- your GUID will be different, but use the VS dialog and it will do the job.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProjectSection(ProjectDependencies) = postProject&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {B79CE0B0-565B-4BC5-8D28-8463A05F0EDC} = {B79CE0B0-565B-4BC5-8D28-8463A05F0EDC}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EndProjectSection&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you're using&amp;nbsp;&lt;strong&gt;C++ projects&lt;/strong&gt;, you are less likely to have this problem, because in the upgrade process that converts .vcproj's to .vcxproj's, it moves any solution dependencies relating to them to project references for you. However, if you do, there's a similar fix. For C++/CLI project references to other managed projects, use project references like the one above. For the equivalent situation with a project reference to a static lib, where you want a project reference without linking in the referenced lib, the metadata you want is&lt;/p&gt;
&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&amp;lt;ProjectReference Include="... lib.vcxproj"&amp;gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinkLibraryDependencies&amp;gt;false&amp;lt;/LinkLibraryDependencies&amp;gt;&amp;nbsp;&lt;br /&gt;&amp;lt;/ProjectReference&amp;gt;&lt;/span&gt;
&lt;h4&gt;Summary&lt;/h4&gt;
&lt;p&gt;Although it's tiresome to have to edit your projects in this way to make the bug go away, it's a best practice to use project references instead and consider the solution file merely a "view", and you'll end up with projects that if you want can be built without a solution file.&lt;/p&gt;
&lt;h4&gt;Post Script&lt;/h4&gt;
&lt;p&gt;I know of one other, more obscure and completely different case, where MSBuild 4.0 does not order correctly but Visual Studio does. This can happen if you have web application projects, AND you build with 64 bit MSBuild (which is the default, in Team Build 2010). I won't go into the tedious details but the fix is to do one of these things: (1) set a property or environment variable named MSBuildExtensionsPath to C:\program files (x86)\msbuild or (2) Build with 32 bit MSBuild, which I recommend in general for other reasons or (3) copy the web application targets files under the 64 bit program files MSBuild folder to the equivalent location in the 32 bit program files MSBuild folder.&lt;/p&gt;
&lt;p&gt;If you find any other case where the solution is not ordering correctly yet this workaround does not work, that's interesting. Please make a minimal repro like the one in this bug, and send it to Dan at&lt;a href="mailto:msbuild@microsoft.com"&gt;msbuild@microsoft.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
&lt;h4&gt;&lt;span style="color: #800000;"&gt;Update (12/25)&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Luc C points out below that sometimes removing a project reference in favor of a new solution dependency reference is an alternative solution. That assumes you're only using the project reference for ordering , or you replace it with a file reference. Still, I do recommend project references in general, on the principle of "express the dependency in the place it applies" &amp;ndash; you can look at the project and see that the dependency is correct, and you can include the projects in more than one solution easily.&lt;/p&gt;
&lt;p&gt;Luc also points out the case of a managed project depending on a non-CLR native project (presumably for PInvoke). In my experiments, VS will let you add a project reference, albeit with an ugly bang, and it will do the ordering correctly, as will msbuild.exe.&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10112880" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Dan+Moseley/">Dan Moseley</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/bugs/">bugs</category></item><item><title>MSBuild Known Issues</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/07/15/msbuild-known-issues.aspx</link><pubDate>Thu, 15 Jul 2010 09:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10039043</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10039043</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/07/15/msbuild-known-issues.aspx#comments</comments><description>&lt;p&gt;Since the release of Visual Studio 2010 we have received a few reports of crashing behavior which can be traced back to issues with MSBuild.&amp;nbsp; We&amp;rsquo;ve analyzed all of these and there are several particular cases where a crash can occur.&amp;nbsp; We&amp;rsquo;ve also added a notification to Windows Error Reporting to help guide those who hit these errors.&amp;nbsp; You can determine you your error is one of these either by matching the problem description below, or looking in the Event Viewer as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the Event Viewer&lt;/li&gt;
&lt;li&gt;Search for Information events with ID = 1001 and Source = Windows Error Reporting.&amp;nbsp; Look for those with the time that approximately matches when you saw the crash.&lt;/li&gt;
&lt;li&gt;At the top of the details pane for the event is text that would look like the below.&amp;nbsp; If the bucket number is not 1055654512, then this post may not apply to you.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Fault bucket 1055654512, type 1&lt;/p&gt;
&lt;p&gt;Event Name: APPCRASH&lt;/p&gt;
&lt;p&gt;Response: xxxxxxx&lt;/p&gt;
&lt;p&gt;Cab Id: 0&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Crash when debugging using F5&lt;/h4&gt;
&lt;p&gt;Problem: This can occur if the build process is missing a required target.&amp;nbsp; This is normally due to an improperly customized build process.&amp;nbsp; If you are using the .NET MicroFramework 4, which is not supported in Visual Studio 2010, you may also see this issue.&lt;/p&gt;
&lt;p&gt;Solution: Provide the missing target.&amp;nbsp; Try building the project/solution on the command-line.&amp;nbsp; If MSBuild logs an error that a target is missing, that could be the problem.&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;Crash when registering COM component&lt;/h4&gt;
&lt;p&gt;Problem: COM registration requires the user have permission to certain registry keys, and lacking that permission the RegASM task crashes.&lt;/p&gt;
&lt;p&gt;Solution: Ensure the registry keys needed to perform the registration are accessible to the account doing the registration.&amp;nbsp; Look under HKCR\Record for the GUID matching the type (or types) associated with the COM components you are registering.&lt;/p&gt;
&lt;h4&gt;Invalid Project Exception when building with .NET MicroFramework 4&lt;/h4&gt;
&lt;p&gt;Problem: When building projects with Visual Studio 2010 and the .NET MicroFramework 4, the build would fail with an InvalidProjectFileException.&amp;nbsp; The .NET MicroFramework 4 is not compatible with Visual Studio 2010.&lt;/p&gt;
&lt;p&gt;Workaround: There is unfortunately no workaround for this.&amp;nbsp; According to the .NET MicroFramework 4 team, the next version of the MicroFramework will support VS2010.&amp;nbsp; Check out &lt;a href="http://www.microsoft.com/netmf/default.mspx" title="http://www.microsoft.com/netmf/default.mspx"&gt;http://www.microsoft.com/netmf/default.mspx&lt;/a&gt; for updated information.&lt;/p&gt;
&lt;h4&gt;MSBuild throws an error that it cannot find msbuild.exe&lt;/h4&gt;
&lt;p&gt;Problem: Building on the command-line or from Visual Studio displays an error that MSBuild could not find MSBuild.exe during a C++ or multiproc build.&amp;nbsp; If your username is exactly 20 character long excluding your domain (the maximum allowed under Windows), there is a bug in the .NET Framework which will prevent us from authenticating the other MSBuild nodes.&lt;/p&gt;
&lt;p&gt;Workaround: Build under an account with a name that is less than 20 characters.&amp;nbsp; The bug should be fixed in the next version of the .NET Framework.&lt;/p&gt;
&lt;h4&gt;MSBuild throws an OutOfMemory exception&lt;/h4&gt;
&lt;p&gt;Problem: Your build in Visual Studio aborts with an OutOfMemory exception.&amp;nbsp; It may or may not also do this when built from the command-line.&amp;nbsp; This occurs typically when there are a very large number of projects with a lot of interdependencies, or when projects have an extremely large number of source files.&lt;/p&gt;
&lt;p&gt;Workaround: Build your solution on the command-line, so that your process does not have Visual Studio&amp;rsquo;s initial memory foot print; or build on a 64-bit machine under a 64-bit command window so we can take advantage of the additional virtual memory spacel or split your solution into smaller chunks which can be built individually; or create a solution configuration in which only a subset of your projects build.&lt;/p&gt;
&lt;h4&gt;Visual Studio crashes when building a solution containing C++ and WiX projects&lt;/h4&gt;
&lt;p&gt;Problem: When building a solution which contains C++ and WiX projects, Visual Studio may crash. &lt;/p&gt;
&lt;p&gt;Solution: This problem has been traced to a bug in the WiX project system.&amp;nbsp; Please contact the WiX project for a newer version with the correct bits.&lt;/p&gt;
&lt;h4&gt;Other issues&lt;/h4&gt;
&lt;p&gt;For some crashing issues we have set up Windows Error Reporting so that it will automatically request for you to send us additional information and contact us directly.&amp;nbsp; If you see such a request, please consider providing us with the requested additional information so we can either determine that your issue is already known or address it in the next version of the product. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10039043" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Known+Issues/">Known Issues</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/msbuild/">msbuild</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Debugging/">Debugging</category></item><item><title>Debugging MSBuild script with Visual Studio (3)</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/07/09/debugging-msbuild-script-with-visual-studio-3.aspx</link><pubDate>Fri, 09 Jul 2010 08:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10037028</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10037028</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/07/09/debugging-msbuild-script-with-visual-studio-3.aspx#comments</comments><description>&lt;p&gt;In my last two posts (&lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx"&gt;&lt;span style="color: #0066dd;"&gt;here&lt;/span&gt;&lt;/a&gt; and &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/07/09/debugging-msbuild-script-with-visual-studio-2.aspx"&gt;&lt;span style="color: #0066dd;"&gt;here&lt;/span&gt;&lt;/a&gt;) I showed how to enable the unsupported MSBuild debugger to debug a build started on the command line with MSBuild.exe. In this final post, I'll mention some other variations.&lt;/p&gt;
&lt;p&gt;Note that this blog is rather narrow, so some of the screenshots may be hard to see &amp;ndash; you can click on them to see the full size version. &lt;/p&gt;
&lt;h3&gt;Scenario 3: Debug a Solution file on the command line&lt;/h3&gt;
&lt;p&gt;In the previous example, I launched msbuild.exe against a project file. You well might want to start with a solution file instead. If you do, you may get an error that looks like this:&lt;/p&gt;
&lt;p&gt;Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Mismatched leave was C:\Users\danmose\Do &lt;br /&gt;cuments\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1.sln.metaproj expected C:\Users\dan &lt;br /&gt;mose\Documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1.csproj (2,1)&lt;/p&gt;
&lt;p&gt;The workaround is as follows. First, set an environment variable MSBUILDEMITSOLUTION=1. Then do a build of the solution in the regular way: if you want, you can cancel it after it starts building projects. Next to the solution file, you should see a file with the extension ".sln.metaproj". This is essentially the solution file translated into MSBuild-format. Now do the usual debugging procedure, but this time launch msbuild.exe against this sln.metaproj file instead of the original solution file.&lt;/p&gt;
&lt;h3&gt;Scenario 4: Multiprocessor build&lt;/h3&gt;
&lt;p&gt;When you're debugging your build process or tasks, it's much easier to follow if only one project is building at a time, and you'll probably do it that way whenever you can. What's more, debugging slows down the build so much that it may not help you diagnose a timing problem anyway.&lt;/p&gt;
&lt;p&gt;If however for some reason you do need to debug a multiprocessor build, it's possible.&lt;/p&gt;
&lt;p&gt;As you probably know, MSBuild launches child processes to build more than one project at once, and they persist for a while to be ready for another build. The /debug switch doesn't propagate to them. To get this to work, first terminate any msbuild.exe processes that are still alive. Then in a command window set an environment variable MSBUILDDEBUGGING=1. That environment variable is equivalent to the /debug switch, but unlike the switch it will get propagated to any child processes.&lt;/p&gt;
&lt;p&gt;From this command window now start msbuild.exe with the /debug switch as usual. Everything will work much the same as before, but you'll get a new JIT prompt as each child process starts to do its work, and you'll have to use a new instance of Visual Studio for each one of them.&lt;/p&gt;
&lt;p&gt;For example, I'm building a solution here, using the .metaproj workaround I mentioned above. Attaching at the first JIT prompt, I can see I am starting in the .metaproj itself:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1731.image_5F00_39023CCA.png"&gt;&lt;img height="211" width="831" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5531.image_5F00_thumb_5F00_654EE97B.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;If I hit Continue (F5) I'll get to the top of the next project, and stop there as usual. In the callstack window, I can see that the solution has invoked that project, and I can double click on the lower frame in the callstack to see where it did that &amp;ndash; it's an MSBuild task, of course:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4786.image_5F00_6CDA58E8.png"&gt;&lt;img height="247" width="743" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0245.image_5F00_thumb_5F00_4D2B7F20.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;While I'm stopped here, I get a JIT prompt again. This time it's for the other project in my solution, which has already started to load in parallel in another msbuild.exe process. I'll go through the JIT prompts as I did before, and select to start a new instance of Visual Studio. That will in turn break in at the top of that other project.&lt;/p&gt;
&lt;p&gt;Here's what I see now:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5531.image_5F00_54B6EE8D.png"&gt;&lt;img height="565" width="664" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1731.image_5F00_thumb_5F00_0E39FE85.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Visual Studio supports debugging more than one process at the same time, which would be more convenient, but I don't think the JIT launcher will let you do that. If you have a lot of child processes, it could get rather cumbersome. Remember that the "/m" switch defaults to the same number of processes as you have CPU's, so you may want to cut it down with "/m:2".&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Scenario 5: Debugging projects while they are loaded in Visual Studio&lt;/h3&gt;
&lt;p&gt;When I wrote the prototype, it was also possible to debug the evaluation and building of projects loaded in Visual Studio.&lt;/p&gt;
&lt;p&gt;Unfortunately in walking through this scenario to write this blog post, I was sorry to find that it's somewhat broken in the release version of Visual Studio 2010. In my experiments debugging works through the first evaluation, as the projects are loaded, but then it hits a bug and terminates. Since it's an untested feature there's always the chance something can break without detection and that's apparently what happened here. &lt;/p&gt;
&lt;p&gt;Given that, you'll most likely have to stick with msbuild.exe. However, I'll go ahead and explain a little about how one would do this in Visual Studio, in case you have better luck than I do.&lt;/p&gt;
&lt;p&gt;Start off by setting the registry key as described at the start of my &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx"&gt;&lt;span style="color: #0066dd;"&gt;first post&lt;/span&gt;&lt;/a&gt; and kill any lingering instances of MSBuild.exe as you did in the last scenario.&lt;/p&gt;
&lt;p&gt;Make sure the environment variable MSBUILDDEBUGGING is &lt;em&gt;not &lt;/em&gt;set and open your first Visual Studio to act as your debugger. You can do this from the start menu. As before make sure Just-My-Code is switched on in this instance.&lt;/p&gt;
&lt;p&gt;Open a command prompt and set the environment variable MSBUILDDEBUGGING=1 again. Then launch Visual Studio from that command prompt -- most likely you'd start it with a command like "%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe". This second instance is your debuggee, which you will load your projects into.&lt;/p&gt;
&lt;p&gt;Go back to the debugger process, and attach to that debuggee, choosing the "Managed (v4.0)" engine as always. In this debugger process, open up the project or targets file you want to start debugging through. Make sure you open it with "Open File" into the XML editor, rather than loading it as an actual project. &lt;/p&gt;
&lt;p&gt;Debugging may not start automatically on the first line this time, so set a breakpoint where you want to begin. I opened the "WindowsFormsApplication1.csproj" file I used before into the XML editor, and set a breakpoint on the first line to get hit when the project is first loaded.&lt;/p&gt;
&lt;p&gt;Open up your project or projects in the normal way in the debuggee now and you should see your breakpoint is hit. Step a little further, and for me, Visual Studio terminates.&lt;/p&gt;
&lt;h3&gt;End of the Walkthrough&lt;/h3&gt;
&lt;p&gt;Now I've shown you all the features of the MSBuild debugger, I hope you'll try it out. &lt;/p&gt;
&lt;p&gt;If you have feedback, do post it here. In particular, how important is it to be able to debug projects loaded inside Visual Studio? Also, as you've seen, MSBuild must be in "debugging mode" from launch -- it's not possible to walk up to a regular build that's in progress and attach to it. Is it important to be able to do that? &lt;/p&gt;
&lt;p&gt;Most of all, how useful is this to you, and how problematic are the bugs and limitations you run into?&lt;/p&gt;
&lt;p&gt;Thanks for reading&lt;/p&gt;
&lt;p&gt;Dan &lt;/p&gt;
&lt;p&gt;Visual Studio Project &amp;amp; Build Dev Lead&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10037028" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Dan+Moseley/">Dan Moseley</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/msbuild/">msbuild</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Debugging/">Debugging</category></item><item><title>Debugging MSBuild script with Visual Studio (2)</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/07/09/debugging-msbuild-script-with-visual-studio-2.aspx</link><pubDate>Fri, 09 Jul 2010 08:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10037026</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10037026</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/07/09/debugging-msbuild-script-with-visual-studio-2.aspx#comments</comments><description>&lt;p&gt;In my &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx"&gt;&lt;span style="color: #0066dd;"&gt;previous post&lt;/span&gt;&lt;/a&gt;, I showed how to enable the hidden Visual Studio debugger for MSBuild script, and demonstrated it by stepping through the evaluation of a C# project. In this post, I'll keep debugging into the actual build of that project.&lt;/p&gt;
&lt;p&gt;Note that this blog is rather narrow, so some of the screenshots may be hard to see &amp;ndash; you can click on them to see the full size version.&lt;/p&gt;
&lt;p&gt;Starting from where we left off last post, I'll set a breakpoint in Microsoft.CSharp.targets on the &amp;lt;Csc&amp;gt; task tag. That's where the compiler will run. Then hit F5 to run to it.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2287.image_5F00_61F36390.png"&gt;&lt;img height="371" width="681" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3386.image_5F00_thumb_5F00_26CFAD92.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Ideally, I'd be able to set a breakpoint on the enclosing &amp;lt;Target&amp;gt; tag, but unfortunately there's a bug: you can't. As a workaround you could inspect the values of a target's attributes when you get to the first tag in the body of that target. If the target's condition is false, or if its inputs and outputs are up to date so that it skips, it's not so simple. You'd have to work around this by stepping up to the target before. &lt;/p&gt;
&lt;p&gt;I'd like to be able to evaluate the condition on the task there, but because it's &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms171473.aspx"&gt;&lt;span style="color: #0066dd;"&gt;batchable&lt;/span&gt;&lt;/a&gt; it could have multiple results: the EvaluateCondition delegate I used before won't accept it. If this was a parameter on the task, I'd probably step into the task's code itself to see the value. Since it's a condition, I'd probably look through the metadata on the item list directly, or query the object model in some way.&lt;/p&gt;
&lt;p&gt;Something like the value of Sources is easy to evaluate here, though:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4265.image_5F00_2088D704.png"&gt;&lt;img height="147" width="691" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2605.image_5F00_thumb_5F00_00D9FD3C.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now I want to step into the task implementation.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You might think that at this point, you can simply Step In (F11). However, you can't &amp;ndash; it happens that MSBuild will run this task on a different thread. To know to jump threads properly here, the debugger has to support what they call "causality" for this kind of debugging, and since it doesn't know anything about MSBuild, it doesn't. &lt;/p&gt;
&lt;p&gt;It's easy to get the job done though &amp;ndash; set a breakpoint in the task and run until it's hit.&lt;/p&gt;
&lt;p&gt;I have the source code for the Csc task, so I set a breakpoint here on the setter of the WarningLevel property, and did Continue (F5). I can see the task is getting "4" as the value of that property here. I can debug this code just like any other C# code, stepping through methods and so forth. &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2703.image_5F00_5D20D5A1.png"&gt;&lt;img height="425" width="701" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6320.image_5F00_thumb_5F00_7688D8DB.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To get out to the XML, I'll set a breakpoint in it and run &amp;ndash; the same trick I used to get into the C#, but in reverse. Here I'm at the next tag after the task:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6835.image_5F00_7E807B3D.png"&gt;&lt;img height="486" width="700" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4278.image_5F00_thumb_5F00_7EECAE32.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I used Csc as an example here, but you'll generally be debugging a custom task (or possibly, logger). Just make sure the assembly is not optimized: since you have Just-My-Code on, it won't be debuggable otherwise. If you only have access to an optimized one, you can switch off Just-My-Code temporarily.&lt;/p&gt;
&lt;p&gt;There's a CallTarget tag here: you can step into those, and like imports they'll look like a new frame on the callstack &amp;ndash; although unlike imports, that's correct for their semantics.&lt;/p&gt;
&lt;p&gt;Probably the biggest limitation (bug) with the debugger right now is that you can't see item and property changes made inside a target. For example, at this point @(_CoreCompileResourceInputs) should be empty because of the line above, but the immediate window tells me it isn't:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7485.image_5F00_78A5D7A4.png"&gt;&lt;img height="246" width="721" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7002.image_5F00_thumb_5F00_71F2CE21.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;When you get past that target, you can see the changes.&lt;/p&gt;
&lt;h3&gt;Scenario 2: Debugging a build with multiple projects&lt;/h3&gt;
&lt;p&gt;Typically there's more than one project in a build. I've added a project reference from this project to another. I've put a breakpoint at the top of that project, and run to it:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5751.image_5F00_4471AE5E.png"&gt;&lt;img height="386" width="802" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0574.image_5F00_thumb_5F00_72CB340B.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The bottom of the callstack is the point in Microsoft.Common.targets where, early in the build of WindowsFormsApplication1, it invoked WindowsFormsApplication2.&lt;/p&gt;
&lt;h5&gt;In my next posts I'm going to cover&lt;/h5&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Debugging a multiprocessor build&lt;/li&gt;
&lt;li&gt;Debugging the build of projects loaded into Visual Studio&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See you then! &lt;/p&gt;
&lt;p&gt;Dan &lt;/p&gt;
&lt;p&gt;Visual Studio Project &amp;amp; Build Dev Lead&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10037026" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Dan+Moseley/">Dan Moseley</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/msbuild/">msbuild</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Debugging/">Debugging</category></item><item><title>Debugging MSBuild script with Visual Studio</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx</link><pubDate>Tue, 06 Jul 2010 07:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10035792</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10035792</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx#comments</comments><description>&lt;p&gt;Back when we started 4.0 development, I polled readers of the MSBuild blog to find out what features were most important to them. &lt;a target="_blank" href="http://blogs.msdn.com/b/msbuild/archive/2007/11/30/response-to-the-feature-poll.aspx"&gt;&lt;span style="color: #0066dd;"&gt;Debugging was #1&lt;/span&gt;&lt;/a&gt; which was very surprising to us. Thinking about it more, it makes sense. In our team we've become so proficient ourselves at reading the XML and making sense of logs that it's easy to forget how difficult it is &amp;ndash; especially for someone new. John Robbins, debugging guru, &lt;a target="_blank" href="http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/11/12/msbuild-3-5-tips-and-a-small-msbuild-4-0-wish-list.aspx"&gt;&lt;span style="color: #0066dd;"&gt;also requested a Visual-Studio-integrated debugger&lt;/span&gt;&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Fast forward to the 4.0 release earlier this year, and we addressed 7 out of 16 of the requests by my count. We had to balance the requests with what Visual Studio itself needed from MSBuild. There were two major requirements it had on MSBuild: to enable &lt;a target="_blank" href="http://blogs.msdn.com/b/vcblog/archive/2008/11/20/printf-hello-msbuild-n.aspx"&gt;&lt;span style="color: #0066dd;"&gt;VC++ to move onto MSBuild&lt;/span&gt;&lt;/a&gt; (#5 request), and to help enable more powerful and fine grained &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/05/19/visual-studio-managed-multi-targeting-part-1-concepts-target-framework-moniker-target-framework.aspx"&gt;&lt;span style="color: #0066dd;"&gt;multi-targeting&lt;/span&gt;&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;It turned out that these two in turn required many other features, most of which were happily also popular requests on that blog poll. We added the ability to define a task with inline code (#7 &amp;ndash; see &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/02/20/msbuild-task-factories-guest-starring-windows-powershell.aspx"&gt;&lt;span style="color: #0066dd;"&gt;powershell example&lt;/span&gt;&lt;/a&gt;) a new, comprehensive object model (#14; in three parts, &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.build.construction.aspx"&gt;&lt;span style="color: #0066dd;"&gt;one&lt;/span&gt;&lt;/a&gt;, &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.build.evaluation.aspx"&gt;&lt;span style="color: #0066dd;"&gt;two&lt;/span&gt;&lt;/a&gt;, &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.build.execution.aspx"&gt;&lt;span style="color: #0066dd;"&gt;three&lt;/span&gt;&lt;/a&gt;), improved &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/06/01/better-parallelism-in-msbuild-with-yieldduringtaskexecution.aspx"&gt;&lt;span style="color: #0066dd;"&gt;performance&lt;/span&gt;&lt;/a&gt; and scalability in many cases (#8 -- and &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/03/08/tuning-c-build-parallelism-in-vs2010.aspx"&gt;&lt;span style="color: #0066dd;"&gt;here&lt;/span&gt;&lt;/a&gt;), &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/04/02/msbuild-property-functions.aspx"&gt;&lt;span style="color: #0066dd;"&gt;property&lt;/span&gt;&lt;/a&gt; and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ee886422.aspx"&gt;&lt;span style="color: #0066dd;"&gt;item functions&lt;/span&gt;&lt;/a&gt; (#9 &amp;ndash; albeit not currently extensible) , and accurate automatic dependency checking by performing file system interception (#11), plus some small syntax additions (label, &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ff606262.aspx"&gt;&lt;span style="color: #0066dd;"&gt;import group&lt;/span&gt;&lt;/a&gt;, import by wildcard) and a more configurable build engine (eg see &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.build.execution.buildmanager_members.aspx"&gt;&lt;span style="color: #0066dd;"&gt;here&lt;/span&gt;&lt;/a&gt;, &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.build.execution.buildparameters_members.aspx"&gt;&lt;span style="color: #0066dd;"&gt;here&lt;/span&gt;&lt;/a&gt;, and &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.build.execution.buildsubmission_members.aspx"&gt;&lt;span style="color: #0066dd;"&gt;here&lt;/span&gt;&lt;/a&gt;), plus &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/02/18/build-extensibility-with-net-framework-4.aspx"&gt;&lt;span style="color: #0066dd;"&gt;easier build extensibility&lt;/span&gt;&lt;/a&gt; and some &lt;a target="_blank" href="http://blogs.msdn.com/b/visualstudio/archive/2010/03/05/msbuild-4-detailed-build-summary.aspx"&gt;&lt;span style="color: #0066dd;"&gt;performance diagnostics&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We &lt;em&gt;didn't &lt;/em&gt;have time, unfortunately, to address converting the solution file to MSBuild (#3) &amp;ndash; which we would &lt;em&gt;dearly &lt;/em&gt;love to do &amp;ndash; nor to add a Visual Studio integrated debugger (#1).&lt;/p&gt;
&lt;p&gt;At least, not a supported one!&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/b/jmstall/"&gt;&lt;span style="color: #0066dd;"&gt;Mike Stall&lt;/span&gt;&lt;/a&gt; approached us to demonstrate an ingenious &lt;a target="_blank" href="http://blogs.msdn.com/b/jmstall/archive/2005/07/27/state-machine-theory.aspx"&gt;&lt;span style="color: #0066dd;"&gt;reflection-emit&lt;/span&gt;&lt;/a&gt; idea which made it considerably more feasible to create an MSBuild specific debugger with many of the features of the real managed code debugger. While on leave I wrote and checked-in the code to do it. Unfortunately we couldn't complete it in time to make the 4.0 schedule. &lt;/p&gt;
&lt;p&gt;For that reason, it's in the product, but disabled by default. It does work, it's just not supported or documented, and has a few limitations and bugs: it may be slow, it's not always pretty, and in at least one case, it's a little inaccurate. This blog post is "unofficial" documentation of how to use it in the hope it will be useful. Although it's not supported we will welcome Connect feedback, but it will likely will be moved to our backlog rather than fixed immediately. It would also be a great idea to add any bug reports and feedback to the comments on this blog post.&lt;/p&gt;
&lt;h2&gt;Debugging Walkthrough&lt;/h2&gt;
&lt;p&gt;I'm going to walk through each debugging scenario in turn. &lt;/p&gt;
&lt;p&gt;Before you start, open Visual Studio briefly and make sure that "Just My Code" is enabled. It's essential for this to work properly:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5504.image_5F00_2B12E3B3.png"&gt;&lt;img height="388" width="672" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0211.image_5F00_thumb_5F00_2B7F16A8.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;There's a lot of screenshots here, but this blog is rather narrow, so some of them are distorted &amp;ndash; you can click on them to see the full size version.&lt;/p&gt;
&lt;h4&gt;Scenario 1 &amp;ndash; Command Line only&lt;/h4&gt;
&lt;p&gt;First, enable the undocumented "/debug" switch on MSBuild.exe by setting the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\4.0 key to have debuggerenabled=true, as I've done here with reg.exe in an elevated Visual Studio prompt:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3060.image_5F00_2AD5204A.png"&gt;&lt;img height="91" width="863" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6014.image_5F00_thumb_5F00_61264859.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You should now have these keys, assuming C: is your system drive.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8625.image_5F00_5FEFC323.png"&gt;&lt;img height="152" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8713.image_5F00_thumb_5F00_78AF1033.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Run MSBuild /? and you'll see the new switch has appeared. &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4428.image_5F00_79F3A912.png"&gt;&lt;img height="117" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7635.image_5F00_thumb_5F00_73409F8F.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We are now ready to debug.&lt;/p&gt;
&lt;p&gt;Normally you'd be debugging some build process you've customized or authored, but for illustrative purposes I'm going to debug a brand new C# Windows Forms project. I'm going to build it with the /debug switch, and it will immediately stop:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0456.image_5F00_185E1DC8.png"&gt;&lt;img height="91" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3073.image_5F00_thumb_5F00_55AEF85C.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my case I get a prompt to elevate, and hit Yes:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2043.image_5F00_017F1880.png"&gt;&lt;img height="318" width="589" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1768.image_5F00_thumb_5F00_61D03EB7.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Then I get the standard JIT debugging prompt. Make sure you check "Manually choose the debugging engines".&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8637.image_5F00_344F1EF4.png"&gt;&lt;img height="444" width="409" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4011.image_5F00_thumb_5F00_4697E5B6.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;that causes a dialog to appear to choose the debugging engine: you want Managed only. (Mixed will work, is more clunky.)&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5504.image_5F00_0DED3BA9.png"&gt;&lt;img height="309" width="404" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0207.image_5F00_thumb_5F00_1C2BB499.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And you are now debugging!&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8637.image_5F00_7C7CDAD0.png"&gt;&lt;img height="382" width="684" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7658.image_5F00_thumb_5F00_15E4DE0B.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The first thing to notice is that we are right at the top of the first project file, the very first line MSBuild is evaluating. You are breaking in automatically at the very start, as if you started debugging a regular application with "F11".&amp;nbsp; Well, almost the very start: MSBuild already read in the environment and its other initial settings:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/5187.image_5F00_366C1DBD.png"&gt;&lt;img height="327" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4024.image_5F00_thumb_5F00_7DC173AF.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now hit F10 and you will step line by line:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1307.image_5F00_504053EC.png"&gt;&lt;img height="184" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2451.image_5F00_thumb_5F00_1795A9DF.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you step over properties, you'll see the locals window is updating:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8540.image_5F00_30FDAD19.png"&gt;&lt;img height="136" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0726.image_5F00_thumb_5F00_3F3C2609.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8244.image_5F00_5FC365BB.png"&gt;&lt;img height="62" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1803.image_5F00_thumb_5F00_06FDAEF1.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you probably know, MSBuild evaluates in &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/dd997067.aspx"&gt;&lt;span style="color: #0066dd;"&gt;passes&lt;/span&gt;&lt;/a&gt;. The first pass evaluates just properties, pulling in any imports as they're encountered. Try to set a breakpoint (F9) on an item tag right now &amp;ndash; you can't! MSBuild is unaware of them at this point. &lt;/p&gt;
&lt;p&gt;Set a breakpoint on the &amp;lt;Import&amp;gt; tag at the bottom and run to it (F5):&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1616.image_5F00_674ED528.png"&gt;&lt;img height="260" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2870.image_5F00_thumb_5F00_19B2A8A8.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now step in (F11). You'll enter the file that's being imported, which in this case is Microsoft.CSharp.targets.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4034.image_5F00_331AABE2.png"&gt;&lt;img height="253" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3750.image_5F00_thumb_5F00_4C82AF1C.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The Callstack window shows that jump like a function call, including the location in the file:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0638.image_5F00_61E06484.png"&gt;&lt;img height="96" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3858.image_5F00_thumb_5F00_14443804.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Of course, &amp;lt;Import&amp;gt; does not have the semantics of a function call at all. Like an #include in C++, it simply logically inserts the content of another file. But I chose to make it work this way so that you can see the chain of imports in the Callstack window and figure out your context.&lt;/p&gt;
&lt;p&gt;By setting some more breakpoints on Imports and doing step-into, I can go deeper to illustrate:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3056.image_5F00_5B998DF6.png"&gt;&lt;img height="135" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4540.image_5F00_thumb_5F00_0DFD6176.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To get past the property pass, given that I can't set a breakpoint on items yet, I'll use a trick. I'll Step Out repeatedly (Shift-F11) until we get to the project file again, then step to get to the next pass, which is &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/bb651788.aspx"&gt;&lt;span style="color: #0066dd;"&gt;Item Definitions&lt;/span&gt;&lt;/a&gt;. The C++ build process uses Item Definitions a great deal, but they're not very interesting for C#, in fact there's only one:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3343.image_5F00_1C3BDA66.png"&gt;&lt;img height="114" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7178.image_5F00_thumb_5F00_2A7A5356.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Use the same trick to get to the Item pass, and we'll get to the first item. I've then set a breakpoint to illustrate that I can do that now.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/4442.image_5F00_2EF0D41D.png"&gt;&lt;img height="247" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6082.image_5F00_thumb_5F00_24337CC8.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Conditional Breakpoints work too, by the way as I believe do Trace Points.&lt;/p&gt;
&lt;p&gt;Stepping a bit further, I can see items in the locals window, and also their metadata. A small bug here -- ignore the red message, and go into "Non-public members" to see the names and values:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/1200.image_5F00_5DB68CBF.png"&gt;&lt;img height="66" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0245.image_5F00_thumb_5F00_6BF505AF.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6518.image_5F00_505079B9.png"&gt;&lt;img height="188" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3377.image_5F00_thumb_5F00_17A5CFAC.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sometimes you'll want to figure what a condition evaluates to at the current moment. To do that, in the immediate window, pass the condition to the function EvaluateCondition:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2705.image_5F00_181202A1.png"&gt;&lt;img height="123" width="565" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6012.image_5F00_thumb_5F00_58481C1B.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;It's much the same if you want to evaluate (expand) an expression, but the function is named EvaluateExpression:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3872.image_5F00_51951298.png"&gt;&lt;img height="62" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/3465.image_5F00_thumb_5F00_0DC0DE41.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This is also a convenient way to see what a property value is, or what's in an item list, without navigating through the locals window. &lt;em&gt;Be sure to escape any slashes&lt;/em&gt;, as I've done here. &lt;/p&gt;
&lt;p&gt;The Autos window doesn't work, but Watch does:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/0654.image_5F00_070DD4BE.png"&gt;&lt;img height="112" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/7585.image_5F00_thumb_5F00_005ACB3B.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the Immediate window you can change almost any project state during the build, using the new object model. For example, I'll modify this property while I'm stopped here:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6012.image_5F00_60ABF172.png"&gt;&lt;img height="85" width="573" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/6505.image_5F00_thumb_5F00_72F4B834.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You can do a lot through the new object model, so it's very useful to be able to call it here.&lt;/p&gt;
&lt;p&gt;My Watch window updated to match:&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/2308.image_5F00_2F2083DD.png"&gt;&lt;img height="66" width="644" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92-metablogapi/8267.image_5F00_thumb_5F00_6F569D57.png" alt="image" border="0" title="image" style="display: inline; border: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;That's the end of what I'm going to show for debugging MSBuild evaluation.&lt;/p&gt;
&lt;h5&gt;How it works&lt;/h5&gt;
&lt;p&gt;What's happening at the high level (you can find out more from Mike's blog) is that MSBuild is pretending the script is actually VB or C#. It's doing this by emitting IL on the fly that's semantically equivalent to what it's really doing as it goes through the XML. The code of MSBuild itself is of course optimized, so Just My Code hides it, but conveniently the IL isn't optimized, so it shows up. Inside the IL MSBuild emits line directives that point to the right place in the project file, completing the trick. As for the "locals", they're actually parameters passed to functions in the IL so that they appear. EvaluateCondition and EvaluateExpression are just delegates passed the same way.&lt;/p&gt;
&lt;p&gt;As such, a large part of the basic features you get with the regular VB/C# debugger just work. Some that don't: hovering over an expression doesn't give you the result; you can't just use the "?" syntax in the immediate window; Threads and Processes windows don't make sense; I doubt Intellitrace works. Plus, there's some of our internals leaking out in the windows here and there. But by using this trick, it was vastly less work to get the basics of an integrated debugger. I believe I spent a day or two tidying up Mike's sample code, and another three days wiring it straightforwardly into MSBuild. Creating a real debugger engine would be much more costly; and something comparable with what you get for C# would be fantastically costly, so I expect that long term, this will be the MSBuild debugging story. I hope you'll agree it's a lot better than staring at XML and logs or adding &amp;lt;Message&amp;gt; tags. &lt;/p&gt;
&lt;h5&gt;In my next post I'm going to cover&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Debugging during the build &amp;ndash; ie., debugging what happens inside targets, and project references; &lt;/li&gt;
&lt;li&gt;Debugging a multiprocessor build; &lt;/li&gt;
&lt;li&gt;Debugging the build of projects loaded into Visual Studio &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See you then!&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
&lt;p&gt;Visual Studio Project &amp;amp; Build Dev Lead&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10035792" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Dan+Moseley/">Dan Moseley</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Debugging/">Debugging</category></item><item><title>Better Parallelism in MSBuild 4 with YieldDuringToolExecution</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/06/03/better-parallelism-in-msbuild-4-with-yieldduringtoolexecution.aspx</link><pubDate>Thu, 03 Jun 2010 07:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10019871</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10019871</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/06/03/better-parallelism-in-msbuild-4-with-yieldduringtoolexecution.aspx#comments</comments><description>&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;In MSBuild 4 we introduced several performance improvements, particular for large interdependent builds.&amp;nbsp; By and large they are automatic and you receive their benefit without making any changes to the way your build process in authored.&amp;nbsp; However, there are still some cases where we are unable to make the best decision.&amp;nbsp; One such case is when there is a particular external tool which is invoked as part of the build but which takes a significant amount of time.&amp;nbsp; An example of such a tool would be cl.exe, the C++ compiler.&amp;nbsp; This article discusses how to use the new yield mechanism for external tools to improve the performance of your builds.&lt;/p&gt;
&lt;h3&gt;Tool Tasks&lt;/h3&gt;
&lt;p&gt;There are a few ways MSBuild can be made to execute external, command-line tools:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write a task which derives from ToolTask. &lt;/li&gt;
&lt;li&gt;Use the Exec task to call your command. &lt;/li&gt;
&lt;li&gt;Use the XamlTaskFactory. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All of these methods ultimately use the ToolTask class in Microsoft.Build.Utilities.v4.0.dll to handle executing a command-line task and deal with the output in the MSBuild way.&amp;nbsp; Like all tasks, however, they block any other work from happening in MSBuild while they are executing.&amp;nbsp; In cases where the task is very short, such as touching a log file or copying a file from one place to another this is perfectly acceptable.&amp;nbsp; But in the original example of invoking the C++ compiler, the amount of time MSBuild itself sits idle can be lengthy and in some cases it may be a significant impediment to good parallelization of your build.&lt;/p&gt;
&lt;p&gt;The problem has to do with the way MSBuild utilizes its worker nodes.&amp;nbsp; Whenever a project is scheduled to be built, it is assigned to one of the worker nodes.&amp;nbsp; This node will then execute that project from start to finish, and will not accept more work until the project is either finished or the project makes an MSBuild call (for instance to satisfy a project-to-project reference.)&amp;nbsp; This is in large part because a node can only execute one task at a time, as tasks must be guaranteed their environment and current directory will not be modified during execution.&lt;/p&gt;
&lt;p&gt;However, command-line tools do not execute in-process, and therefore their environment cannot be polluted by the running of additional tasks in parallel on the same node.&amp;nbsp; We can take advantage of this behavior to let the MSBuild node execute tasks in other projects while our long-running tool completes its work.&amp;nbsp; This is done using the YieldDuringToolExecution parameter.&lt;/p&gt;
&lt;h3&gt;YieldDuringToolExecution&lt;/h3&gt;
&lt;p&gt;In order to allow MSBuild to continue building other projects while a command-line tool in one project is running is simple.&amp;nbsp; Just set the YieldDuringToolExecution parameter to &amp;lsquo;True&amp;rsquo; on your long running command-line tool.&amp;nbsp; This is a boolean parameter, so any valid MSBuild expression which resolves to a boolean value will work.&amp;nbsp; Here&amp;rsquo;s an example:&lt;/p&gt;
&lt;table bgcolor="#eeeeee" cellpadding="2" cellspacing="0" border="0" style="width: 564px;"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="562" valign="top"&gt;
&lt;pre&gt;&lt;span style="font-family: Consolas; font-size: x-small;"&gt;&amp;lt;PropertyGroup&amp;gt;
    &amp;lt;YieldDuringToolExecution&amp;gt;true&amp;lt;/YieldDuringToolExecution&amp;gt;&lt;br /&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: x-small;"&gt;
&amp;lt;Exec CommandLine=&amp;rdquo;Sleep 10000&amp;rdquo; YieldDuringToolExecution=&amp;rdquo;$(YieldDuringToolExecution)&amp;rdquo;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;When the Exec task executes, normally it would sleep for 10000 seconds during which no other work on the node can proceed.&amp;nbsp; However, with yielding enabled, the Sleep command will still run but the MSBuild node will be free to do other work.&amp;nbsp; Once the Sleep command is finished, the node will resume building the project which launched it as soon as the node is free to do so.&lt;/p&gt;
&lt;p&gt;Whether or not you should enable yielding for your ToolTasks depends on what they do.&amp;nbsp; Generally speaking if the task runs for less than one second, it&amp;rsquo;s probably not worth it to enable this since there is a small cost to give up the MSBuild node.&amp;nbsp; However, for longer tools you may see some wins, and the wins will likely be larger the more complex your build is and the more long running tasks you have in it.&amp;nbsp; Again, large interdependent C++ builds are a great example of this and they benefit tremendously from yielding being applied to the compiler.&amp;nbsp; You can investigate your build&amp;rsquo;s performance using the &lt;a href="http://blogs.msdn.com/b/visualstudio/archive/2010/03/05/msbuild-4-detailed-build-summary.aspx"&gt;&lt;span style="color: #0066dd;"&gt;Detailed Summary&lt;/span&gt;&lt;/a&gt; feature of MSBuild 4.&lt;/p&gt;
&lt;p&gt;Yielding interacts well with the /m switch in MSBuild as well.&amp;nbsp; For instance, if you have specified /m:4 to enable parallelization, MSBuild will ensure that no more than four parallel things are going on at once, whether they be regularly building projects or yielding tools.&amp;nbsp; So enabling yielding will not cause your machine to become more overloaded.&amp;nbsp; Instead your builds are likely to improve their parallelization and make better use of available CPU and I/O cycles that they would otherwise.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;We have already enabled yield semantic for several tool tasks.&amp;nbsp; These include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CL, the C++ compiler &lt;/li&gt;
&lt;li&gt;MIDL, the IDL compiler &lt;/li&gt;
&lt;li&gt;Link, the native linker &amp;ndash; Only when the LinkTimeCodeGeneration metadata is set to UseLinkTimeCodeGeneration &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It could also be enabled for the Vbc and Csc tasks since they are ToolTasks as well, but this support is not in the Microsoft.CSharp.targets and Microsoft.VisualBasic.targets shipped with .Net 4.0.&amp;nbsp; You could easily add them yourself if you wished.&amp;nbsp; More generally, if you include Microsoft.Common.targets the YieldDuringToolExecution property will be set to true unless it is overridden with the parameter /p:YieldDuringToolExecution=false being passed to MSBuild.&amp;nbsp; We will continue to use this property as the basis for selecting the tool parameter value of the same name.&lt;/p&gt;
&lt;h3&gt;Why isn&amp;rsquo;t it automatic?&lt;/h3&gt;
&lt;p&gt;Unfortunately for MSBuild 4 we didn&amp;rsquo;t get the opportunity to make this system as automatic as we would like.&amp;nbsp; In future versions we would like to automatically yield when ToolTasks are executing if they look like they will last longer than a certain threshold.&amp;nbsp; This will also work together with additional automatic improvements in build analysis and scheduling we have planned.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cliff Hudson&lt;/strong&gt; - MSBuild Developer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10019871" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/msbuild/">msbuild</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/cliff+hudson/">cliff hudson</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Performance/">Performance</category></item><item><title>Assembly Resolution in MSBuild and Visual Studio Series Introduction</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/05/11/assembly-resolution-in-msbuild-and-visual-studio-series-introduction.aspx</link><pubDate>Tue, 11 May 2010 12:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10011581</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10011581</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/05/11/assembly-resolution-in-msbuild-and-visual-studio-series-introduction.aspx#comments</comments><description>&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 18px; "&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Assembly references are an integral part of build process. When the assembly references passed to the compiler are correct everything works but when they are not projects stop building.&amp;nbsp; When this happens It can be frustrating to try and figure out why a reference was resolved from one location rather than another thereby causing the problem. In this series we will be detailing what steps are taken to take a reference from the project file and turn it into the path on disk that is passed to the compilers.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;This series will be focusing on the MSBuild task ResolveAssemblyReference. This task does the work of taking references declared in project files and turning them into paths on disk.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The reason we discuss this task is because this same task is used by both MSBuild on the commandline and Visual Studio to find the references. Internally Visual Studio uses MSBuild as its build engine, so even though this series focuses on the behavior in MSBuild, it behaves exactly the same way in Visual Studio.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;b&gt;Outline for the of the assembly resolution series.&lt;/b&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Part 1&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In part one we will discuss how references are represented inside of the project file. This will give a basic understanding when looking at a project file of the different forms a reference can take (e.g. file path, simple name, or fusion name) and the additional attributes that can be set on those references.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Part 2&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In part two we will discuss some of the basic inputs to the ResolveAssemblyReference task. Why these inputs are important and how they affect how references are found is outlined. This post also goes into detail about how a reference is resolved and the different kinds of algorithms involved in turning what is represented in the project file into a path on disk.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Part 3&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In part three we discuss the AssemblyFoldersEx registry location. This is just one of the places where references can be resolved from, however it is one of the most complicated locations due to how the location is searched. This section will discuss the layout of the registry keys and the algorithms used to find assemblies which are declared in this location.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Part 4&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In part four we will discuss how conflicts between dependent assemblies arise and how they are dealt with. This section will provide an understanding of why conflict warnings occur and how they can be prevented or disabled. This part also discusses how the determination as to whether or not an assembly should be copied to the output directory is made. This is partially dependent on the resolution of conflicts between dependent assemblies and for this reason is in the same section.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Part 5&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In part five we will discuss how the target framework moniker represented in the project file is used to generate a list of directories which represent the framework that the project is targeting. We also discuss the new multi-targeting rules that were introduced in MSBuild 4.0 to prevent users from referencing framework assemblies which are not part of the framework their project is targeting.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Part 6&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In part six we will discuss the ResolveAssemblyReference task logging output. It logs a large amount of information about why it resolves references a certain way. This information is very useful when trying to determine why a reference was not resolved when it was expected to resolve or why one reference was picked from a certain location when it was expected to come from another.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;Chris Mann&lt;/strong&gt;&amp;nbsp;– Developer, MSBuild&amp;nbsp;&lt;/p&gt;&lt;/span&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10011581" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/msbuild/">msbuild</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Chris+Mann/">Chris Mann</category></item><item><title>Building on Cross targeting scenarios and 64-bit MSBuild</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/05/07/building-on-cross-targeting-scenarios-and-64-bit-msbuild.aspx</link><pubDate>Fri, 07 May 2010 19:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10010121</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10010121</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/05/07/building-on-cross-targeting-scenarios-and-64-bit-msbuild.aspx#comments</comments><description>&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 18px; "&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;During the Visual Studio 2010 development cycle a push to make the build experience better on Cross compilation scenarios as well on making sure a build using 32-bit MSBuild was identical (in outputs) to a build using 64-bit MSBuild.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In most cases, 64-bit and 32-bit MSBuild will indeed produce the same output. However there are some cases, generally cross compilation scenarios, where this is not the case.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Note that since Visual Studio is a 32-bit application, if you build from Visual Studio, it is equivalent to running the 32-bit MSBuild.&lt;/p&gt;&lt;h3&gt;&amp;nbsp;&lt;/h3&gt;&lt;h3&gt;ResolveAssemblyReference: Reference resolution ignores Processor Architecture except when resolving from the Global Assembly Cache&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If you have two assemblies whose identities differ only by the processor architecture, i.e.&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;myTypes, Version=1.0.1234.0, Culture=en-US, PublicKeyToken=b77a5c561934e089c, ProcessorArchitecture=msil&amp;nbsp;&lt;br&gt;myTypes, Version=1.0.1234.0, Culture=en-US, PublicKeyToken=b77a5c561934e089c, ProcessorArchitecture=x86&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;And you try to reference one of them specifically:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;&amp;lt;Reference Include="myTypes, Version=1.0.1234.0, Culture=en-US,&amp;nbsp; PublicKeyToken=b77a5c561934e089c, ProcessorArchitecture=x86"/&amp;gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;You will notice that the first reference found will be picked up.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;It will also cause the CopyLocal property being set to false.&lt;/p&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Building with MSBuild 32-bit or 64-bit.&lt;/p&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Add your affected references to the Global Assembly Cache. See&amp;nbsp;&lt;a mce_href="http://support.microsoft.com/kb/315682" style="color: rgb(54, 109, 244); text-decoration: none; " href="http://support.microsoft.com/kb/315682"&gt;KB315682 on how to do that&lt;/a&gt;.&lt;/p&gt;&lt;h3&gt;&amp;nbsp;&lt;/h3&gt;&lt;h3&gt;64-bit MSBuild is not able to find VCBuild.exe while building a VC++ 3.5 solution&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;You keep facing the following error:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;Build FAILED.&lt;/em&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;"mysolution.sln" (Rebuild target) (1) -&amp;gt;(mcpplib1:Rebuild target) -&amp;gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 Warning(s)&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 Error(s)&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Building with MSBuild 64-bit only.&lt;/p&gt;&lt;p mce_keep="true" style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&amp;nbsp;&lt;/p&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In order to properly build solutions with MSBuild containing 3.5 and earlier VC++ project files (*.vcproj) the PATH environment variable should contain the path to VCBuild.exe, which happens to be a 32-bit only executable. To build with 64-bit MSBuild you should point to the location under “Program Files (x86)” path.&lt;/p&gt;&lt;h3&gt;&amp;nbsp;&lt;/h3&gt;&lt;h3&gt;LC.exe causes build failures while building AMD64 configurations inside Visual Studio&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;When building the AMD64 configuration of a solution, LC.exe is being picked up from %&lt;strong&gt;Program Files (x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\LC.exe&lt;/strong&gt;&amp;nbsp;instead of being picked of from %&lt;strong&gt;Program Files (x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64\LC.exe.&amp;nbsp;&lt;/strong&gt;Or if you are using Visual Studio 2008, from the directory&amp;nbsp;&lt;strong&gt;%Program Files%\Microsoft SDKs\Windows\v6.0A\bin&lt;/strong&gt;.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;This will make you face an error like this:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;LC : error LC0000: 'Could not load file or assembly 'MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.'&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;This issue is caused by the fact that LC.exe is not able to satisfy the Cross-Compilation scenarios because of some specific requirements on how it needs to load the referenced dynamic libraries.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;NOTE: your build will succeed if you use 64-bit MSBuild on the command line.&lt;/p&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Cross compilation scenarios. Building x64 platforms with 32-bit MSBuild or x86 platform with 32-bit MSBuild.&lt;/p&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Your build will succeed if you use 64-bit MSBuild in the command line, however if you still want to build inside Visual Studio IDE you can use the following to your project file (by manually editing it):&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;&amp;lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "&amp;gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;&lt;strong&gt;&amp;lt;LCToolPath&amp;gt;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\x64&amp;lt;/LCToolPath&amp;gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;h3&gt;RegisterAssembly task fails on Cross targeting scenarios&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If you have a project in your solution targeted to build an x64 platform and you:&lt;/p&gt;&lt;ul style="margin-left: 0px; padding-left: 2em; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; "&gt;&lt;li&gt;set it to be registered for COM Interop (on the Project Build properties)&lt;/li&gt;&lt;li&gt;or set the RegisterForComInterop property in the project file to true&lt;/li&gt;&lt;/ul&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;You will face the following issue while building it:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;Error 1 File "MyDll.dll" is not a valid assembly. C:\Windows\Microsoft.NET\Framework\v4.0.20904\Microsoft.Common.targets 3257 9 ClassLibrary3&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;MSBuild cannot register a library for COM Interop if its architecture does not match the architecture of the MSBuild.exe (or DevEnv.exe) hosting the build process.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;So on a 64-bit OS, the following scenarios will not work when the RegisterAssembly task is invoked as part of the build:&lt;/p&gt;&lt;ul style="margin-left: 0px; padding-left: 2em; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; "&gt;&lt;li&gt;In the IDE the user changes the platform of the project to x64 and builds&lt;/li&gt;&lt;li&gt;In the command line, 32-bit MSBuild will fail to build a project targeting a x64 platform&lt;/li&gt;&lt;li&gt;In the command line, 64-bit MSBuild will fail to build a project targeting the x86 platform&lt;/li&gt;&lt;/ul&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Cross compilation scenarios. Building x64 platforms with 32-bit MSBuild or x86 platform with 32-bit MSBuild.&lt;/p&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;You need to match the architecture of MSBuild.exe with the platform you are attempting to build, or&lt;/li&gt;&lt;li&gt;Instead of setting the “RegisterForComInterop” property to true, add a custom step to your build that runs RegAsm.exe to register your COM library. It must run the version of RegAsm.exe that matches the architecture of your library. For details on how to add a custom build step,&amp;nbsp;&lt;a style="color: rgb(54, 109, 244); text-decoration: none; " href="http://msdn.microsoft.com/en-us/library/ms366724.aspx"&gt;see here&lt;/a&gt;. Or follow this steps:&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;In the project properties, select “Build Events…” from the compile page.&lt;/li&gt;&lt;li&gt;Add the following post build command line: "%Windir%\Microsoft.NET\&lt;strong&gt;Framework[64]&lt;/strong&gt;\&lt;strong&gt;v4.0.xxxxx&lt;/strong&gt;\regasm" "$(TargetPath)"&lt;ul style="margin-left: 0px; padding-left: 2em; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; "&gt;&lt;li&gt;Be careful to select the Framework directory that matches the architecture you are targeting&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;COM references are not resolved on cross targeting scenarios&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If you have a COM object registered by using regsvr32.exe, consider that there is a 32-bit and 64-bit regsvr32.exe. If you used 32-bit regsvr32.exe to register your COM object and you are attempting to build a project targeting x86 platform but using 64-bit MSBuild. The build will fail, this issue is caused by the fact that the library was registered with a pure 32-bit regsvr32.exe and thus it only registers the component under the WOW registry section, that is invisible to 64-bit processes that do not attempt an explicit look up on the WOW nodes.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The opposite is also true, using the 64-bit regsvr32.exe to register the library and attempting to build a project targeting a x64 platform with 32-bit MSBuild. This process has no way to access the 64-bit part of the registry.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;One manifestation of this issue would be if your build is failing with an AxImp error when building a project that consumes a registered PIA of an ActiveX control:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;Build FAILED.&amp;nbsp;&lt;br&gt;"ActiveXWithPiaConsumer.csproj" (default target) (1) –&amp;gt; (ResolveComReferences target) -&amp;gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;&amp;nbsp; C:\Windows\Microsoft.NET\Framework64\v4.0.21112\Microsoft.Common.targets(1543,9): warning MSB3283: Cannot find wrapper assembly for type library "AxActiveXControlLib". [ActiveXWithPiaConsumer.csproj]&amp;nbsp;&lt;br&gt;"ActiveXWithPiaConsumer.csproj" (default target) (1) –&amp;gt; (ResolveComReferences target) -&amp;gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;&amp;nbsp; AXIMP : AxImp error : Did not find a registered ActiveX control in 'ActiveXWithPia\ActiveXControl.dll'. [ActiveXWithPiaConsumer.csproj]&lt;/em&gt;&lt;/p&gt;&lt;p mce_keep="true" style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;Affected scenarios:&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Mismatches between the architecture of the regsvr32.exe used to register the library and the architecture of MSBuild used to build:&lt;/p&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;32-bit regsvr32.exe and 64-bit MSBuild.exe&lt;/li&gt;&lt;li&gt;64-bit regsvr32.exe and 32-bit MSBuild.exe&lt;/li&gt;&lt;/ol&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;NOTE: if you are using a 32-bit only COM object while trying to build a x64 platform the Interop assembly cannot be generated, and the same applies if you are using a 64-bit only COM object and you are trying to build the x86 platform.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;Workaround:&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Build using a matching MSBuild architecture with the architecture of regsvr32 and the platform to build:&lt;/p&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;You want to build the x86 platform, use 32-bit MSBuild + 32-bit regsvr32.exe.&lt;/li&gt;&lt;li&gt;You want to build a x64 platform, use 64-bit MSBuild + 64-bit regsvr32.exe.&lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;Cannot build Silverlight project targeting a x64 platform or using 64-bit MSBuild&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;You have a Silverlight project and you change the platform to x64. You might face one of the following errors:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;The "ValidateXaml" task failed unexpectedly.&amp;nbsp;&lt;br&gt;System.BadImageFormatException: Could not load file or assembly 'obj\x64\Debug\SilverlightApplication1.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;or if you are building using 64-bit MSBuild:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;"SilverlightApplication1.csproj" (GetXapOutputFile target) (2:2) -&amp;gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.Common.targets(101,9): error : The Silverlight 3 SDK is not installed. [SilverlightApplication1.csproj]&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;Attempts to build a Silverlight project targeting a x64 platform with either 32-bit or 64-bit MSBuild.&lt;/li&gt;&lt;li&gt;Attempts to build a Silverlight project with 64-bit MSBuild.&lt;/li&gt;&lt;/ol&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;No workaround. Silverlight DOES NOT support x64 platforms. And Silverlight projects cannot be built by 64-bit MSBuild. You must use the 32-bit MSBuild and target x86 or AnyCPU platforms to build your Silverlight projects.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If you are using Team Build select x86 for the MSBuild platform setting.&lt;/p&gt;&lt;h3&gt;Interop assemblies are not generated correctly if the project targets the default platform&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;If you have a class library project (for example) and you haven’t changed the platform of the project, it will be targeting the AnyCPU platform. However if you add a reference to a COM object you will find out that the generated Interop assembly is specifically targeting the x86 platform.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;This is because Interop assemblies always have an explicit target platform, and in the absence of an explicit platform from the project consuming the Interop assembly this target platform is defaulted to the value of an Environment Variable named “PROCESSOR_ARCHITECTURE”, which inside Visual Studio IDE it evaluates to the x86 platform.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The effect of this is that if your application (targeting AnyCPU platform) is run in a 64-bit Operating System, it will run as a 64-bit process and the will fail to load the Interop assembly.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Note that applications built as AnyCPU will always run as 64-bit under a 64-bit Operating System, no matter if you launch them from a 64-bit or 32-bit command window.&lt;/p&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Projects targeting the default platform and consuming Interop assemblies. This will happen either with 32-bit and 64-bit MSBuild.&lt;/p&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Explicitly set the platform on your project or manually add it to the project by defining the PlatformTarget property to your configuration block in the project file:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; &amp;lt;PlatformTarget&amp;gt;AnyCPU&amp;lt;/PlatformTarget&amp;gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p mce_keep="true" style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;An error occurs when compiling a .resx file MSBuild&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;On a 64-bit OS you have a project targeting the x86 platform and it targets 3.5 .NET Framework or below. Your project has a reference to a 32-bit only assembly, and when you build you get the following error:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;ResourceFrm.resx(1436,5): error RG0000: Could not load file or assembly '32bitOnlyAssembly.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 1436, position 5.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;This issue is caused by the fact that in the 3.5 .NET tools resgen.exe in both the x86 and x64 bin directories is marked as IL (architecture agnostic), causing it to run on a 64-bit Operating System as a64-bit executable no matter what. As a 64-bit process, resgen.exe is unable to load the 32-bit only library.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Also if you are targeting 4.0 .NET, MSBuild will fail in the same way if you are referencing a 32-bit only assembly while using 64-bit MSBuild and vice versa.&lt;/p&gt;&lt;h5&gt;Affected scenarios:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Cross targeting scenarios while building projects which contain resource files with MSBuild:&lt;/p&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;In a 64-bit Operating System If you are targeting 3.5 .NET and the project references a 32-bit assembly with either 32-bit or 64-bit MSBuild.&lt;/li&gt;&lt;li&gt;The project references a 32-bit assembly and you are using 64-bit MSBuild.&lt;/li&gt;&lt;li&gt;The project references a 64-bit assembly and you are using 32-bit MSBuild.&lt;/li&gt;&lt;/ol&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Make the library referred on the error target the AnyCPU platform&lt;/p&gt;&lt;h3&gt;Cannot build SQL Server project using 64-bit MSBuild&lt;/h3&gt;&lt;h5&gt;Description:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;You have a SQL server project and you attempt to build it using 64-bit MSBuild, the following error is displayed:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;em&gt;&amp;nbsp; SqlServerProject1.vbproj(149,3): error MSB4019: The imported project "C:\Windows\Microsoft.NET\Framework64\v4.0.xxxxx\SqlServer.targets" was not found. Confirm that the path in the &amp;lt;Import&amp;gt; declaration is correct, and that the file exists on disk.&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;h5&gt;Workaround:&lt;/h5&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Copy C:\Windows\Microsoft.NET\&lt;strong&gt;Framework64\v4.0.xxxxx\&lt;/strong&gt;SqlServer.targets to C:\Windows\Microsoft.NET\&lt;strong&gt;Framework\v4.0.xxxxx&lt;/strong&gt;\SqlServer.targets&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;Daniel Estrada&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;&lt;/strong&gt;Software Development Engineer in Test,&amp;nbsp;&lt;em&gt;MSBuild Team&lt;/em&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10010121" width="1" height="1"&gt;</description></item><item><title>MSBuild Property Functions (2)</title><link>http://blogs.msdn.com/b/msbuild/archive/2010/05/05/msbuild-property-functions-2.aspx</link><pubDate>Wed, 05 May 2010 20:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10008281</guid><dc:creator>Michael Fourie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/msbuild/rsscomments.aspx?WeblogPostID=10008281</wfw:commentRss><comments>http://blogs.msdn.com/b/msbuild/archive/2010/05/05/msbuild-property-functions-2.aspx#comments</comments><description>&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 18px; "&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Some more information about this 4.0 feature. (I've also updated the first post with this, so everything's in one place for your reference.)&lt;/p&gt;&lt;h4&gt;Built-in MSBuild functions&lt;/h4&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The full list of built-in [MSBuild] functions, like the one above, are in the MSDN topic&amp;nbsp;&lt;a target="_blank" style="color: rgb(54, 109, 244); text-decoration: none; " href="http://msdn.microsoft.com/en-us/library/dd633440.aspx"&gt;here&lt;/a&gt;. They include arithmetic (useful, for example, for modifying version numbers), functions to convert to and from the MSBuild&amp;nbsp;&lt;a target="_blank" style="color: rgb(54, 109, 244); text-decoration: none; " href="http://msdn.microsoft.com/en-us/library/bb383819.aspx"&gt;escaping format&lt;/a&gt;&amp;nbsp;(on rare occasions, that is useful). Here's another example&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;$([MSBuild]::Add($(VersionNumber), 1))&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;And here's one other property function that will be useful to some people:&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;$([MSBuild]::GetDirectoryNameOfFileAbove(&lt;em&gt;directory, filename)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Looks in the designated directory, then progressively in the parent directories until it finds the file provided or hits the root. Then it returns the path to that root. What would you need such an odd function for? It's very useful if you have a tree of projects in source control, and want them all to share a single imported file. You can check it in at the root, but how do they find it to import it? They could all specify the relative path, but that's cumbersome as it's different depending on where they are. Or, you could set an environment variable pointing to the root, but you might not want to use environment variables. That's where this function comes in handy – you can write something like this, and all projects will be able to find and import it:&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;&amp;nbsp; &amp;lt;Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), EnlistmentInfo.props))' != '' " /&amp;gt;&lt;/strong&gt;&lt;/p&gt;&lt;h4&gt;Error handling&lt;/h4&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;The functions parser is pretty robust but not necessarily that helpful when it doesn't wokr. Errors you can get include&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;(1) It doesn't evaluate but just comes out as a string. Your syntax isn't recognized as an attempt at a function, most likely you've missed a closing parenthesis somewhere. That's easy to do when there's lots of nesting.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;(2)&amp;nbsp;&lt;em&gt;&lt;strong&gt;error MSB4184: The expression "…" cannot be evaluated.&lt;/strong&gt;&amp;nbsp;&lt;/em&gt;It treated it as a function, but probably it couldn't parse it.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;(3)&amp;nbsp;&lt;em&gt;&lt;strong&gt;error MSB4184: The expression "…" cannot be evaluated. Method '…' not found.&lt;/strong&gt;&amp;nbsp;&lt;/em&gt;It could parse it, but not find a member it could coerce to, or it was considered ambiguous by the binder. Verify you weren't calling a static member using instance member syntax. Try to make the call less ambiguous between overloads, either by picking another overload (that perhaps has a unique number of parameters) or using the Convert class to force one of the parameters explicitly to the type the method wants. One common case where this happens is where one overload takes an integer, and the other an enumeration.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;(4)&amp;nbsp;&lt;em&gt;&lt;strong&gt;error MSB4184: The expression "[System.Text.RegularExpressions.Regex]::Replace(d:\bar\libs;;c:\Foo\libs;, \lib\x86, '')" cannot be evaluated. parsing "\lib\x86" - Unrecognized escape sequence \l.&lt;/strong&gt;&lt;/em&gt;&amp;nbsp; Here's an example where it bound the method, but the method threw an exception ("unrecognized escape sequence") because the parameter values weren't valid.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;(5)&amp;nbsp;&lt;em&gt;&lt;strong&gt;error MSB4186: Invalid static method invocation syntax: "....". Method 'System.Text.RegularExpressions.Regex.Replace' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`))..&lt;/strong&gt;&amp;nbsp;&lt;/em&gt;Hopefully this is self explanatory, but more often than a syntax mistake, you called an instance member using static member syntax.&lt;/p&gt;&lt;h4&gt;Arrays&lt;/h4&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Arrays are tricky as the C# style syntax "new Foo[]" does not work, and Array.CreateInstance needs a Type object. To get an array, you either need a method or property that returns one, or you use a special case where we can force a string into an array. Here's an example of the latter case:&lt;/p&gt;&lt;blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;b&gt;$(LibraryPath.Split(`;`))&lt;/b&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;In this case, the string.Split overload wants a string array, and we're converting the string into an array with one element.&lt;/p&gt;&lt;h4&gt;Regex Example&lt;/h4&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Here I'm replacing a string in the property "LibraryPath", case insensitively.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;&amp;lt;LibraryPath&amp;gt;$([System.Text.RegularExpressions.Regex]::Replace($(LibraryPath), `$(DXSDK_DIR)&lt;/strong&gt;&lt;a style="color: rgb(54, 109, 244); text-decoration: none; " href="file://lib/x86%60"&gt;&lt;strong&gt;\\lib\\x86`&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;, ``, System.Text.RegularExpressions.RegexOptions.IgnoreCase))&amp;lt;/LibraryPath&amp;gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Here's how to do the same with string manipulation, less pretty.&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;&amp;lt;LibraryPath&amp;gt;$(LibraryPath.Remove($(LibraryPath.IndexOf(`$(DXSDK_DIR)\lib\x86`, 0, $(IncludePath.Length), System.StringComparison.OrdinalIgnoreCase)), $([MSBuild]::Add($(DXSDK_DIR.Length), 8))))&amp;lt;/LibraryPath&amp;gt;&lt;/strong&gt;&lt;/p&gt;&lt;h4&gt;Future Thoughts&lt;/h4&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;So far in my own work I've found this feature really useful, and far, far, better than creating a task. It can make some simple tasks that were impossible possible, and often, easy. But as you can see from the examples above, it often has rough edges and sometimes it can be horrible to read and write. Here's some ways we can make it better in future:&lt;/p&gt;&lt;ol style="margin-left: 2em; padding-left: 0px; "&gt;&lt;li&gt;A "language service" would make writing these expressions much easier to get right. What that means is a better XML editing experience inside Visual Studio for MSBuild format files, that understands this syntax, gives you intellisense, and squiggles errors. (Especially missed closing parentheses!)&lt;/li&gt;&lt;li&gt;A smarter binder. Right now we're using the regular CLR binder, with some customizations. Powershell has a much more heavily customized binder, and I believe there is now one for the DLR. If we switch to that, it would be much easier to get the method you want, with appropriate type conversion done for you.&lt;/li&gt;&lt;li&gt;Some more methods in the [MSBuild] namespace for common tasks. For example, a method like $([MSBuild]::ReplaceInsensitive(`$(DXSDK_DIR)&lt;a style="color: rgb(54, 109, 244); text-decoration: none; " href="file://lib/x86%60"&gt;\\lib\\x86`&lt;/a&gt;, ``)) would be easier than the long regular expression example above.&lt;/li&gt;&lt;li&gt;Enable more types and members in the .NET Framework that are safe, and useful.&lt;/li&gt;&lt;li&gt;Make it possible to expose your own functions, that you can use with this syntax, but write in inline code like MSBuild 4.0&amp;nbsp;&lt;a target="_blank" style="color: rgb(54, 109, 244); text-decoration: none; " href="http://msdn.microsoft.com/en-us/library/dd722601.aspx"&gt;allows you to do for tasks&lt;/a&gt;. You'd write once, and use many.&lt;/li&gt;&lt;li&gt;Offer some similar powers for items and metadata.&lt;/li&gt;&lt;/ol&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;What do you think?&lt;/p&gt;&lt;p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;strong&gt;Dan Moseley&lt;/strong&gt;&lt;br&gt;Developer Lead - MSBuild&amp;nbsp;&lt;/p&gt;&lt;/span&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10008281" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Dan+Moseley/">Dan Moseley</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/msbuild/">msbuild</category><category domain="http://blogs.msdn.com/b/msbuild/archive/tags/Property+Functions/">Property Functions</category></item></channel></rss>