<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Marius Bancila's Blog &#187; msbuild</title>
	<atom:link href="http://mariusbancila.ro/blog/tag/msbuild/feed/" rel="self" type="application/rss+xml" />
	<link>http://mariusbancila.ro/blog</link>
	<description>Sharing my opinions and ideas!</description>
	<lastBuildDate>Mon, 14 Nov 2011 07:19:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Generate Output from T4 at Build Time</title>
		<link>http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/</link>
		<comments>http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/#comments</comments>
		<pubDate>Wed, 04 May 2011 07:27:40 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[T4]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=922</guid>
		<description><![CDATA[Text templates (aka T4) is a great feature in Visual Studio, that proves helpful in many scenarios. I use it for instance in developing Alchemy. However, it has a significant drawback: it does not generate code automatically when you build your solution. To build the files and generate their output you have to manually run [...]]]></description>
			<content:encoded><![CDATA[<p>Text templates (aka T4) is a great feature in Visual Studio, that proves helpful in many scenarios. I use it for instance in developing <a href="http://mariusbancila.ro/blog/games/alchemy/">Alchemy</a>. However, it has a significant drawback: it does not generate code automatically when you build your solution. To build the files and generate their output you have to manually run either <strong>Run Custom Tool</strong> command for each .tt file, or <strong>Transform All Templates</strong> for the entire solution.</p>
<table border="0">
<tr valign="top">
<td><div class="wp-caption alignnone" style="width: 255px"><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010runcustomtool.png" title="Run Custom Tool" width="245" height="214" /><p class="wp-caption-text">Run Custom Tool</p></div></td>
<td><div class="wp-caption alignnone" style="width: 292px"><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010tat.png" title="Transform All Templates" width="282" height="107" /><p class="wp-caption-text">Transform All Templates</p></div></td>
</tr>
</table>
<p>The good news is that Visual Studio 2010 has added capabilities for building the text templates files automatically at the build time. Basically, what you have to do is two things: first install the <a href="http://archive.msdn.microsoft.com/vsvmsdk">Visual Studio Visualization and Modeling SDK</a>. Second, manually add the following to the project file:</p>
<pre name="code" class="xml">
   &lt;PropertyGroup>
      &lt;TransformOnBuild >true&lt;/TransformOnBuild>
   &lt;/PropertyGroup>

   &lt;Import Project=
     "$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets" />
</pre>
<p>And that should do the trick. When you build the project, the .tt files will also be built.</p>
<p>To read more about this topic see:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ee847423.aspx">Code Generation in a Build Process</a></li>
<li><a href="http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration/">Understanding T4: MSBuild Integration</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 Changes for VC++ (part 1)</title>
		<link>http://mariusbancila.ro/blog/2010/03/17/visual-studio-2010-changes-for-vc-part-1/</link>
		<comments>http://mariusbancila.ro/blog/2010/03/17/visual-studio-2010-changes-for-vc-part-1/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 09:02:34 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=483</guid>
		<description><![CDATA[The new version of Visual Studio, called Visual Studio 2010 comes with a series of changes for Visual C++. This includes a new build system, new project system, multi-targeting, new IntelliSense, support in MFC for new controls, new additions to the C++ compiler (which were already approved for C++0x), new deployment model, and others. In [...]]]></description>
			<content:encoded><![CDATA[<p>The new version of Visual Studio, called Visual Studio 2010 comes with a series of changes for Visual C++. This includes a new build system, new project system, multi-targeting, new IntelliSense, support in MFC for new controls, new additions to the C++ compiler (which were already approved for C++0x), new deployment model, and others. In this post I will talk about the new build system and multi-targeting.</p>
<p>In order to show the changes I will create two simple projects, one in Visual Studio 2008, called Wordpad 2008, and one in Visual Studio 2010, called Wordpad 2010. These would be simple MFC single document applications. The image bellow shows the two solutions opened in Solution Explorer.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/wordpadsolsxs.png" title="Projects in Solution Explorer, side by side" class="alignnone" width="645" height="500" /></p>
<p>As you can see both versions contain the same solutions file (only the suffix in the name differs). The next image shows the files on disk, in comparison for the two solutions.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/wordpadsxs.png" title="Solutions on disk, side by side" class="alignnone" width="828" height="432" /></p>
<p><strong>MS-Build System</strong></p>
<p>The first thing to notice (though it might not be the obvious) is that the project file extension was modified. In Visual Studio 2008 it is called .vcproj, but in Visual Studio 2010 is called .vcxproj. Not only the extension changed, but also the content of the file. This is because in Visual Studio 2010, Visual C++ build system was changed from <a href="http://msdn.microsoft.com/en-us/library/hw9dzw3c%28VS.80%29.aspx" target="_blank">VCBuild</a> to <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" target="_blank">MSBuild</a>. This build engine was already used for the languages targeting the .NET framework.</p>
<p>MSBuild uses XML project files, and the most important elements of a project are:</p>
<ul>
<li><strong>Items</strong>: units of input into the build system, grouped into item collections, which can be used as parameters to the tasks, using the syntax <em>@(ItemCollectionName)</em>. Examples of items from the Wordpad2010 project:
<pre class="prettyprint">
  < ItemGroup >
    < ClInclude Include="MainFrm.h" / >
    < ClInclude Include="Resource.h" / >
    < ClInclude Include="stdafx.h" / >
    < ClInclude Include="targetver.h" / >
    < ClInclude Include="Wordpad2010.h" / >
    < ClInclude Include="Wordpad2010Doc.h" / >
    < ClInclude Include="Wordpad2010View.h" / >
  < /ItemGroup >
</pre>
</li>
<li><strong>Properties</strong>: pairs of key/value used to configure the builds. The value of a property can be changed after it was defined. They can be referred in the project file using the syntax <em>$(PropertyName)</em>. Examples of properties from the Wordpad2010 project.
<pre class="prettyprint">
  < PropertyGroup Label="Globals" >
    < ProjectGuid >{1E7DC2AA-8CAC-44A8-98F6-DE69249AD30C}< /ProjectGuid >
    < RootNamespace >Wordpad2010< /RootNamespace >
    < Keyword >MFCProj< /Keyword >
  < /PropertyGroup >
</pre>
</li>
<li><strong>Tasks</strong>: reusable units of executable code used to perform builds. Example of tasks can be compiling input files, linking, running external tools. Tasks can be reused in different projects.</li>
<li><strong>Targets</strong>: represent groupings of tasks in a particular order and expose parts of the project file as entry points into the build system.</li>
</ul>
<p>You can get a deeper overview on the <a href="http://msdn.microsoft.com/en-us/library/ms171452.aspx" target="_blank">MSBuild</a> engine here.</p>
<p>Another thing to notice is the presence of a file called Wordpad2010.vcxproj.filters. This file defines the solution explorer tree with the files contained in the project. This used to be a part of the file project, but in Visual Studio 2010 it was moved into a separate file. The reason is to keep the project file only for the build, not for the organization of the project.</p>
<p>The user specific settings used to be stored in a file called <strong><em>ProjectName</em>.vcproj.<em>fullyqualifiedusername</em>.user</strong>. Now there is a new file called <strong><em>ProjectName</em>.vcxproj.user</strong>.</p>
<p>You can read more about these changes in <a href="http://msdn.microsoft.com/en-us/library/ee862524%28VS.100%29.aspx" target="_blank">MSDN</a>.</p>
<p><strong>Multi-targeting</strong></p>
<p>Visual Studio 2008 came to support for multi-targeting of the .NET framework, not only for C# and VB.NET, but also for C++/CLI. In addition to that, Visual Studio 2010 comes with support for native multi-targeting.</p>
<p>The managed multi-targeting allows to target different versions of the .NET framework for mixed-mode applications. By default the target version is the latest, 4.0. This can only be changed manually in the project file. The support for changing this from the IDE was not included in this version. Actually it was dropped, because in Visual Studio 2008 this was possible.</p>
<pre class="prettyprint">
  < PropertyGroup Label="Globals" >
    < ProjectGuid >{AB3D9231-F8B6-4EAD-A15B-C792977AB26E}< /ProjectGuid >
    < RootNamespace >MixedModeDemo< /RootNamespace >
    < TargetFrameworkVersion >v3.5< /TargetFrameworkVersion >
    < Keyword >MFCDLLProj< /Keyword >
  < /PropertyGroup >
</pre>
<p>The native multi-targeting allows to use different versions of the tools and libraries to build (native) C++ projects. Of course, you must have the targeted toolset installed on your machine, in order to do that. You can define different configurations that target different versions of the toolsets. The targeted toolset can be changed from project&#8217;s properties page, General, Platform Toolset. The following image shows the available options on a machine with Visual Studio 2008 SP1 and Visual Studio 2010 installed side by side.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/wordpad2010propsgen.png" title="Platform toolset property in project&#039;s properties" class="alignnone" width="618" height="289" /></p>
<p>It is possible to target the previous version, 2008, 2005, 2003 and 2002. In theory it&#8217;s possible to target even VC6, but there is no support from Microsoft for that.</p>
<p>I suggest to read more about native multi-targeting <a href="http://blogs.msdn.com/vcblog/archive/2009/12/08/c-native-multi-targeting.aspx" target="_blank">here</a>, and about managed multi-targeting, for mixed-mode applications, <a href="http://blogs.msdn.com/visualstudio/archive/2009/11/22/framework-multi-targeting-for-vc-projects.aspx" target="_blank">here</a>.</p>
<p>In a next post I will talk about the changes to IntelliSense and browsing experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/03/17/visual-studio-2010-changes-for-vc-part-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Channel 9 Video about MSBuild for C++</title>
		<link>http://mariusbancila.ro/blog/2009/06/22/channel-9-video-about-msbuild-for-c/</link>
		<comments>http://mariusbancila.ro/blog/2009/06/22/channel-9-video-about-msbuild-for-c/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 08:03:24 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[channel9]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=309</guid>
		<description><![CDATA[Visual Studio 2010, currently in beta 1, replaces VCBuild with MSBuild as the build system, aligning C++ with the other languages that already used MSBuild. The VC++ team has already posted several articles on it&#8217;s blog about the new build system. Channel 9 has published recently a video with Bogdan Mihalcea, a developer in the [...]]]></description>
			<content:encoded><![CDATA[<p>Visual Studio 2010, currently in beta 1, replaces VCBuild with MSBuild as the build system, aligning C++ with the other languages that already used MSBuild. The VC++ team has already posted several articles on it&#8217;s <a href="http://blogs.msdn.com/vcblog/default.aspx" target="_blank">blog</a> about the new build system. Channel 9 has published recently a video with Bogdan Mihalcea, a developer in the VC++ build and system project team, talking about MSBuild. You can watch the video <a href="http://channel9.msdn.com/posts/Charles/Bogdan-Mihalcea-The-New-VC-ProjectBuild-system-MSBuild-for-C/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2009/06/22/channel-9-video-about-msbuild-for-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

