Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / January 2006

Tip: Looking for answers? Try searching our database.

Modify project file programmatically without add-in or macro?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wsr@williamrakocy.com - 21 Jan 2006 19:22 GMT
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
Carlos J. Quintero [VB MVP] - 24 Jan 2006 12:25 GMT
Hi Bill,

See my article:

     HOWTO: Automating Visual Studio .NET from outside the IDE

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

Signature

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

> Hello,
>
[quoted text clipped - 28 lines]
> Thanks,
> Bill
wsr@williamrakocy.com - 25 Jan 2006 01:07 GMT
> Hi Bill,
>
[quoted text clipped - 46 lines]
> > Thanks,
> > Bill

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 =
(EnvDTE.DTE)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE",
"");

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

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

aDTE.Quit();  

-Bill
wsr@williamrakocy.com - 25 Jan 2006 01:15 GMT
> Hi Bill,
>
[quoted text clipped - 46 lines]
> > Thanks,
> > Bill

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 =
(EnvDTE.DTE)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE",
"");

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

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

aDTE.Quit();  

-Bill
wsr@williamrakocy.com - 25 Jan 2006 01:16 GMT
> Hi Bill,
>
[quoted text clipped - 46 lines]
> > Thanks,
> > Bill

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 =
(EnvDTE.DTE)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE",
"");

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

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

aDTE.Quit();  

-Bill

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.