all groups > visual studio .net ide > january 2006 >
You're in the

visual studio .net ide

group:

Modify project file programmatically without add-in or macro?


Modify project file programmatically without add-in or macro? wsr NO[at]SPAM williamrakocy.com
1/21/2006 11:22:41 AM
visual studio .net ide:
Hello,

I'm wondering if it is possible to open and modify a csproj file
programmatically outside of a Visual Studio Add-in project.

I'm envisioning something to the effect of the following (simplified)
pseudo code:

VSProject proj = VSProject.LoadFromFile(pathOfProjFile);
proj.RemoveFile(oldFileName);
proj.AddFile(newFileName);
proj.Save();

Examples I've been able to turn up thus far have all been presented
within the context of an add-in project. For example:

public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
....

VSLangProj80.VSproject2 vsproject= applicationObject
..Solution.Projects.Item(1);
vsproject = (VSLangProj80.VSProject2)proj;
....
}

The project I'm working on however is not an Add-In.....

Thanks,
Bill
Re: Modify project file programmatically without add-in or macro? Carlos J. Quintero [VB MVP]
1/24/2006 12:00:00 AM
Hi Bill,

See my article:

HOWTO: Automating Visual Studio .NET from outside the IDE

http://www.mztools.com/articles/2005/MZ005.htm

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


<wsr@williamrakocy.com> escribió en el mensaje
news:1137871361.796487.289650@g44g2000cwa.googlegroups.com...
[quoted text, click to view]

Re: Modify project file programmatically without add-in or macro? wsr NO[at]SPAM williamrakocy.com
1/24/2006 5:07:20 PM
[quoted text, click to view]

Carlos,

Thanks very much for your response. The information on your link was
quite helpful, and led me to the following solution:

EnvDTE.DTE aDTE =3D
(EnvDTE.DTE)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DT=
E",
"");

aDTE.MainWindow.Visible =3D false;
aDTE.Solution.Create(@"C:\temp", "tmp_solution.sln");

Project proj =3D aDTE.Solution.AddFromFile(myProjPath, true);
folder.ProjectItems.AddFromFile(myFilePath);
proj.Save(myProjPath);

aDTE.Quit(); =20

-Bill
Re: Modify project file programmatically without add-in or macro? wsr NO[at]SPAM williamrakocy.com
1/24/2006 5:15:41 PM
[quoted text, click to view]

Carlos,

Thanks very much for your response. The information on your link was
quite helpful, and led me to the following solution:

EnvDTE.DTE aDTE =3D
(EnvDTE.DTE)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DT=
E",
"");

aDTE.MainWindow.Visible =3D false;
aDTE.Solution.Create(@"C:\temp", "tmp_solution.sln");

Project proj =3D aDTE.Solution.AddFromFile(myProjPath, true);
folder.ProjectItems.AddFromFile(myFilePath);
proj.Save(myProjPath);

aDTE.Quit(); =20

-Bill
Re: Modify project file programmatically without add-in or macro? wsr NO[at]SPAM williamrakocy.com
1/24/2006 5:16:07 PM
[quoted text, click to view]

Carlos,

Thanks very much for your response. The information on your link was
quite helpful, and led me to the following solution:

EnvDTE.DTE aDTE =3D
(EnvDTE.DTE)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DT=
E",
"");

aDTE.MainWindow.Visible =3D false;
aDTE.Solution.Create(@"C:\temp", "tmp_solution.sln");

Project proj =3D aDTE.Solution.AddFromFile(myProjPath, true);
proj.ProjectItems.AddFromFile(myFilePath);
proj.Save(myProjPath);

aDTE.Quit(); =20

-Bill
AddThis Social Bookmark Button