Can you exclude code automatically when using the publish feature in Visual Studio

Posted by LarryDev on Stack Overflow See other posts from Stack Overflow or by LarryDev
Published on 2010-04-22T14:35:14Z Indexed on 2010/04/22 14:43 UTC
Read the original article Hit count: 377

Filed under:
|
|

Is their a way to exclude a block of code when you use the publish feature in visual studio. In other words say I had a log in button that did something like:

// Start Exclude when publishing
if (txtUserName.Text == "" && txtPassword.Password == "")
{             
  lp = new System.ServiceModel.DomainServices.Client.ApplicationServices.LoginParameters("UserName", "Password");
}
else
// Stop Exclude when publishing
{
  lp = new System.ServiceModel.DomainServices.Client.ApplicationServices.LoginParameters(txtUserName.Text, txtPassword.Password);
}

This way when I am debugging I can just leave the username and password field blank and just click login and the application will log me on. But when the application is published the compiler woudl ignore that code and not compile it in to the application.

© Stack Overflow or respective owner

Related posts about visual-studio

Related posts about compiler