Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen to use <ProjectReference> in project files?
    text
    copied!<p><strong>Summary:</strong></p> <p>Projects build in wrong order with visual studio and managed C++ and C# projects</p> <p><strong>Description:</strong></p> <p>I have a massive (100+ projects) solution file that is building a few projects in the wrong order. The solution file contains the following types of projects:</p> <ul> <li>native C/C++</li> <li>Managed C++</li> <li>Managed C#</li> </ul> <p>The solution contains all the proper dependencies between the different types of projects. Ok, so when I build from the command line (Using MSBuild), there is a problem. The dependencies for the managed projects (both C++ and C#) get built in the wrong order. For instance a project will fail to build because a managed dependency is missing. For instance a managed C++ file will have a using declaration that will fail:</p> <pre><code>#using &lt;foo.dll&gt; </code></pre> <p>since foo.dll doesn't exist yet.</p> <p>Which means that foo.dll should have been built before, but wasn't. Like I mentioned earlier, the dependencies are properly set up in the solution file. For instance, if foo depends on baz, I have this in the solution file...</p> <pre><code>Project("{C4ABA494-43D0-400A-9917-20E167A12CFD}") = "Foo", "...\Foo.vcxproj", "{5A42640E-9E0A-442B-8A40-AA91AD5444AC}" ProjectSection(ProjectDependencies) = postProject ... {2CE32AE0-B129-40BA-B06E-A628FA149AB3} = {2CE32AE0-B129-40BA-B06E-A628FA149AB3} EndProjectSection EndProject ... Project("{C4ABA494-43D0-400A-9917-20E167A12CFD}") = "baz", "...\baz.csproj", "{2CE32AE0-B129-40BA-B06E-A628FA149AB3}" ProjectSection(ProjectDependencies) = postProject ... EndProjectSection EndProject </code></pre> <p>So the solution file correctly has the dependency. But the dependency in the Foo.vcxproj project is only expressed by the #using directive. I've read on the visual studio blog that there is a known bug in ordering projects in msbuild. <a href="http://blogs.msdn.com/b/visualstudio/archive/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe.aspx" rel="noreferrer">http://blogs.msdn.com/b/visualstudio/archive/2010/12/21/incorrect-solution-build-ordering-when-using-msbuild-exe.aspx</a></p> <p>Their work around is to add an item called to my projects, like this:</p> <pre><code>&lt;ProjectReference Include="... foo.csproj"&gt; &lt;ReferenceOutputAssembly&gt;false&lt;/ReferenceOutputAssembly&gt; &lt;/ProjectReference&gt; </code></pre> <p>Anyways, <strong>my question is</strong>: do I need to do this ONLY for my managed C++ projects? Or do I do this for Managed C++ AND C# projects? (I kind of believe I don't need to do this for C# projects since their dependencies are explicit)</p> <p>Note: I have tried putting this on ALL projects in my build, and it didn't work so hot, as I got lots of strange build errors in my native projects...</p> <p>Thanks for any response to this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload