Skip to content

Commit

Permalink
Updated build script files to use the same system
Browse files Browse the repository at this point in the history
as also used by Exude, Hyprlinkr, and ZeroToNine.
  • Loading branch information
ploeh committed Mar 17, 2014
1 parent 6c67944 commit 582c56e
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 81 deletions.
9 changes: 9 additions & 0 deletions Build-Release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Get-VsVersion ()
{
if ($env:VS120COMNTOOLS -ne $null)
{
" /property:VisualStudioVersion=12.0"
}
}

Start-Process -NoNewWindow -Wait -FilePath $env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild -ArgumentList ('BuildRelease.msbuild', '/property:Configuration=Release', (Get-VsVersion))
22 changes: 22 additions & 0 deletions Build.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<XUnitPath>Src\packages\xunit.runners.1.9.2\tools</XUnitPath>
<NuGetPath>Src\packages\NuGet.CommandLine.2.7.1\tools</NuGetPath>
<NuGetPackageDependencyRoot>albedo</NuGetPackageDependencyRoot>
</PropertyGroup>
<ItemGroup>
<BuildOutput Include="Src\Albedo\bin\Release\Ploeh.Albedo.dll" />
<BuildOutput Include="Src\Albedo\bin\Release\Ploeh.Albedo.XML" />
</ItemGroup>
<ItemGroup>
<ProjectToBuild Include="Src\*.sln" />
</ItemGroup>
<!-- Expand build output files AFTER the build has run.
Note that the Build Task MUST BE defined by the file that includes this file. -->
<Target Name="GetTestAssemblies" DependsOnTargets="Build">
<ItemGroup>
<TestAssemblies Include="**\bin\Release\*UnitTests*.dll" />
</ItemGroup>
</Target>
</Project>
159 changes: 80 additions & 79 deletions BuildRelease.msbuild
Original file line number Diff line number Diff line change
@@ -1,86 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="CompleteBuild" ToolsVersion="4.0">
<!--Project configuration-->
<Import Project="Build.config" />

<UsingTask TaskName="xunit" AssemblyFile="$(XUnitPath)\xunit.runner.msbuild.dll" />

<!--Clean-->
<Target Name="CleanAll" DependsOnTargets="CleanDebug;CleanVerify;CleanRelease" />
<Target Name="CleanDebug">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Debug" />
</Target>
<Target Name="CleanVerify">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Verify" />
</Target>
<Target Name="CleanRelease">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Release" />
</Target>

<!--Compile-->
<Target Name="Build" DependsOnTargets="CleanAll">
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Verify" />
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Release" />
</Target>

<!--Test. Note that the GetTestAssemblies Task MUST BE defined in the Build.config file. -->
<Target Name="Test" DependsOnTargets="GetTestAssemblies">
<xunit Assemblies="@(TestAssemblies)" />
</Target>

<!--Release-->
<PropertyGroup>
<ReleaseFolder>Release</ReleaseFolder>
</PropertyGroup>
<Target Name="DeleteReleaseFolder">
<RemoveDir Directories="$(ReleaseFolder)" />
</Target>
<Target Name="MakeReleaseFolder" DependsOnTargets="DeleteReleaseFolder">
<MakeDir Directories="$(ReleaseFolder)" Condition="!Exists($(ReleaseFolder))" />
</Target>
<Target Name="CopyToReleaseFolder" DependsOnTargets="Test">
<Copy SourceFiles="@(BuildOutput)" DestinationFolder="$(ReleaseFolder)" />
</Target>

