Language: PowerShell
My basic PSake script.
properties {
# **************** CONFIGURE ****************
$solution_name = "Framework"
$test_library = "$solution_name.Test.dll"
$libraries_to_merge = "antlr3.runtime.dll", `
"ajaxcontroltoolkit.dll", `
"Castle.DynamicProxy2.dll", `
"Castle.Core.dll", `
"FluentNHibernate.dll", `
"log4net.dll", `
"system.linq.dynamic.dll", `
"xunit.dll", `
"nhibernate.caches.syscache2.dll", `
"cssfriendly.dll", `
"iesi.collections.dll", `
"nhibernate.bytecode.castle.dll", `
"oracle.dataaccess.dll"
$libraries_to_copy = "system.data.sqlite.dll"
$tester_directory = "j:\shared_libraries\xunit\msbuild"
$tester_executable = "xunit.console.x86.exe"
$tools_directory = "$tools"
$base_directory = resolve-path .
$thirdparty_directory = "$base_directory\thirdparty"
$build_directory = "$base_directory\build"
$solution_file = "$base_directory\$solution_name.sln"
$release_directory = "$base_directory\release"
}
task default -depends Release
task Clean {
remove-item -force -recurse $build_directory -ErrorAction SilentlyContinue | Out-Null
remove-item -force -recurse $release_directory -ErrorAction SilentlyContinue | Out-Null
}
task Init -depends Clean {
new-item $release_directory -itemType directory | Out-Null
new-item $build_directory -itemType directory | Out-Null
cp $tester_directory\*.* $build_directory
}
task Compile -depends Init {
# from http://poshcode.org/1050 (first lines to get latest versions)
[System.Reflection.Assembly]::Load('Microsoft.Build.Utilities.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | Out-Null
$msbuild = [Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToDotNetFrameworkFile("msbuild.exe", "VersionLatest")
# adding double slash for directories with spaces. Stupid MSBuild.
&$msbuild /verbosity:minimal /p:Configuration="Release" /p:Platform="Any CPU" /p:OutDir="$build_directory"\\ "$solution_file"
}
task Test -depends Compile {
$origin_directory = pwd
cd $build_directory
exec .\$tester_executable "$build_directory\$test_library"
cd $origin_directory
}
task Merge {
$origin_directory = pwd
cd $build_directory
remove-item "$solution_name.merge.dll" -erroraction SilentlyContinue
rename-item "$solution_name.dll" "$solution_name.merge.dll"
& $tools\ilmerge\ilmerge.exe /out:"$solution_name.dll" /t:library /xmldocs /log:"$solution_name.merge.log" `
"$solution_name.merge.dll" $libraries_to_merge
if ($lastExitCode -ne 0) {
throw "Error: Failed to merge assemblies!"
}
cd $origin_directory
}
task Build -depends Compile, Merge {
# When I REALLY don't want to test...
}
task Release -depends Test, Merge {
copy-item $build_directory\$solution_name.dll $release_directory
copy-item $build_directory\$solution_name.xml $release_directory
# copy libraries that cannot be merged
% { $libraries_to_copy } | %{ copy-item (join-path $build_directory $_) $release_directory }
}
Tags:
Comment:
My general PSake script... with a framework library as an example.
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

