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 / Extensibility / May 2006

Tip: Looking for answers? Try searching our database.

Add Web Project programmatically to EFP problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shai - 07 May 2006 21:21 GMT
Hello,

As part of a source control management project for Visual Studio, when the
user creates a new solution it is structured as such:  Solution Level / ETP
Level / Project Level.

The solution contains an enterprise template that then contains the project.
One type of project that have to fit into this is Web Project .We need to be
able to add a web project to the enterprise template level via the DTE. It is
our understanding that to do so we must first create a virtual directory for
the project.
We create the virtual directory via the CreateVDir method with this function
call:

iisMan.CreateVDir(webAddress, vDirName, projPath, false, false,
    false, false, false, false, 1, "localhost")
(The code for iisMan is taken from several examples in codeproject and in
the net, if needed I can provide the code but this part is working)
When that method returns true, indicating the virtual directory has been
created, we add the web project to the enterprise template.

Uri baseUri = new Uri(webAddress);
UriBuilder projectFileUriBuilder = new UriBuilder(baseUri);
projectFileUriBuilder.Path += "/" +
projName.Substring(projName.LastIndexOf(@"\") + 1);
prjETPLevel.ProjectItems.AddFromFile(projectFileUriBuilder.Uri.ToString());

OR
    prjETPLevel.ProjectItems.AddFromFile(webProject);

We have tried assigning the variable being passed into the above method with
various different values including the absolute path of the project file
(c:\test\...\webproj.cproj), the URL of the web project
(http://localhost/.../webproj) and just the name of the web project
(webproj). All of these attempts had the same result. Each raised an
“Unspecified Error”.

What is it that we need to pass to the AddFile method and can you shed any
light on the error we are getting?

TIA
Shai
"Gary Chang[MSFT]" - 08 May 2006 11:35 GMT
Hi Shai,

AddFromFile is not designed for add a virtual directory's URL to the
project. Usually we use the AddFromTemplate Method to add a new project to
a VS.NET solution.

Is it possible for you to add the web project file one by one via the
AddFromFile method?

Thanks!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Shai - 08 May 2006 13:52 GMT
Hi Gary !
I used addfromfile since it working for all other project type.
What i'm looking for a  way to do "AddExistingProjectFromWeb" since the
project exist .
What will be the best programmatically way to add existing WebProject to a
solution ?

TIA
Shai

> Hi Shai,
>
[quoted text clipped - 16 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 09 May 2006 07:55 GMT
Hi Shai,

To add an existing web project into a VS2003 solution, you can use the
following one:

soln.AddFromTemplate("C:\Inetpub\wwwroot\DemoWebApplication\DemoWebApplicati
on.csproj", "http:\\localhost\NewWebApplication\", "NewWebApplication",
False)

The \NewWebApplication is the target virtual directory for the added web
project.

Thanks!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Shai - 10 May 2006 06:47 GMT
Hi Gary !

We tried what you answered , but In trying to add web projects to the
enterprise template level of our solution, we are still experiencing the same
issue. Please note, we are not trying to add it to the solution level itself.
Therefore, we cannot use soln.AddFromTemplate, we need to use
prjETP.ProjectItems.AddFromTemplate, not that I know it makes a difference.
We attempted to adapt the answer we received to our problem by using

    prjFramework.ProjectItems.AddFromTemplate(templatePath, projName);

“templatepath” is the full path of the web project’s template. “projName” is
name of the project, not the entire URL, although we did try that as well.
Even this way it still returned an “Unspecified Error”.

Another issue is that one of the reasons we were using AddFromFile is that
we need to add existing web projects as well as new ones. Using
AddFromTemplate we can only add new web projects.

Again we work in vs.net 2003.

TIA
Shai

> Hi Shai,
>
[quoted text clipped - 19 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 11 May 2006 09:32 GMT
Hi Shai,

The ProjectItems.AddFromTemplate seems not work with a web project, it
cound not be used to specify a vdir URL.

We will perform research on this issue and will get back to you as soon as
possible. I appreciate your patience.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 15 May 2006 06:39 GMT
Hi Shai,

I consulted this problem with our product team, it appears there is no
general convention to add an existing web project to a projectitem object.
If I get any other workaround for the issue, we will update you.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Shai - 15 May 2006 23:44 GMT
Hi Gary !
It is possible to do so via IDE , so it should be possible via
programmatically way too.
If you file/new/project the in new project dialog select from
Other projects/ETP/Visual C# Distributed Application for example. it create
a solution with ETP projects Hirarchy.
If you go to WebUIProjects node and add/Existing project from web select URL
and then .csproj . Its work fine.
So how come there is no programmatically way to do it ?

TIA
Shai

> Hi Shai,
>
[quoted text clipped - 13 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 18 May 2006 07:40 GMT
Hi Shai,

One of the product team engineers replied me the ProjectItems.AddFromFile
would work by passing by passing the URL of the web project as the FileName
parameter.  However it appears not work in my side. Except that method,
currently we haven't found another approach to this problem.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 25 May 2006 23:00 GMT
Hi Shai,

The "Add Existing Project From Web" menu item, corresponds to the
guidVSStd97:cmdidAddExistingProjFromWeb, which unfortunately wasn't
designed to accept additional arguments. Consquently, any attempt to invoke
this command, will invoke the dialog. There are no other interfaces short
of possibly the IVsProject::AddItem interface, that would allow programatic
access to do this. And accessing IVsProject::AddItem would require
access/dependencies on the VSIP Extras interop assemblies, and you'd have
to have code to programatically traverse the hierarchy to find the
appropriate hierarchy item in which to invoke the AddItem method on.

This is purely theoretical, as I've never seen anyone write a project
wizard that directly accessed the VSIP interfaces to do something like
this. And this would probably require a custom IDTWizard, as I suspect you
cannot get access to the VSIP interfaces from a jscript/vsz based wizard.

I did notice that the "Add Existing Project From Web" isn't displayed
unless I right click on the Project node. Clicking on the WebUI node,
doesn't enable this command. This basically means that the underlying
project hierarchy doesn't support nesting of additional projects off the
WebUI node.

I was however, able to programatically add an existing web project to the
Project node, by way of a simple addin that did something along the lines
of the following:

  Project proj = applicationObject.Solution.Projects.Item(1);
 
proj.ProjectItems.AddFromFile("c:\\Inetpub\\wwwroot\\MyWebService\\MyWebServ
ice.csproj");

I'm fairly confident the same can be done by way of your project wizard.
I'm not sure if this is exactly what your looking for, but it seemed to
work for me when testing against a Wizard generated Simple Disitributed C#
project.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.

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.