VSProject2.CopyProject Method
Copies some or all of a Web project to a new location.
Namespace: VSLangProj80
Assembly: VSLangProj80 (in VSLangProj80.dll)
Syntax
'Declaration
Sub CopyProject ( _
bstrDestFolder As String, _
bstrDestUNCPath As String, _
copyProjectOption As prjCopyProjectOption, _
bstrUsername As String, _
bstrPassword As String _
)
void CopyProject(
string bstrDestFolder,
string bstrDestUNCPath,
prjCopyProjectOption copyProjectOption,
string bstrUsername,
string bstrPassword
)
void CopyProject(
[InAttribute] String^ bstrDestFolder,
[InAttribute] String^ bstrDestUNCPath,
[InAttribute] prjCopyProjectOption copyProjectOption,
[InAttribute] String^ bstrUsername,
[InAttribute] String^ bstrPassword
)
abstract CopyProject :
bstrDestFolder:string *
bstrDestUNCPath:string *
copyProjectOption:prjCopyProjectOption *
bstrUsername:string *
bstrPassword:string -> unit
function CopyProject(
bstrDestFolder : String,
bstrDestUNCPath : String,
copyProjectOption : prjCopyProjectOption,
bstrUsername : String,
bstrPassword : String
)
Parameters
- bstrDestFolder
Type: System.String
Required. The destination folder for the new project. The folder is created if it does not exist. This string takes the form, https://ServerName/CopyName/.
- bstrDestUNCPath
Type: System.String
Required. The UNC path for file-sharing if the project to be copied is using file-share access. Use the empty string if the project is using FrontPage Server Extensions access.
- copyProjectOption
Type: VSLangProj.prjCopyProjectOption
Required. A prjCopyProjectOption value that determines which project files are copied — all files, all project files, or only files needed to run the application.
- bstrUsername
Type: System.String
Required. The user's network login ID.
- bstrPassword
Type: System.String
Required. The user's password.
Implements
VSProject.CopyProject(String, String, prjCopyProjectOption, String, String)
Remarks
This method, used to copy Web projects, provides more functionality than a simple xcopy of the project files, but less functionality than deployment. The CopyProject method makes the appropriate changes to IIS and the project folder on the Web server, so that development can continue as usual on the project. Deployment provides more features for setting up a Web, including creating databases and message queues.
This method copies only Web projects. Web projects are projects created from the ASP.NET Web application, XML Web Service, and Empty Web Project templates in the New Project dialog box. If the project is a local project, an exception is raised.
If the destination folders or files already exist, they are overwritten.
Examples
This example copies the first project in the solution, as long as it is a Visual Basic or Visual C# project. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.
[Visual Basic]
' Add-in code.
' Copies the first project in the solution.
' This procedure could fail if the first project is not a Visual Basic,
' or Visual C# project, or if the project is not a Web
' application.
Imports VSLangProj
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
applicationObject = CType(application, DTE2)
addInInstance = CType(addInInst, AddIn)
CopyWeb(applicationObject)
End Sub
Public Sub CopyWeb(ByVal dte As DTE2)
Try
Dim proj As VSProject2 = _
CType(applicationObject.Solution.Projects.Item(1).Object, _
VSProject2)
proj.CopyProject("https://Localhost/Copy_of_Project", "", _
prjCopyProjectOption.prjRunFiles, "", "")
Catch ex As System.Exception
MsgBox("Cannot copy Web project.")
End Try
End Sub
[C#]
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application, ext_ConnectMode
connectMode, object addInInst, ref Array custom)
{
applicationObject = (DTE2)application;
addInInstance = (AddIn)addInInst;
CopyWeb((DTE2)applicationObject);
}
public void CopyWeb( DTE2 dte ) {
try {
VSProject2 proj = ( ( VSProject2 )
(applicationObject.Solution.Projects.Item( 1 ).Object ) );
proj.CopyProject( "https://Localhost/Copy_of_Project", "",
prjCopyProjectOption.prjRunFiles, "", "" );
}
catch ( System.Exception ex ) {
MessageBox.Show(ex.ToString());
MessageBox.Show( "Cannot copy Web project.");
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.