Tuesday, May 02, 2006 2:03 PM
I'm working on an automation project that does a bunch of work with a DTE Project, and for the most part, the DTE Project exposes everything I need....
Except for the "internal" settings of the project file itself, ie - the info contained within:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
.... blah blah blah...
On the other hand, instantiating an MSBuild Project allows me to go after and play with all the underlying goodness using the GetEvaluatedProperty() and SetProperty() methods.
My dilemna is trying to save any changes I made via the MSBuild project - as you would expect, the VS IDE advises me that something (ie: the MSBuild Project) has changed my project outside the environment, and "would I like to reload"? This is causing havoc on my automation logic.
Is there a way I can manipulate the data within this property group (using MSBuild or other) without having the IDE get upset (ie: can I somehow effect the change using the DTE.Project?)
Following is some sample code:
private void PlayWithProjectStuff(EnvDTE.Project dteProject)
//Some hard code to get us going...
Microsoft.Build.BuildEngine.Engine.GlobalEngine.BinPath = @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727";
Microsoft.Build.BuildEngine.Project msBuildProject =
string data = msBuildProject.GetEvaluatedProperty("Something");
//also works great..
-- TIA for any help.
Tuesday, May 02, 2006 5:20 PM
I am guessing that you are manipulating existing project types using the automation model. In this case the MsBuild API is not available to you when working with the automation model. Trying to load the project in a separate msbuild project object in order to manipulate it is not recommended. Whenever you save the project file outside VS you will get prompted to reload the modified project file. That behaviour can not be changed.
If you are manipulating C#/VB and J# projects you might find what you need in the VSProject Object model which is a language specific object that you can acces through the Project.Object Property.
You can find reference documentation on MSDN for the core project automation model using this link:
Monday, July 30, 2012 9:29 AMI've a problem which is when compiling the solution with VS, every thing is OK. But when compiling with MSBuild, this line of code returns NULL value:
static DTE Dte;
Dte = serviceProvider.GetService(typeof(SDTE)) as DTE;
How can I solve this?
please, contact me at: email@example.com
thanks in advace.
- Edited by DrMAF Monday, July 30, 2012 9:29 AM