Deploy PDB files into production to ease exception report investigation.

 

 For a long time I believed that PDB as a part of debugging information should not be included in production deployment. Recently my colleague suggested to copy them to simplify exception investigations. 

 

The following  SO discussion convinced us that it is a good idea  ( at least for web sites).

 http://stackoverflow.com/questions/933883/are-there-any-security-issues-leaving-the-pdb-debug-files-on-the-live-servers

    These files will not be exposed to the public if kept in the right places (websitebin). 

 
 So we decided to deploy the PDBs into production.
 

BTW, if you include PDBs with your deployments, you don’t need to store them in a symbol server,

 as it is suggested in http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx

However we found that  PDBs   were generated not for all DLLs.  After some analysis we believe that MS changed default settings starting from VS 2008 (or may be since VS 2005) and make generation of PDB-only even for release mode. This is why older projects had generation of PDBs disabled.

To change setting in Visual Studio there is an option in the “Project Properties”, “Build”, “Advanced…”.

Change “Debug Info:” to PDB-only.

The screenshots are available in the posthttp://callicode.com/Homeltpagegt/tabid/38/EntryId/24/How-to-disable-pdb-generation-in-Visual-Studio-2008.aspx

 

Related links:
The article http://blog.vuscode.com/malovicn/archive/2007/08/05/releasing-the-build.aspx compares different options for debug and release and confirms that in 2007 pdbonly was the default for release configuration of visual studio   
              

/optimize+ /debug:pdbonly (release configuration of visual studio)

The article Include .pdb files in Web Application Publish for Release mode (VS2012)  wasn’t applicable for us, but may be useful for someone else.

Using CTT to modify config files for different environments

We previously tried to use msbuild to adjust configuration files for different environments.

Recently I found

C
onfig Transformation Tool(CTT) on CodePlex

and with

addition of global replace using powershell

it is enough and easier to do all required modifications




Content of ChangeConfig.cmd:

ctt s:..web.config t:WebConfig.CTT d:..web.config

powershell.exe -command “Get-Content ..Remoting.config | ForEach-Object { $_ -replace ‘//localhost/ServicesCI/’, ‘//ServerName01/ServicesCI/’ } | Set-Content ..remoting.temp”

powershell.exe -command “copy  ..remoting.temp ..remoting.config”

ctt s:..EnterpriseLibraryLogging.config t:EnterpriseLibraryLogging.CTT d:..EnterpriseLibraryLogging.config

@goto end

@rem some code that currently not used

:End

@pause







Content of example
WebConfig.CTT
:




<?
xml
version=”1.0″?>
<

configuration
xmlns:xdt=”http://schemas.microsoft.com/XML-Document-Transform”>
<

appSettings
>
<

add
key=”ShowDeveloperExceptionInfo” value=”False” xdt:Transform=”Replace”  xdt:Locator=”Match(key)” />
</

appSettings
>
<

system.diagnostics
>
<

sharedListeners
>
<

add
name=”ServiceModelMessageLoggingListener” initializeData=”C:temptestCIcopy2.svclog”   xdt:Locator=”Match(name)” xdt:Transform=”SetAttributes(initializeData)”   />
</

sharedListeners
>
</

system.diagnostics
>
</

configuration
>




Extract from web.config –
sharedListeners section






 <
sharedListeners
>
       <

add
initializeData=”C:tempTEST.svclog” type=”System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ name=”ServiceModelMessageLoggingListener” traceOutputOptions=”Timestamp”>
       <

filter
type=”” />

     </
add
>
   </

sharedListeners
>v

MSbuild Task FileUpdate to replace content in text files

I wanted to replace some strings in files using my deployment MSbuild script.

I’ve noticed that MSBuild Community Tasks Project has RegexReplace task.

But when I’ve looked in documentation 

(By the way, it will be good if Reference help will be available online, not only from download)

I’ve realized that the task is applicable for strings(e.g file names) not to content within a file.

Almost accidently in one of the posts i’ve found a reference to FileUpdate
task, that support Regex and does content replacements within a file.

The following examle (from downloaded help) search for a version number and update the revision.

   
            <FileUpdate Files="version.txt"
                Regex="(d+).(d+).(d+).(d+)"
                ReplacementText="$1.$2.$3.123" />

Note: don’t forget to insert in to your project

<MSBuildCommunityTasksPath>.</MSBuildCommunityTasksPath>
<Import Project=”MSBuild.Community.Tasks.Targets”/>

You may require to change MSBuildCommunityTasksPath if it is not in current directory.

EntitySpaces API: How to get esQueryItem column name.

In constructor columnName is passed as parameter.

public esQueryItem (
	esDynamicQuery query,
	string columnName
)
However I wasn't able to fint the property ColumnName or something similar.
After some time I understood, that they use implicit operator string
public static implicit operator string  (
	esQueryItem item
)
which does the magic.
However  the explicit read-Only property ColumnName will be useful.

By the way the help shows 2 different operators as the same
static member Implicit(esQueryItem)
ToString() (to use in GroupBy/OrderBy and such ....)

static member Implicit(esQueryItem)
ToString() (to use in GroupBy/OrderBy and such ....)

Error in WEBCA_SetTARGETSITE during installation of Web Setup Project on Vista.

I have a MSI package created using Visual Studio 2005 Web Setup Project on Windows 2003 Server.


When I tried to install it on Vista(home premium) with IIS7 installed, the setup failed with


Action ended: WEBCA_SetTARGETSITE. Return value 3.


Fortunately, when I’ve  installed  the optional “IIS 6 Management Compatibility” option within IIS7, the installation succeeded.

Update appSettings in App.Config for executable.

I wanted programmatically (for administrator) to update configuration settings for .Net 2.0 executable.
The new  in VS 2005 Properties.Settings class saves only user-scope settings, not application scope, which is inconvinient.

I’ve decided to use The easiest way to read/write AppSettings   from the very good article Read/Write App.config with .NET 2.0/Enterprise Library   However I noticed two issues:

 config.AppSettings.Settings (KeyValueConfigurationCollection class) has Add and Remove methods, but does not have Set method, so I had to create static helper function:
        public static void Set(KeyValueConfigurationCollection settings, string key, string value)
        {

            if (settings[key] != null)

            {

                settings.Remove(key);

            }

            settings.Add(key, value);

        }

 

Also if the appSettings element uses the File attribute,

config.Save() for executable updates the main file, not specified in File attribute “appSettings” section.So if the value is stored in the referenced file, saving “appSettings” to the main file has no effect.

 

Invoke Executable as custom action during Install.

I’ve used MS Installer class to provide custom  actions during setup in a few projects(e.g.see Using VS 2005 Web Setup Project with custom actions).
However if you have some complex logic to do as a part of setup, it is possible that some exception will occur.
I don’t like to hide exceptions, and they are shown to the user,causing installation to rollback.
It is not good, becuse sometimes user wants to ignore exception and use installation even if some custom action failed.
I found that moving code from custom action to executable gives more flexibility,as well as allow to use the same program to customize installation later just by running the same exe.
The Visual Studio SetupProject allowes to specify Custom Action as executable,not as Installer Class.
However during Uninstall,Repair etc, Executable Custom Action can be invoke not as programmer initially designed,and it is required to specify conditions for custom actions. Unfortunately, I had a lot of problems trying to set correct conditions(see Custom action condition to run for a new or upgraded product.and Intermittent execution of custom action for installation of product upgrade. )


To avoid these problems with  Executable Custom Action I desided to return back to Installer Class Custom action, but in Install method the only task is to start  executable and executable will do all required customization of installation.
You can see the code of the class here.