Author Archives: Berend de Jong

Add “After build” event in project file Visual Studio

After build events can be added to the property page of a visual studio project. You can also add your own “targets” file to the afterbuild (or beforebuild) in the project file itself. Use the following method:

  1. Add a targets file to your project with the following contents (for example)
    <?xml version="1.0" encoding="utf-8" ?>
    <Project DefaultTargets="WSPBuild"
       xmlns=http://schemas.microsoft.com/developer/msbuild/2003>
       <PropertyGroup>
          <WSPBuilderPath>"....ToolsWSPBuilder.exe"</WSPBuilderPath>
       </PropertyGroup>
       <Target Name="WSPBuild">
          <Exec Command="cd $(ProjectDir)" Outputs="null" />
          <Message Text="Executing WSP Builder in directory $(ProjectDir)"/>
          <Exec Command="$(WSPBuilderPath) "/>
       </Target>
    </Project>
    
  2. Unload the project file
  3. Right click the project file and choose Edit…..
  4. Add an import tag below the last import tag in the projectfile:
    <Import Project="wspbuilder.Targets" />
    
  5. Uncomment the AfterBuild tag and add the following statements; remember to specify the adjust CallTarget!
    <Target Name="AfterBuild">    
         <CallTarget Targets="BuildSharePointPackage" />
    </Target> 
    
Share

SharePoint stuff

General

  • Enable the Windows SharePoint Services Administration to be able to schedule retracting jobs in the Central Admin
  • Download the newest WSPBuilder bits
  • Remember to remove the default bin of VS2008 and store the dll’s in 80bin (dll’s in the default bin are going to be deployed to the GAC!)
  • Add solution to the solution store: %STSADMPRG% -o addsolution -filename “..Solution1.wsp” (No files available in the 12 hive yet)
  • Deploy a solution: %STSADMPRG% -o deploysolution -name “Solution1” -immediate -force -allowCasPolicies -allowGacDeployment (Now you can see the files are added to the 12 hive; features are installed NOT activated)
  • Activate the feature: %STSADMPRG% -o deactivatefeature -filename Feature1feature.xml -url http://ServerName
Share

Schedule tasks with windows 2003

The following command schedules the “start.cmd” batch file to run hourly beginning at five minutes past midnight. Because the /mo parameter is omitted, the command uses the default value for the hourly schedule, which is every (1) hour. If this command is issued after 12:05 A.M., the program will not run until the next day.

schtasks /create /sc hourly /st 00:20:00 /tn “Move backup to fs” /tr start.cmd

Share

SELECT TOP WITH TIES

create table tie 
( 
    id int, 
    price int 
) 
insert into tie values (1, 20); 
insert into tie values (1, 30); 
insert into tie values (1, 40); 
insert into tie values (1, 50); 
insert into tie values (1, 60); 
insert into tie values (1, 60);

select top 5 with ties from tie 
order by price asc; 

Results
1 20
2 30
3 40
4 50
5 60
6 60
The first 6 rows are part of the result set. 6 rows because row number 5 and 6 have the same price value. The price value is looked at because the WITH TIES clause has an ORDER BY on price. An order by clause is mandatory with the WITH TIES construct.

Share

SQL Joins

Start situation (download the sql script here)

Table A Table B
1 2
2 3
3 4

The INNER join (“normal / regular” join)

select a.id as A, b.id as B from a inner join b on a.id = b.id; 

Results
A B
2 2
3 3

Only rows that have the same id in both tables appear in the result set.

The LEFT OUTER join

select a.id as A, b.id as B from a left join b on a.id = b.id; 

Results
A B
1 NULL
2 2
3 3

Every row from the table mentioned on the left (table A in this example) will be part of the result set. If possible the corresponding row (the one with the same id) in table B is also part of the result set. If no corresponding row is found in table B NULL values are provided.
The RIGHT OUTER join

select a.id as A, b.id as B from a right join b on a.id = b.id; 

Results
A B
2 2
3 3
NULL 4

Every row from the table mentioned on the right (table B in this example) will be part of the result set. If possible the corresponding row (the one with the same id) in table A is also part of the result set. If no corresponding row is found in table A NULL values are provided.
The FULL OUTER join

select a.id as A, b.id as B from a full join b on a.id = b.id; 

Results
A B
1 NULL
2 2
3 3
NULL 4

Every row from table A and table B is part of the result set. If possible a match is made based on the id. If a match could not be made NULL values are provided for the missing items.
Cartesian product
select a.id as A, b.id as B from a , b;
Results
A B
1 2
2 2
3 2
1 3
2 3
3 3
1 4
2 4
3 4

Every row in table A is joined with every row in table B. So the cartesian product of table A and table B delivers 9 rows in the result set. A cartesian produkt is often specified by mistake (missing join condition).

Share

Keyboard shortcuts

Windows
Win+Break Open “System Properties”
Shft+Win+M Restore all windows
Shft+Ctrl+Esc Task Manager
Win+E Explorer

Visual Studio 2005
Server Explorer Ctrl+Alt+S
Solution Explorer Ctrl+Alt+L
Properties Window F4
Toolbox Ctrl+Alt+X
Class View Ctrl+Shft+C
Error List Ctrl+W,Ctrl+E
Bookmark Ctrl+K,Ctrl+K
Bookmark previous Ctrl+K,Ctrl+P
Output Window Ctrl+Alt+O
BreakPoints Ctrl+Alt+B
Tasklist Ctrl+,Ctrl+K
Insert Code Snippet Ctrl+K,Ctrl+X
Code Snippet manager Ctrl+K,Ctrl+B

Share

Useful Software

VirtualBox Virtualisation software.
doPDF DoPDF is a pdf-converter which installs itself a printerdriver.
MediaInfo Retrieve information about multimedia files.
HWInfo Hardware information.
SysInternals Set of handy tools and utilities
Recuva Recover deleted file.
FoxMarks Manage bookmarks and passwords online.
WinMerge a (source) file comparer; available on codeplex
PrismVideoConverter Rip DVD’s to whatever format you desire (wmv, mp4,….)
mkvtoolnix Create and modify mkv containers (add subtitles, images etc)
VLC Player Plays every known video / audio format!
SOAP UI Test your webservices with the help of SOAP UI!
imgBurn The ultimate image burner!
DVDtoAVI Convert your 4Gb dvd’s to a 700Mb avi file.
dvdshrink Shrink (and copy) your dvd’s removing unwanted audio and video tracks.
Notepad++ Freeware text editor
nLite Deployment Tool for the Bootable Unattended Windows ISO
Hiren’s bootCD BootCD with a lot of utilities and programs
Share

HTML Injection

In de Page_load of a ASP.NET page called inject.aspx:

Response.Write("Hello "  + Request.QueryString["name"]); 

Direct your browser to “…./…../inject.aspx?name=alert(“script injected”);”

To avoid HTML injection adjust the code below to:

Response.Write("Hello "  + Server.HtmlEncode(Request.QueryString["name"]));
Share