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

Change project platform through envdte

$
0
0

I have created an add-in that... among other things, adds a c++ project to a solution.

I have a problem with adding c++ projects to solutions that contain c# or vb.net projects (I'll refer to these solutions as dot net solutions).

I am sure you have all done this - without envdte automation.

Add a c++ project (with supported platforms Win32 and x64), to a dot net solution. Look at Configuration Manager -> since the dot net solution only has x86 and x64, the x64 configuration is correct, but in the x86 configuration you will see not Win32 for the c++ project - you will see x64 instead !!!!! Oh yeah, VS is smart enough to know that this is not going to work and does not select this configuration to build either !!!!

If you are doing this by hand, you as a developer should be smart enough to check, ok. But I am trying to build an automation to add this project - which means, the user might not be aware of this bug, will build the solution - and it will fail.

I have tried to change the platform - but it is read-only.

This is the only thing I have found so far:

SolutionConfiguration config = solution.SolutionBuild.SolutionConfigurations.Item("Debug");

string msg = "";

foreach (SolutionContext context in config.SolutionContexts)
{
  msg += context.ProjectName + context.ConfigurationName + context.PlatformName + context.ShouldBuild;
  context.ConfigurationName = "Debug";  // I can modify this but I don't want to
  if(context.PlatformName == "x64" && !context.ShouldBuild) // this must be the wrong platform
  {
    // I'd like to do that but it won't even compile
    context.PlatformName == "Win32";   // intellisense says error
    context.ShouldBuild = true;        // compiles but checkbox doesn't get set
  }
}

I have considered trying to delete an entire configuration row and add a new one - but can't find how to do that...

I found "ConfigurationManager.DeleteConfigurationRow Method" but it only deletes a "Debug" or "Release" configuration... I don't think that is what I want ?

Same with "ConfigurationManager.AddConfigurationRow Method" - there is nothing to specify platform...

Please help, thank you.

VS2010


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>