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 / January 2006

Tip: Looking for answers? Try searching our database.

how to add existing web site into solution

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zafer Orenlili - 28 Dec 2005 13:53 GMT
Hello,

I am try to add localhost web site to current solution. I am writing VS 2005 addin project. My web site doesnt contains a project
file, only a folder. Manually add existing web site, working fine.

How to add programmically?

Project proj = _dte.Solution.AddFromFile("http://localhost/WebSite1/", false);
doesnt work.

Please help.

Thanks
Steven Cheng[MSFT] - 29 Dec 2005 06:14 GMT
Hi Zafer,

Welcome to MSDN newsgroup.
As for the Adding Website (project) into VS2005 solution, we can not use
the AddFromFile method of the ENVDTE.Solution class. Because the ASP.NET
2.0 project for vs2005 is projectless( no project file).   To add website
application, we need to use the AddFromTemplate method, the first parameter
present the ProjectTemplate file,  we can use the
Solution.GetProjectTemplate method to get the vstemplate file for website
application.  For example:

===============
Sub AddWebSite()

       Dim dte2 As EnvDTE80.DTE2
       Dim sln2 As Solution2
       Dim proj As EnvDTE.Project

       Dim tmpFile As String

       dte2 = DTE
       sln2 = dte2.Solution

       tmpFile = sln2.GetProjectTemplate("WebApplication.zip", "Web")

       proj = sln2.AddFromTemplate(tmpFile,
"C:\users\stcheng\workspace\Whidbey\WebSites\DemoSite", "DemoSite", False)

       MsgBox("done")

   End Sub
==============================

#you can find those projects template files under vs2005 program folder,
e.g:

C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\ProjectTemplates\Web\CSharp\1033

Also, when adding an existing webproject, calling the AddFromTemplate will
popup dialog to ask for creating new or open existing project, choose open
existing one to add the existing project into current solution......

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Zafer Orenlili" <zaferorenlili@hotmail.com>
| Subject: how to add existing web site into solution
[quoted text clipped - 25 lines]
|
| Thanks
Zafer Orenlili - 29 Dec 2005 15:00 GMT
Thank You!

I will always use the existing web project option so is it possible to prevent popup dialog from being shown?

Regards,
Zafer
Steven Cheng[MSFT] - 30 Dec 2005 09:54 GMT
Thanks for your response Zafer,

As for suppress the popup dialog, IMO it will be hard to do that since the
steps are determined by the vstemplate and that template is used for both
creating and add existing one....   Anyway, I'll consult some other VS IDE
experts to see whether there is any other means to achieve this...  I'll
update you as soon as possible.

Thanks for your patience,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Zafer Orenlili" <zaferorenlili@hotmail.com>
| References: <uXHeGX7CGHA.1312@TK2MSFTNGP09.phx.gbl>
<q1#108DDGHA.832@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: how to add existing web site into solution
| Date: Thu, 29 Dec 2005 17:00:08 +0200
[quoted text clipped - 17 lines]
| Regards,
| Zafer
Steven Cheng[MSFT] - 04 Jan 2006 02:32 GMT
Hi Zafer,

I've got the answer for your question from our VS IDE developers, here is
the updated AddWEbSite and RemoveWebSite method:

===================================
Sub AddWebSite()
       Dim dte2 As EnvDTE80.DTE2
       Dim sln2 As Solution2
       Dim proj As EnvDTE.Project
       Dim tmpFile As String
       Dim webPackage As VsWebSite.VSWebPackage
       Dim webSites As Projects

       Dim sitepath As String =
"http://localhost/StevenRoot/Whidbey/WebSites/IISSite/"

       dte2 = DTE
       sln2 = dte2.Solution
       webPackage = dte2.GetObject("WebPackage")

       proj = webPackage.OpenWebSite(sitepath,
VsWebSite.OpenWebsiteOptions.OpenWebsiteOption_None, True)
       

       MsgBox("done")

   End Sub

   Sub RemoveWebSite()
     

       Dim dte2 As EnvDTE80.DTE2
       Dim sln2 As Solution2
       Dim proj As EnvDTE.Project
       Dim tmpFile As String
       Dim webPackage As VsWebSite.VSWebPackage
       Dim webSites As Projects

       Dim sitepath As String =
"http://localhost/StevenRoot/Whidbey/WebSites/IISSite/"

       dte2 = DTE
       sln2 = dte2.Solution
       webPackage = dte2.GetObject("WebPackage")

       webSites = dte2.GetObject("WebSites")

       proj = webSites.Item(sitepath)

       sln2.Remove(proj)

       MsgBox("done")
   End Sub
==================================

Also, to use the WebSite related object and collection, you need to add a
reference to the following assembly to have access to the VsWebSite
namespace:

C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\PublicAssemblies\VsWebSite.Interop.dll

You can easily add the reference through VS 2005's Macro IDE....

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| X-Tomcat-ID: 161027794
| References: <uXHeGX7CGHA.1312@TK2MSFTNGP09.phx.gbl>
<q1#108DDGHA.832@TK2MSFTNGXA02.phx.gbl>
<OSAFugIDGHA.2300@TK2MSFTNGP15.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
[quoted text clipped - 54 lines]
| | Regards,
| | Zafer
Zafer Orenlili - 04 Jan 2006 11:17 GMT
Thank You.

Regards,
Zafer

> Hi Zafer,
>
[quoted text clipped - 133 lines]
> | | Regards,
> | | Zafer
Steven Cheng[MSFT] - 04 Jan 2006 12:06 GMT
You're welcome Zafer,

Feel free to post here when you need our assistance :)

Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Zafer Orenlili" <zaferorenlili@hotmail.com>
| References: <uXHeGX7CGHA.1312@TK2MSFTNGP09.phx.gbl>
<q1#108DDGHA.832@TK2MSFTNGXA02.phx.gbl>
<OSAFugIDGHA.2300@TK2MSFTNGP15.phx.gbl>
<$balXcSDGHA.1240@TK2MSFTNGXA02.phx.gbl>
<crdthcNEGHA.1240@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: how to add existing web site into solution
| Date: Wed, 4 Jan 2006 13:17:33 +0200
[quoted text clipped - 8 lines]
| NNTP-Posting-Host: host-62-244-194-241.borusantelekom.com 62.244.194.241
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP0
9.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.vstudio.extensibility:3617
| X-Tomcat-NG: microsoft.public.vstudio.extensibility
[quoted text clipped - 141 lines]
| > | | Regards,
| > | | Zafer

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.