Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

VCProjectEngineObject.CreateObject in MSVS 2012

$
0
0

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.


Viewing all articles
Browse latest Browse all 4410

Trending Articles