.NET Framework Developer Center > .NET Development Forums > MSBuild > How to use the "Microsoft.Build.BuildEngine.Engine" to build solutions which relies on Environment Variables on their xcopy Post Build Events?
Ask a questionAsk a question
 

General DiscussionHow to use the "Microsoft.Build.BuildEngine.Engine" to build solutions which relies on Environment Variables on their xcopy Post Build Events?

  • Sunday, November 01, 2009 9:46 PMTrinominal Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    As you may know, one can use the class "Microsoft.Build.BuildEngine.Engine" in order to programatically build a solution, instead of use MSBuild.

    I want to use this class to programatically build solutions, instead of using MSBuild, but I have a problem.

    Some of the solutions I'm trying to build contains "xcopy..." commands in the PostBuild events of their projects, and these xcopy events relies on environment variables. The environment variables are defined, and when running MSBuild in order to build the solution, the build succeeds. However, for some un-known reason, the Engine fails to build the solution and specifies that the PostBuildEvent "xcopy ..." exited with code 4.

    1. Can some specify how this problem can be solved ?

    2. Are you aware of any other scenarios in which the MSBuild should succeeds, and the Engine class fails ?

    Regards

    Thanks a lot

All Replies

  • Wednesday, November 04, 2009 4:57 AMChao KuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello, Trinominal
    Could you clarify that does the error happens before you add xcopy commands? If so, please reference this thread MSBuild crashes with a "Message" task could not be instantiated exception
    And if not, please post your XCopy command line here.
    Looking forward your following up!
    Thanks
    Chao
  • Friday, November 06, 2009 2:13 AMChao KuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Thank you!
    Chao
  • Sunday, November 22, 2009 3:30 PMTrinominal Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Chao Kuo,

    Sorry for the delay..

    The problem is solved by the following solution:

    The xcopy contained environment variable to specify the location of the files which should be copied.

    So the solution is just to verify that the process from which your code is being executed has the relevant environment variables defined.


    Regards
  • Sunday, November 22, 2009 3:31 PMTrinominal Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Chao Kuo,

    Sorry for the delay..

    The problem is solved by the following solution:

    The xcopy contained environment variable to specify the location of the files which should be copied.

    So the solution is just to verify that the process from which your code is being executed has the relevant environment variables defined.


    Regards