none
VCProjectEngineObject.CreateObject in MSVS 2012 RRS feed

  • Question

  • Our primary development is in C++ and we have internal application, which prepares and updates vcxproject files programatically by Visual Studio interop libraries. 

    Now, we are moving some software from Visual Studio 2010 to Visual Studio 2012 and I am trying to update also this helper application. It is written in C# and uses envdte and Microsoft.VisualStudio.VCProjectEngine references. However, there is issue while creating new project. The code is:

    // Usings at the top of the file:
    // using Microsoft.VisualStudio.VCProjectEngine;
    
    // Create new project file myfile.vcxproj.
    VCProjectEngine engine = new VCProjectEngineObject(); // Line (1). OK.
    VCProject project = (VCProject) engine.CreateProject("myfile.vcxproj"); // Line (2). Throws exception.

    Line (1) creates instance of engine. Line (2) throws and exception with message:

    MSBuild does not contain a value for the "VCTargetsPath" property.

    However, this exception is thrown only by executing our helper application from command line (outside Visual Studio 2012 environment). Its execution from Visual Studio 2012 (by Start With/Without Debugging) is ok and the application does everything it should do.

    Istead of Line (1) I also try the code from MSVS 2010 version of my helper application:

    VCProjectEngine engine = new Microsoft.VisualStudio.Project.VisualC.VCProjectEngi ne.VCProjectEngineShim(); // Alternative to Line (1).

    The result is same. Program throws same exception on Line (2).

    I have Visual Studio 2008, 2010 and 2012 installed on my computer and I need all of them installed. So, where is the problem?

    Thank you for your answers.

    Monday, July 22, 2013 12:43 PM

Answers

All replies

  • Hi,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
     
    Thank you for your understanding and support.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 23, 2013 7:28 AM
    Moderator
  • I would like to add the stack trace:
    at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectExceptionHelper(Exception innerException, String unformattedMessage, Object[] args)
    at Microsoft.VisualStudio.Project.Utilities.ProjectErrorUtilities.ThrowProjectException(String message)
    at Microsoft.VisualStudio.Project.VisualC.VCPlatformExtensionService.GetInstalledPlatforms(String toolsVersion)
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectEngineShim.ReadInstalledPlatforms()
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectEngineShim.get_PlatformShims()
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.GetVCPlatform(String platform)
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.get_ConfigurationShims()
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim.Initialize(IntPtr externalCookie)
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectEngineShim.CreateProjectWithNoEvent(String projectName)
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectEngineShim.<>c__DisplayClass1.<CreateProject>b__0()
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.ApartmentMarshaler.Invoke[TResult](Func`1 method)
    at Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectEngineShim.CreateProject(String projectName)
    
    And the source is:
    Microsoft.VisualStudio.Project.Utilities.v11.0


    Friday, July 26, 2013 3:11 PM
  • Hi,

    Unlike the DTE automation interface, the underlying VCProjectEngine object is a COM object that gets re-guided on every C++ release. I suspect the issue here is that you will need to conditionally load and use the interop assembly based on the version of VS they want to automate.

    Thanks,

    Gaurav

    Tuesday, July 30, 2013 12:35 AM
  • Thank you for your answer Gaurav,

    I understand your question, but I am not familiar with interop classes (there are quite messy, bad-documented and full of workarounds for me, sorry). Can you write me a piece of code you talking about?

    Thank you.

    Tuesday, July 30, 2013 8:35 AM
  • Thursday, August 1, 2013 10:49 PM
  • Hi,

    If you still need further help, please open a connect request at http://connect.microsoft.com/VisualStudio

    Thanks,

    Gaurav

    Monday, August 5, 2013 11:32 PM
  • Gaurav,

    thank you for your replies. I am not sure, if marked reply is real answer. Checking registry entry was first thing I did and everything have been set correctly after MSVS installation. I am sorry, I don't think that given link solves problem. 

    I opened connect request with steps to reproduce the problem (it is very easy to reproduce this issue, just create console application and write down two lines of code):

    https://connect.microsoft.com/VisualStudio/feedback/details/796433/vcprojectengineobject-createproject-in-msvs-2012

    Regards,

    Jaroslav

    Tuesday, August 6, 2013 2:06 PM