Wednesday, August 22, 2018

Web.config Transform (Visual Studio)



Introduction:

Sometimes, you may encounter a situation that you want your web.config of staging server to be different with the web.config of production server. For example, the connection string of staging server should be different from that of production server (one is for test database, and one is for client database).  

How to create our own transform web.config?

Note: Originally, VS create “Debug” and “Release” configuration for us.

If we want to create our own configuration, select “VS -> Build -> Configuration Manage”.

Then you can see the following picture to create a new configuration.

After creating our customized configuration, on Solution Explorer right click on the web.config, then click “Add Config Transform”.


Then, you can see the one we created has been shown.

How to know the difference through using different transform config?


As default, VS will create “Debug” and “Release” configuration for us. We can use those to be example to declare this question. We found there is only one-line difference between Debug and Release.

<compilation xdt:Transform="RemoveAttributes(debug)" />

From above instruction, we assume that on “Release” build we want to delete the debug attributes.

On Solution Employer, we can right click our project and select Publish…

Then select Folder option.

Then go the file path “source/repos/ConfigTransform/ConfigTransform/bin/Release/PublishOutput” to check the transform web.config.

"Release" version of web.config as shown as following picture.


On the other hand, we want to change the build configuration to “Debug”.
Go to Publish page, click Settings…


And change Configuration to Debug.

Then you can notice that the web.config has been changed! The Debug version contains debug information.


Conclusion:

According above, we can use web.config transform to define the different setting between staging server and production server.

Thursday, August 16, 2018

tmux (session tool)


Introduction


The tool can help to reattach the losing sessions. It is really useful if your network connection is unstable. You can attach the losing session and keep working. In addition, it enables users to control window panes through keyboard.

Installation (Linux):

sudo apt-get update
sudo apt-get install tmux
tmux -V

To start:

In:
tmux new (it will use number to name the session)
tmux new -s name-of-session

Out:
exit
Prefix + d

Commands:


Note: all commands need a prefix  
Default prefix: 
                       ctrl + b

Session

Attach

 tmux a -t number-of-session
 tmux a -t name-of-session

Kill

 tmux kill-session -t number-of-session

List   

 tmux ls

Windows

New: 
  Prefix + c
Kill:  
  Prefix + ,
Moving:
                        Prefix + p
                        Prefix + n
                        Prefix + Number

Panes


New:
  Horizontally:
prefix + “
  Vertically:
prefix + %
Kill:
                        Prefix + x
Moving:
                        Prefix + up|down|left|right
                        Prefix + o

How to customize it?

The keyboard combination of prefix seems to be not that user friendly. If we can change it to something else, that will be really appreciated.

First, we need to create a tmux configuration file.
    vim ~/.tmux.conf

Copy the following instructions into that file.
    unbind c-b
    set -g prefix C-a
    bind C-a send-prefix

The above instructions mean that we change prefix from ctrl + b to ctrl + a.


Reload Config

tmux source-file ~/.tmux.conf