none
MSBuild 4.0 builds projects in a solution in a different order than visual studio

    Question

  • I have a solution file containing two projects, a Wix project using Votive, and a custom action dll project that is used by the wix project.  The wix project has a project reference to the custom action project, and so the solution needs to build the projects in the correct order:

    1) CustomAction.dll

    2) Setup.msi

    This order applies to both MSBuild / TeamBuild and VisualStudio builds, and it all worked correctly before I upgraded the solution to VS 2010.  After upgrading the solution to VS 2010, I can build correctly in the IDE, but command line builds build in the wrong order, causing the build to fail.

    I've tried recreating the solution from scratch using VS2010, but I still get the same issue.  The project dependencies in the solution are correct, though the check boxes are greyed out because VS is detecting the project reference, and forcing the ordering.

    The project reference in the .wixproj looks correct:

        <ProjectReference Include="..\..\SharedCommonSource\IISCustomAction\IISCustomAction.csproj">
          <Name>IISCustomAction</Name>
          <Project>{53328c31-fb51-4b15-a8f9-576ab05cb898}</Project>
          <Private>True</Private>
          <DoNotHarvest>True</DoNotHarvest>
        </ProjectReference>

    If I undo the upgrade of the solution file, then MSBuild 4.0 works correctly, but this is not a viable fix for me.  When I do this, the only change to the solution file is to change the header from:

    Microsoft Visual Studio Solution File, Format Version 11.00
    # Visual Studio 2010

    to this:

    Microsoft Visual Studio Solution File, Format Version 10.00
    # Visual Studio 2008

    It seems like MSBuild 4.0 is not handling the project dependencies correctly for 2010 solutions.

    Tuesday, May 18, 2010 5:36 PM

All replies

  • Hi Bwmeier,

    Thanks for your post.

    Have you tried to add project reference by selecting references node and adding a reference there by selecting it on Projects tab of Add Reference dialog, replace Project Denpendencies in context menu. The project dependencies that are available for the solution is a different way of expressing this.

    Please let me know the result.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, May 19, 2010 3:27 AM
  • That's how the project reference was added - the pasted bit from the .wixproj file above is what is generated when I do that.  The solution file does not have any dependency information in it.
    Thursday, May 20, 2010 5:10 PM
  • Hi Bwmeier,

    I'm not sure the following thread is the similiar question as yours.

    http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/01a0a7c6-b9ab-40cd-903a-a4a0b5eb2882

    But I would suggest you trying to add project dependency to your solution file to see if it works fine. And have you meet the same issue but not with a Wix project? I see the Wix Votive is a beta vesion, I guess it might be some related to Wix.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, May 21, 2010 8:51 AM
  • Gotta love the forum software killing my reply before submitting it...

    The solution outlined in that post works, temporarily.  The problem is that when I open the solution file in visual studio and make any changes, that project dependency note appears to go away, because VS sees that the dependency is expressed in the project reference.

    The problem appears to be specific to MSBuild 4.0, if I build using 3.5 everything works correctly for all permutations I've tried.  Unfortunately, TFS 2010 uses MSBuild 4.0, so the problem appears there.  I have a small solution that reproduces the problem, I can zip it up and send it somewhere if needed.

    Friday, May 21, 2010 5:45 PM
  • Hi Bwmeier,

    It's better to upload a sample to repro this issue. But is this sample wix project?

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, May 25, 2010 7:47 AM
  • I am having the same issue. My solution builds fine in MsBuild 2008, but MsBuild 2010 does not build according the dependencies defined by Visual Studio 2010: both dependencies that result from a project Reference and dependencies that result from Project Dependencies -> Dependencies.
    Thursday, June 03, 2010 9:16 PM
  • If there's a bug here, please make sure it's open on Connect. We don't open bugs directly from forums in general, as they're then invisible. If it's gotten closed without a fix, let us know.

    Dan


    developer on msbuild
    Monday, July 26, 2010 1:19 PM
  • We're also experiencing the same problem. Projects are getting built in the wrong order even if we set dependencies on the solution (Project Dependencies -> Dependencies). 

    Our solution contains both vcxproj and csproj files. Some of our csproj files are dependent on vcxproj files and we've got custom AfterBuild tasks to copy the native Dll's to the correct folders. This worked for MSBuild 3.5, but doesn't consistently work when using MSBuild 4.0.

    Any help?

    Thursday, October 21, 2010 5:45 AM
  • If there's a bug here, please make sure it's open on Connect. We don't open bugs directly from forums in general, as they're then invisible. If it's gotten closed without a fix, let us know.

    Dan


    developer on msbuild


    There is a bug id for this in Connect: 586358

    http://connect.microsoft.com/VisualStudio/feedback/details/586358/msbuild-ignores-projectsection-projectdependencies-in-sln-file-and-attempts-to-build-projects-in-wrong-order 

    Unfortunately, there isn't an elegant workaround or fix as of yet.

    It has been suggested to partition the solution and force the build order as an automated build workaround.
    I haven't tried it yet but it looks like I might have to do that!

    Tuesday, October 26, 2010 4:52 PM
  • Same problem here. I have several wix msi projects and a wixbundle project (Burn).  In the IDE everything builds in the right order, first the MSIs build, then the bundle.  With MSBuild, the bundle tries to build first and fails.  To work around this I have to build twice.  
    Wednesday, October 19, 2011 10:35 PM