<commit_before>properties {
	$buildName = "dev"
}

task default -depends Package

task PreparePackage -depends Test {
	$packagesDirectory = '..\targets\packages'
	
	if (Test-Path -path $packagesDirectory)
	{
		rm $packagesDirectory -recurse -force
	}

	mkdir $packagesDirectory
	cp ..\build\package.nuspec ..\targets\packages

	mkdir ..\targets\packages\lib\net40
	cp ..\targets\speakeasy\speakeasy.* ..\targets\packages\lib\net40

	mkdir ..\targets\packages\lib\sl5
	cp ..\targets\silverlight\speakeasy.* ..\targets\packages\lib\sl5
}

task PackagePre -depends PreparePackage {
	# update nuspec package
	$version = get-content ..\VERSION
	$when = (get-date).ToString("yyyyMMddHHmmss")
	$packageVersion = "$version-$buildName-$when"

	get-content ..\targets\packages\package.nuspec | 
        %{$_ -replace '0.0.0.1', $packageVersion } > ..\targets\packages\package.nuspec.tmp
	
	mv ..\targets\packages\package.nuspec.tmp ..\targets\packages\package.nuspec -force

	..\src\.nuget\nuget.exe pack "..\targets\packages\package.nuspec" -outputdirectory ".\..\targets\packages"
}

task Package -depends PreparePackage {
	# update nuspec package
	$version = get-content ..\VERSION
	$packageVersion = "$version"

	get-content ..\targets\packages\package.nuspec | 
        %{$_ -replace '0.0.0.1', $packageVersion } > ..\targets\packages\package.nuspec.tmp
	
	mv ..\targets\packages\package.nuspec.tmp ..\targets\packages\package.nuspec -force

	..\src\.nuget\nuget.exe pack "..\targets\packages\package.nuspec" -outputdirectory ".\..\targets\packages"	
}

task Publish -depends Package {
	$package = gci .\..\targets\packages\*.nupkg | select -first 1
	..\src\.nuget\nuget.exe Push $package.fullname
}

task PublishPre -depends PackagePre {
	$package = gci .\..\targets\packages\*.nupkg | select -first 1
	..\src\.nuget\nuget.exe Push $package.fullname
}

task CopyTools {
	
}

task Test -depends Clean,CopyTools,Compile { 
  # run specs
  ..\src\packages\Machine.Specifications.0.5.6.0\tools\mspec-clr4.exe .\..\targets\specifications\speakeasy.specifications.dll

  # run integration tests somehow (need a local nunit-console.exe, or switch to xunit?)
}

task UpdateAssemblyInfo {
	$version = get-content ..\VERSION

	$assemblyVersion = 'AssemblyVersion("' + $version + '")';
	$assemblyFileVersion = 'AssemblyFileVersion("' + $version + '")';

	get-content ..\src\CommonAssemblyInfo.cs | 
        %{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $assemblyVersion } |<commit_msg>update build script to work with new mspec<commit_after>properties {
	$buildName = "dev"
}

task default -depends Package

task PreparePackage -depends Test {
	$packagesDirectory = '..\targets\packages'
	
	if (Test-Path -path $packagesDirectory)
	{
		rm $packagesDirectory -recurse -force
	}

	mkdir $packagesDirectory
	cp ..\build\package.nuspec ..\targets\packages

	mkdir ..\targets\packages\lib\net40
	cp ..\targets\speakeasy\speakeasy.* ..\targets\packages\lib\net40

	mkdir ..\targets\packages\lib\sl5
	cp ..\targets\silverlight\speakeasy.* ..\targets\packages\lib\sl5
}

task PackagePre -depends PreparePackage {
	# update nuspec package
	$version = get-content ..\VERSION
	$when = (get-date).ToString("yyyyMMddHHmmss")
	$packageVersion = "$version-$buildName-$when"

	get-content ..\targets\packages\package.nuspec | 
        %{$_ -replace '0.0.0.1', $packageVersion } > ..\targets\packages\package.nuspec.tmp
	
	mv ..\targets\packages\package.nuspec.tmp ..\targets\packages\package.nuspec -force

	..\src\.nuget\nuget.exe pack "..\targets\packages\package.nuspec" -outputdirectory ".\..\targets\packages"
}

task Package -depends PreparePackage {
	# update nuspec package
	$version = get-content ..\VERSION
	$packageVersion = "$version"

	get-content ..\targets\packages\package.nuspec | 
        %{$_ -replace '0.0.0.1', $packageVersion } > ..\targets\packages\package.nuspec.tmp
	
	mv ..\targets\packages\package.nuspec.tmp ..\targets\packages\package.nuspec -force

	..\src\.nuget\nuget.exe pack "..\targets\packages\package.nuspec" -outputdirectory ".\..\targets\packages"	
}

task Publish -depends Package {
	$package = gci .\..\targets\packages\*.nupkg | select -first 1
	..\src\.nuget\nuget.exe Push $package.fullname
}

task PublishPre -depends PackagePre {
	$package = gci .\..\targets\packages\*.nupkg | select -first 1
	..\src\.nuget\nuget.exe Push $package.fullname
}

task CopyTools {
	
}

task Test -depends Clean,CopyTools,Compile { 
  # run specs
  ..\src\packages\Machine.Specifications.0.5.8\tools\mspec-clr4.exe .\..\targets\specifications\speakeasy.specifications.dll

  # run integration tests somehow (need a local nunit-console.exe, or switch to xunit?)
}

task UpdateAssemblyInfo {
	$version = get-content ..\VERSION

	$assemblyVersion = 'AssemblyVersion("' + $version + '")';
	$assemblyFileVersion = 'AssemblyFileVersion("' + $version + '")';

	get-content ..\src\CommonAssemblyInfo.cs | 
        %{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $assemblyVersion } |
{'fraction_non_alphanumeric': 0.16803196803196804, 'fraction_numerical': 0.01058941058941059, 'mean_word_length': 3.449777777777778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '63088', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1678, 'n_words': 319}