Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

2012-07-13

Compile OpenSSL with Visual Studio 2010


Download Perl, nasm, source OpenSSL -> chỉnh lại path trong file bat (copy trong link trên)

@rem @echo off
@cls

@rem 1. Download and unzip Netwide Assembler (http://nasm.us/) to some folder
@rem 2. Download and uzip Strawberry Perl (http://strawberryperl.com/)
@rem    or ActivePerl (http://www.activestate.com/activeperl/downloads)
@rem 3. Download and uzip (xxx.tar.gz) latest version of OpenSSL (http://www.openssl.org/)

@rem NOTE: For more info, please read INSTALL.W32 file in OpenSSL folder

@rem ***************************************************************
@rem Setup paths
@rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@set strPathNetwideAssembler=D:\workspace\nasm-2.09.10
@set strPathStrawberryPerl=D:\workspace\strawberry
@set strPathActivePerl=D:\workspace\Perl64\bin
@rem set strPathActivePerl=D:\workspace\Perl64\bin
@set strPathOpenSSLDir=D:
@set strPathOpenSSL=%strPathOpenSSLDir%\download\openssl-1.0.1c
@set strPathTargetOpenSSLDir=D:\workspace\openssl-1.0.1c
@set bEnableStaticEngine=True
@rem True -> the shared library build will compile the engines into libeay32.dll
@rem ***************************************************************

@IF NOT "%strPathNetwideAssembler%" == "" set PATH=%strPathNetwideAssembler%;%PATH%
@IF NOT "%strPathStrawberryPerl%" == "" set PATH=%strPathStrawberryPerl%\c\bin;

%strPathStrawberryPerl%\perl\site\bin;%strPathStrawberryPerl%\perl\bin;%PATH%
@IF NOT "%strPathActivePerl%" == "" set PATH=%strPathActivePerl%;%PATH%
@set strEnableStaticEngine=
@IF "%bEnableStaticEngine%"=="True" set strEnableStaticEngine=enable-static-engine

@rem START

@rem Create OpenSSL installation dir
@rmdir /S /Q %strPathTargetOpenSSLDir%
@mkdir %strPathTargetOpenSSLDir%
@echo OpenSSL will be installed into %strPathTargetOpenSSLDir%

@%strPathOpenSSLDir%
@cd %strPathOpenSSL%

@IF NOT "%strPathNetwideAssembler%" == "" call :ConfigureMakefileWithASM
@IF "%strPathNetwideAssembler%" == ""     call :ConfigureMakefileWithoutASM

@if "%VS100COMNTOOLS%" == "" goto ErrorNoVS2010
@call "%VS100COMNTOOLS%vsvars32.bat"

@cls
@echo ***************************************************************
@echo Compile OpenSSL
@echo ***************************************************************
@pause
@nmake -f ms\ntdll.mak
@echo ***************************************************************
@echo Compile OpenSSL DONE
@echo ***************************************************************
@echo .
@echo ***************************************************************
@echo Test OpenSSL
@echo ***************************************************************
@pause
@nmake -f ms\ntdll.mak test
@echo ***************************************************************
@echo Test OpenSSL DONE
@echo ***************************************************************
@echo .
@echo ***************************************************************
@echo install OpenSSL to the specified location (%strPathTargetOpenSSLDir%)
@echo ***************************************************************
@pause
@nmake -f ms\ntdll.mak install
@echo ***************************************************************
@echo install OpenSSL to %strPathTargetOpenSSLDir% DONE
@echo ***************************************************************
@pause

goto EOF



:ConfigureMakefileWithoutASM
@rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@rem Configure with platform VC-WIN32 but without Assembler and Build Makefiles
@rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@echo ***************************************************************
@echo Configure with platform VC-WIN32 but without Assembler
@echo ***************************************************************
@perl Configure VC-WIN32 no-asm %strEnableStaticEngine% --prefix=%strPathTargetOpenSSLDir%
@echo ***************************************************************
@echo Configure with platform VC-WIN32 but without Assembler. DONE
@echo ***************************************************************
@echo .
@echo ***************************************************************
@echo Build the Makefiles
@echo ***************************************************************
@call ms\do_ms.bat
@echo ***************************************************************
@echo Build the Makefiles DONE
@echo ***************************************************************
@pause
@cls
goto EOF

:ConfigureMakefileWithASM
@rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@rem Configure with platform VC-WIN32 and with Assembler, and Build Makefiles
@rem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@echo ***************************************************************
@echo Configure with platform VC-WIN32 and Assembler
@echo ***************************************************************
perl Configure VC-WIN32 %strEnableStaticEngine% --prefix=%strPathTargetOpenSSLDir%
@echo ***************************************************************
@echo Configure with platform VC-WIN32 and Assembler. DONE
@echo ***************************************************************
@echo .
@echo ***************************************************************
@echo Build the Makefiles and optionally the assembly language files:
@echo ***************************************************************
@call ms\do_nasm.bat
@echo ***************************************************************
@echo Build the Makefiles DONE
@echo ***************************************************************
@pause
@cls
goto EOF

rem Errors
rem ***********************************************************
:ErrorNoVS2010
echo Visual Studio 2010 is not installed on your computer. Please install it and run this file again.
goto EOF

:EOF

2012-02-14

Multiple output files from a T4 template

Lâu ngày ngồi modify lại T4 template của Subsonic. Thật ra là mình dùng cái template đó rồi modify lại để generate DTO, chứ không dùng Subsonic.

Nhìn thấy rối quá, thật ra lúc trước lười search. Search ra multiple output file solution của Damien Guard ở đây Multiple outputs from T4 made easy.
Latest source available at GitHub
Giờ thì sẽ chỉnh lại những template đang có.

Note: file T4 bắt buộc sinh ra ít nhất 1 file, vì vậy thay vì output extension là .cs thì chuyển thành .log và ghi những thông tin cần thiết vào đây, ví dụ ngày giờ generated ... Ví dụ như sau:


// -----------------------------------------------------------------------------
//   GENERATED AT <#= DateTime.Now.ToShortDateString() + ", " + DateTime.Now.ToLongTimeString() #>
// -----------------------------------------------------------------------------
<#@ template language="C#" debug="False" hostspecific="True"  #>
<#@ include file="SQLServer.ttinclude" #>
<#@ include file="Manager.ttinclude"#>
<#@ output extension=".log" #>

2010-12-01

Microsoft Visual Studio 2008 RC/RTM uninstall tool

Hôm nay cài lại Visual Studio, máy này đã cài SQL Server 2008 trước. Chạy installer thì hiện ra là maintenance mode và bị báo lỗi 'A problem has been encountered while loading the setup components. Canceling setup.' Nói chung là rất khó chịu và bực mình. Chắc chắn là củ chuối này đụng với cái gì đó đã cài trên máy. Search vòng vòng một hồi, thì có lẽ completely uninstall trước rồi cài lại chắc được.

Có một vài bài ở đây
Trên Stackoverflow
Microsoft Visual Studio 2008 RC/RTM uninstall tool
Uninstall Visual Studio (all versions)

Dùng tool để thực hiện uninstall Visual Studio 2008 trước link tại đây UninstallTool.exe

Cũng liên quan đến việc install, lần này là lỗi với installer của VS 2008 (khi Add/Remove components) với cùng cái thông báo củ chuối 'A problem has been encountered....' , thực hiện remove hết updates và hotfixes liên quan như KB971091 thì installer không bị lỗi nữa.

Sau khi change/remove thì nhớ update lại lên service pack 1 để cho VS 2008 bình thường lại. Nếu không update lại thì lỗi hay gặp là VS 2008 không kết nối được SQL 2008, với thông báo lỗi 'This server version is not supported.  Only servers up to Microsoft SQL Server 2005 are supported'. Thật là lòng vòng, vì vậy nếu dùng VS 2008 nhiều và dư ổ cứng thì download Service Pack 1 để sẵn đó khoảng 800MB VS 2008 Service Pack 1 ISO