<!--NuGet-->
<ItemGroup>
<NuSpecFiles Include="NuGetSpecs\*.nuspec" />
</ItemGroup>
<Target Name="CreateTemporaryNuGetSpecFiles">
<PropertyGroup>
<XUnitPath>Src\packages\xunit.runners.1.9.2\tools</XUnitPath>
<NuGetOutputFolder>NuGetPackages</NuGetOutputFolder>
</PropertyGroup>
<UsingTask TaskName="xunitproject" AssemblyFile="$(XUnitPath)\xunit.runner.msbuild.dll" />
<ItemGroup>
<ProjectToBuild Include="Src\*.sln" />
</ItemGroup>
<ItemGroup>
<BuildOutput Include="Src\Albedo\bin\Release\Ploeh.Albedo.dll" />
<BuildOutput Include="Src\Albedo\bin\Release\Ploeh.Albedo.XML" />
</ItemGroup>
<ItemGroup>
<NuSpecFiles Include="NuGetSpecs\*.nuspec" />
</ItemGroup>
<RemoveDir Directories="$(NuGetOutputFolder)" />
<Copy SourceFiles="@(NuSpecFiles)" DestinationFolder="$(NuGetOutputFolder)">
<Output TaskParameter="CopiedFiles" ItemName="TempNuspecFiles" />
</Copy>
</Target>
<Target Name="NuGetPrepare" DependsOnTargets="CreateTemporaryNuGetSpecFiles;CopyToReleaseFolder" Outputs="%(TempNuspecFiles.Identity)">
<PropertyGroup>
<ReleaseFolder>Release</ReleaseFolder>
<TempNuspecFilePath>%(TempNuspecFiles.FullPath)</TempNuspecFilePath>
<AssemblyFile Condition="Exists('$(ReleaseFolder)\%(TempNuspecFiles.Filename).dll')">$(ReleaseFolder)\%(TempNuspecFiles.Filename).dll</AssemblyFile>
<AssemblyFile Condition="Exists('$(ReleaseFolder)\%(TempNuspecFiles.Filename).exe')">$(ReleaseFolder)\%(TempNuspecFiles.Filename).exe</AssemblyFile>
</PropertyGroup>
<!--Clean all-->
<Target Name="CleanAll" DependsOnTargets="CleanDebug;CleanVerify;CleanRelease" />
<Target Name="CleanDebug">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Debug" />
</Target>
<Target Name="CleanVerify">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Verify" />
</Target>
<Target Name="CleanRelease">
<MSBuild Projects="@(ProjectToBuild)" Targets="Clean" Properties="Configuration=Release" />
</Target>
<!--Build tasks-->
<Target Name="DeleteReleaseFolder">
<RemoveDir Directories="$(ReleaseFolder)" />
</Target>
<Target Name="MakeReleaseFolder" DependsOnTargets="DeleteReleaseFolder">
<MakeDir Directories="$(ReleaseFolder)" Condition="!Exists($(ReleaseFolder))" />
</Target>
<Target Name="Verify" DependsOnTargets="MakeReleaseFolder;CleanAll">
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Verify" />
</Target>
<Target Name="Build" DependsOnTargets="Verify;CleanAll">
<MSBuild Projects="@(ProjectToBuild)" Properties="Configuration=Release" />
</Target>
<Target Name="Test" DependsOnTargets="Build">
<xunitproject ProjectFile="Src\All.xunit" />
</Target>
<Target Name="CopyToReleaseFolder" DependsOnTargets="Test">
<Copy SourceFiles="@(BuildOutput)" DestinationFolder="$(ReleaseFolder)" />
<Copy SourceFiles="@(NuGetPackageScripts)" DestinationFolder="$(ReleaseFolder)" />
</Target>
<Target Name="CreateTemporaryNuGetSpecFiles">
<PropertyGroup>
<NuGetOutputFolder>NuGetPackages</NuGetOutputFolder>
</PropertyGroup>
<RemoveDir Directories="$(NuGetOutputFolder)" />
<Copy SourceFiles="@(NuSpecFiles)" DestinationFolder="$(NuGetOutputFolder)">
<Output TaskParameter="CopiedFiles" ItemName="TempNuspecFiles" />
</Copy>
</Target>
<Target Name="NuGetPrepare" DependsOnTargets="CreateTemporaryNuGetSpecFiles;CopyToReleaseFolder" Outputs="%(TempNuspecFiles.Identity)">
<PropertyGroup>
<TempNuspecFilePath>%(TempNuspecFiles.FullPath)</TempNuspecFilePath>
<AssemblyFile>$(ReleaseFolder)\%(TempNuspecFiles.Filename).dll</AssemblyFile>
</PropertyGroup>
<GetAssemblyIdentity AssemblyFiles="$(AssemblyFile)">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<Version>%(AssemblyInfo.Version)</Version>
<SemanticVersion>$(Version.Substring(0, $(Version.LastIndexOf('.'))))</SemanticVersion>
</PropertyGroup>
<XmlPoke XmlInputPath="$(TempNuspecFilePath)"
Query="//metadata/version"
Value="$(SemanticVersion)" />
<XmlPoke XmlInputPath="$(TempNuspecFilePath)"
Query="//metadata/dependencies/dependency/Albedo/@version"
Value="$(SemanticVersion)" />
</Target>
<Target Name="NuGetPack" DependsOnTargets="NuGetPrepare">
<Exec Command="Src\packages\NuGet.CommandLine.2.7.1\tools\NuGet.exe pack %(TempNuspecFiles.FullPath) -BasePath $(ReleaseFolder) -OutputDirectory $(NuGetOutputFolder)" />
</Target>
<Target Name="CleanTemporaryNuGetSpecFiles" DependsOnTargets="NuGetPack">
<Delete Files="@(TempNuspecFiles)" />
</Target>
<Target Name="CompleteBuild" DependsOnTargets="CopyToReleaseFolder;CleanTemporaryNuGetSpecFiles" />
<GetAssemblyIdentity AssemblyFiles="$(AssemblyFile)">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<Version>%(AssemblyInfo.Version)</Version>
<SemanticVersion>$(Version.Substring(0, $(Version.LastIndexOf('.'))))</SemanticVersion>
</PropertyGroup>
<XmlPoke XmlInputPath="$(TempNuspecFilePath)"
Query="//metadata/version"
Value="$(SemanticVersion)" />
<XmlPoke XmlInputPath="$(TempNuspecFilePath)"
Query="//metadata/dependencies/dependency[contains(@id, '$(NuGetPackageDependencyRoot)')]/@version"
Value="$(SemanticVersion)" />
</Target>
<Target Name="NuGetPack" DependsOnTargets="NuGetPrepare">
<Exec Command="$(NuGetPath)\nuget.exe pack %(TempNuspecFiles.FullPath) -BasePath $(ReleaseFolder) -OutputDirectory $(NuGetOutputFolder)" />
</Target>
<Target Name="CleanTemporaryNuGetSpecFiles" DependsOnTargets="NuGetPack">
<Delete Files="@(TempNuspecFiles)" />
</Target>

<!--Done-->
<Target Name="CompleteBuild" DependsOnTargets="CleanTemporaryNuGetSpecFiles" />
</Project>
13 changes: 11 additions & 2 deletions build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ function abspath()
echo $(cd $(dirname $1); pwd)/$(basename $1) | sed 's/^\///' | sed 's/\//\\/g' | sed 's/^./\0:/'
}

function vsvers()
{
if [ "$VS120COMNTOOLS" ]; then
echo " /property:VisualStudioVersion=12.0"
else
echo ""
fi
}

if [ "$1" != "" ]; then
$WINDIR/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe /property:AssemblyOriginatorKeyFile=`abspath $1` `dirname $0`/BuildRelease.msbuild
$WINDIR/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe /property:AssemblyOriginatorKeyFile=`abspath $1` /property:SignAssembly=true BuildRelease.msbuild /property:Configuration=Release `vsvers`
else
$WINDIR/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe `dirname $0`/BuildRelease.msbuild
$WINDIR/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe BuildRelease.msbuild /property:Configuration=Release `vsvers`
fi

0 comments on commit 582c56e

Please sign in to comment.