Two steps build when your project contains XAML files, Visual Studio vs MSBuild
<p>There is project with output type as class library, which contains WPF controls. AssemblyInfo.cs should be generated before compile, and for that purpose there is next target (using MSBuild.Community.Tasks) which I imported at the end of <code>.csproj</code> file:</p>

<pre><code>&lt;Target Name="BeforeCompile"&gt;
    &lt;AssemblyInfo CodeLanguage="CS"
        OutputFile="Properties\AssemblyInfo.cs"
        AssemblyCompany="..."
        AssemblyCopyright="..."
        ComVisible="false"
        AssemblyVersion="..."
        AssemblyFileVersion="..."  /&gt;
&lt;/Target&gt;
</code></pre>

<p>Before build file AssemblyInfo.cs does not exist.</p>

<p>And the problem is next: when building project from Visual Studio (2015) everything if fine, file is being created, but when I use MSBuild next error shows:</p>

<pre><code>CSC : error CS2001:
Source file '...\Controls.Wpf\Properties\AssemblyInfo.cs' could not be found.
[...\Controls.Wpf\en2zf2n0.tmp_proj]
</code></pre>

<p><strong>My hot fix</strong>: is to name above target differently (which generates AssemblyInfo), let's say 'GenerateAssemblyInfo', and call it in project file this way, before all the build actions:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Project ToolsVersion="12.0" DefaultTargets="GenerateAssemblyInfo;Build" xmlns="..."&gt;
</code></pre>

<p>My guess is that happens because when there is <code>xaml</code> files - they need to be compiled into <code>baml</code> (that is why error is in <strong>en2zf2n0.tmp_proj</strong>, see above), and only after that 'real' build takes place. <code>BeforeCompile</code> happens somewhere between these two steps, and AssemblyInfo is needed before fist step, but there is no such.</p>

<p><strong>Question:</strong> What is the difference between building with Visual Studio and MSBuild this <strong>this</strong> case, and is there any <em>proper</em> (<em>more proper</em>) way to solve this?</p>