How to regenerate T4 templates from command prompt?

I am using T4 templates for web.config templating for different environments (development, production). You can regenerate templates from Visual Studio, but what if you want to regenerate all of them from console. It is very useful if you had some mass change in all your web.tt (in different projects) and now need to regenerate corresponding web.config-s.

Here is a little batch script that can help you to do this:

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

:: set the working dir (default to current dir)
set wdir=%cd%
if not (%1)==() set wdir=%1

echo executing transform_all from %wdir%
:: create a list of all the T4 templates in the working dir
dir %wdir%\web*.tt /b /s > t4list.txt

echo the following T4 templates will be transformed:
type t4list.txt

:: transform all the templates
for /f %%d in (t4list.txt) do (
  set configfile=%%d
  set configfile=!configfile:~0,-3!.config
  echo:  \--^> !configfile!
  "%CommonProgramFiles%\Microsoft Shared\TextTemplating\1.2\TextTransform.exe" -out !configfile! %%d
)

echo transformation complete
Friday, August 06, 2010 | Add Comment

How to control your iPhone remotely?

Remote control of your iPhone might be very useful for testing iPhone friendly web sites. You can use emulators for this purpose. Blackboud iPhone Browser Simulator is not bad, but still this is not a real iPhone browser.

First of all you iPhone needs to be jailbroken. Then you need to install VNC Server for iPhone. Just search for Veency in Cydia, it is free.

On you desktop you need VNC Viewer. There are bunch of them, but I use UltraVNC since it is free. Then you can connect to your iPhone over Wi-Fi, but you can do it thru USB too.

For USB connection you need to install python interpreter and usbmuxd. From usbmuxd we need only python client part. Run connect.bat, which has following line inside:

c:\python26\python.exe tcprelay.py 5900

And then you can connect to your iPhone using 127.0.0.1 address.

iPhone remote view

Friday, July 09, 2010 | Add Comment

How to fix ViewStateException Invalid ViewState?

Usually you don't see Invalid ViewState exception unless you implement some kind of ASP.NET error logger in Global.asax.

Error usually states something like this:

Exception: System.Web.HttpException: The state information is invalid for this page and might be corrupted. ---> System.Web.UI.ViewStateException: Invalid viewstate.

Those errors are usually generated by some automatic submission form engines. Comments and contact forms are mostly effected by this exception. End user never sees those errors, so invalid viewstate errors don't have any value for your error logger. Let's bypass them:

if (ex is HttpException && ex.InnerException is ViewStateException)
{
    _app.Response.Redirect(_app.Request.Url.AbsoluteUri)                
    return
}

See my error logger article for further details.
Wednesday, June 23, 2010 | Comments (2) | Add Comment

Categories

Recent Tweets

  • Creating a Microsoft .NET Compact Framework-based Animation Control http://t.co/P92rCZ4
  • Now you can jailbrake your iphone from browser: http://bit.ly/91Nm7S. It is legal, but voids your iPhone warranty.
  • iPhone jailbreaking and Android rooting get DMCA exemption http://bit.ly/bCmEEA
  • Here is excellent tool for development of JQuery scripts, it is called jsshell: http://bit.ly/72wsQz. It is Google Chrome extension.

Valid XHTML 1.0 Transitional