Orchard/Orchard.proj
Renaud Paquay e019aeb597 Fix issue with file locking
Calling SetVersion has the side-effect of locking our custom msbuild
tasks assembly. So, doing a "SetVersion;Build" doesn't work because
"Build" does a "Clean" first.

Expose a "BuildWithVersion" target instead.

--HG--
branch : dev
2010-07-19 14:14:35 -07:00

264 lines
11 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Initialization -->
<PropertyGroup>
<LibFolder>$(MSBuildProjectDirectory)\lib</LibFolder>
<SrcFolder>$(MSBuildProjectDirectory)\src</SrcFolder>
<BuildFolder>$(MSBuildProjectDirectory)\build</BuildFolder>
<SqlCeFolder>$(MSBuildProjectDirectory)\lib\sqlce</SqlCeFolder>
<SourceArtifactFolder>$(MSBuildProjectDirectory)\artifacts\Source</SourceArtifactFolder>
<MsDeployArtifactFolder>$(MSBuildProjectDirectory)\artifacts\MsDeploy</MsDeployArtifactFolder>
<ModulesSrcFolder>$(MSBuildProjectDirectory)\src\Orchard.Web\Modules</ModulesSrcFolder>
<CompileFolder>$(BuildFolder)\Compile</CompileFolder>
<WebSitesFolder>$(CompileFolder)\_PublishedWebsites</WebSitesFolder>
<StageFolder>$(BuildFolder)\Stage</StageFolder>
<MsDeployFolder>$(BuildFolder)\MsDeploy</MsDeployFolder>
<ProfilingFolder>$(BuildFolder)\Profiling</ProfilingFolder>
<BuildPlatform Condition="$(ProgramW6432) != ''">x64</BuildPlatform>
<BuildPlatform Condition="$(BuildPlatform) == ''">x86</BuildPlatform>
<!-- TeamCity build number -->
<Version>$(BUILD_NUMBER)</Version>
</PropertyGroup>
<Import Project="$(LibFolder)\msbuild\MSBuild.Community.Tasks.Targets"/>
<!-- Coordinating Targets -->
<Target Name ="Build">
<CallTarget Targets="Clean"/>
<CallTarget Targets="Compile"/>
<CallTarget Targets="Test"/>
<CallTarget Targets="Package"/>
</Target>
<Target Name ="BuildWithVersion">
<CallTarget Targets="Clean"/>
<CallTarget Targets="SetVersion"/>
<CallTarget Targets="Compile"/>
<CallTarget Targets="Test"/>
<CallTarget Targets="Package"/>
</Target>
<Target Name="Package">
<CallTarget Targets="Package-Stage"/>
<CallTarget Targets="Package-MsDeploy"/>
<CallTarget Targets="Package-Zip"/>
</Target>
<Target Name="Profiling">
<CallTarget Targets="Clean"/>
<CallTarget Targets="Compile"/>
<CallTarget Targets="Package-Stage"/>
<CallTarget Targets="Profiling-Stage"/>
<CallTarget Targets="Profiling-Setup"/>
</Target>
<!-- Building -->
<Target Name="Clean">
<MSBuild Projects="$(SrcFolder)\Orchard.sln" Targets="Clean" />
<RemoveDir Directories="$(BuildFolder)" />
</Target>
<Target Name ="Compile">
<CallTarget Targets="CompileMsBuildTasks"/>
<MSBuild
Projects="$(SrcFolder)\Orchard.sln"
Targets="Build"
Properties="Configuration=Release;OutputPath=$(CompileFolder)" />
</Target>
<Target Name ="CompileMsBuildTasks">
<MSBuild
Projects="$(SrcFolder)\Tools\MSBuild.Orchard.Tasks\MSBuild.Orchard.Tasks.csproj"
Targets="Build"
Properties="Configuration=Release;OutputPath=$(CompileFolder)" />
</Target>
<!-- Testing -->
<Target Name ="Test">
<!-- TeamCity support -->
<ItemGroup>
<NUnitAddinFiles Include="$(teamcity_dotnet_nunitaddin)-2.5.2.*" />
</ItemGroup>
<Copy SourceFiles="@(NUnitAddinFiles)" DestinationFolder="$(LibFolder)\nunit\addins" />
<!-- Run unit test assemblies -->
<CreateItem Include="$(CompileFolder)\*.Tests.*dll">
<Output TaskParameter="Include" ItemName="TestAssemblies" />
</CreateItem>
<NUnit Assemblies="@(TestAssemblies)" ToolPath="$(LibFolder)\nunit" WorkingDirectory="$(CompileFolder)" OutputXmlFile="$(BuildFolder)\Orchard.Tests.xml" />
</Target>
<Target Name ="Spec">
<CreateItem Include="$(CompileFolder)\*.Specs.dll">
<Output TaskParameter="Include" ItemName="SpecAssemblies" />
</CreateItem>
<NUnit Assemblies="@(SpecAssemblies)" ToolPath="$(LibFolder)\nunit" />
</Target>
<!-- Packaging (Stage) -->
<UsingTask AssemblyFile="$(CompileFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.StageProjectAlteration" />
<UsingTask AssemblyFile="$(CompileFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.FilterModuleBinaries" />
<UsingTask AssemblyFile="$(CompileFolder)\MSBuild.Orchard.Tasks.dll" TaskName="MSBuild.Orchard.Tasks.FileUpdateLines" />
<Target Name="Package-Stage">
<ItemGroup>
<SqlCe-Native-Binaries-x86 Include="$(SqlCeFolder)\x86\*"/>
<SqlCe-Native-Binaries-amd64 Include="$(SqlCeFolder)\amd64\*"/>
<Stage-Orchard-Web-Bins Include="$(WebSitesFolder)\Orchard.Web\bin\*"/>
<Stage-Bin-Exclude Include="$(WebSitesFolder)\**\bin\**\*" />
<Stage-Web Include="$(WebSitesFolder)\Orchard.Web\**\*;$(SrcFolder)\Orchard.Web\*.csproj" />
<Stage-Core Include="$(WebSitesFolder)\Orchard.Core\**\*" Exclude="$(WebSitesFolder)\Orchard.Core\**\bin\**\*" />
<Stage-Module-Exclude Include="@(Stage-Web);@(Stage-Core);$(WebSitesFolder)\PackageIndexReferenceImplementation\**\*"/>
<Stage-Modules Include="$(WebSitesFolder)\**\*" Exclude="@(Stage-Bin-Exclude);@(Stage-Module-Exclude)" />
<Stage-Modules-Binaries Include="$(WebSitesFolder)\**\bin\**\*" Exclude="@(Stage-Module-Exclude)"/>
<Stage-Modules-Sources Include="$(ModulesSrcFolder)\**\*.csproj;$(ModulesSrcFolder)\**\*.cs"/>
<Stage-License Include="$(MSBuildProjectDirectory)\*.txt" />
</ItemGroup>
<!-- Copying module binaries is somewhat tricky: From a module "bin" directory, we
only want to include the files that are _not_ already present in
the "Orchard.Web\Bin" folder. -->
<FilterModuleBinaries
ModulesBinaries="@(Stage-Modules-Binaries)"
OrchardWebBinaries="@(Stage-Orchard-Web-Bins)">
<Output TaskParameter="ExcludedBinaries" ItemName="FilterModuleBinaries-ExcludedBinaries"/>
</FilterModuleBinaries>
<ItemGroup>
<Stage-Modules-Binaries-Unique Include="@(Stage-Modules-Binaries)" Exclude="@(FilterModuleBinaries-ExcludedBinaries)"/>
</ItemGroup>
<Copy SourceFiles="@(Stage-Web);@(Stage-License)" DestinationFolder="$(StageFolder)\%(RecursiveDir)"/>
<Copy SourceFiles="@(SqlCe-Native-Binaries-x86)" DestinationFolder="$(StageFolder)\bin\x86"/>
<Copy SourceFiles="@(SqlCe-Native-Binaries-amd64)" DestinationFolder="$(StageFolder)\bin\amd64"/>
<Copy SourceFiles="@(Stage-Core)" DestinationFolder="$(StageFolder)\Core\%(RecursiveDir)"/>
<Copy SourceFiles="@(Stage-Modules)" DestinationFolder="$(StageFolder)\Modules\%(RecursiveDir)"/>
<Copy SourceFiles="@(Stage-Modules-Sources)" DestinationFolder="$(StageFolder)\Modules\%(RecursiveDir)"/>
<Copy SourceFiles="@(Stage-Modules-Binaries-Unique)" DestinationFolder="$(StageFolder)\Modules\%(RecursiveDir)"/>
<!-- extra processing of the staged csproj file -->
<StageProjectAlteration ProjectFileName="$(StageFolder)\Orchard.Web.csproj" AddContentFiles="
@(Stage-Modules->'Modules\%(RecursiveDir)%(Filename)%(Extension)');
@(Stage-Core->'Core\%(RecursiveDir)%(Filename)%(Extension)')">
<Output TaskParameter="ExtraFiles" ItemName="StageProjectAlteration-ExtraFiles"/>
</StageProjectAlteration>
<!-- extra processing of the staged config files -->
<XmlUpdate XmlFileName="$(StageFolder)\web.config"
XPath="/configuration/system.web/compilation/@debug"
Value="false" />
<XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config"
XPath="/system.diagnostics/trace/@autoflush"
Value="false" />
<XmlUpdate XmlFileName="$(StageFolder)\Config\Diagnostics.config"
XPath="/system.diagnostics/sources/source/@switchValue"
Value="Error" />
<!-- move over extra non-content files the csproj referenced -->
<Copy SourceFiles="@(StageProjectAlteration-ExtraFiles->'$(SrcFolder)\Orchard.Web\%(Identity)')"
DestinationFolder="$(StageFolder)\%(RecursiveDir)"/>
</Target>
<!-- Packaging (MsDeploy) -->
<Target Name="Package-MsDeploy">
<ItemGroup>
<!--<MsDeploy-Folder-Input Include="$(StageFolder)\**\*" Exclude="$(StageFolder)\**\bin\**\*.pdb;$(StageFolder)\**\bin\**\*.xml" />-->
<MsDeploy-Folder-Input Include="$(StageFolder)\**\*" Exclude="$(StageFolder)\**\bin\**\*.xml" />
<MsDeploy-Parameters Include="$(LibFolder)\msdeploy\*.xml"/>
</ItemGroup>
<Copy SourceFiles="@(MsDeploy-Folder-Input)"
DestinationFolder="$(MsDeployFolder)\Orchard\%(RecursiveDir)"/>
<Copy SourceFiles="@(MsDeploy-Parameters)"
DestinationFolder="$(MsDeployFolder)"/>
</Target>
<Target Name="Package-Zip">
<ItemGroup>
<Zip-Exclude Include="
$(MSBuildProjectDirectory)\src\**\bin\**\*;
$(MSBuildProjectDirectory)\src\**\obj\**\*;
$(MSBuildProjectDirectory)\**\App_Data\**\*;
$(MSBuildProjectDirectory)\**\_ReSharper*\**\*;
$(MSBuildProjectDirectory)\**\*.sln.cache;
$(MSBuildProjectDirectory)\**\*.suo;
$(MSBuildProjectDirectory)\**\*.user;
$(MSBuildProjectDirectory)\**\*.patch;
$(MSBuildProjectDirectory)\**\*.hg;
" />
<Zip-Stage Include="$(StageFolder)\**\*" />
<Zip-MsDeploy Include="$(MsDeployFolder)\**\*" />
<Zip-Source Include="
$(MSBuildProjectDirectory)\lib\**\*;
$(MSBuildProjectDirectory)\src\**\*;
$(MSBuildProjectDirectory)\*.txt;
" Exclude="@(Zip-Exclude)" />
</ItemGroup>
<MakeDir Directories="$(MsDeployArtifactFolder);$(SourceArtifactFolder)"/>
<Zip Files="@(Zip-MsDeploy)" WorkingDirectory="$(MsDeployFolder)" ZipFileName="$(MsDeployArtifactFolder)\Orchard.Web.zip" />
<Zip Files="@(Zip-Source)" WorkingDirectory="$(MSBuildProjectDirectory)" ZipFileName="$(SourceArtifactFolder)\Orchard.Source.zip" />
</Target>
<!-- Profiling -->
<Target Name="Profiling-Stage">
<ItemGroup>
<Profiling-Web Include="$(StageFolder)\**\*" />
</ItemGroup>
<Copy SourceFiles="@(Profiling-Web)" DestinationFolder="$(ProfilingFolder)\%(RecursiveDir)"/>
</Target>
<Target Name="Profiling-Setup">
<Exec Command="$(ProfilingFolder)\bin\Orchard.exe @$(SrcFolder)\Orchard.Profile\profiling-setup-commands.txt" WorkingDirectory="$(ProfilingFolder)"/>
</Target>
<!-- Version -->
<!-- Update all AssemblyInfo.cs and module.txt files to contain $(Version) -->
<Target Name="SetVersion" Condition="$(Version) != ''">
<CallTarget Targets="CompileMsBuildTasks"/>
<ItemGroup>
<Version-AssemblyInfos Include="$(SrcFolder)\**\AssemblyInfo.cs" />
<Version-Modules Include="$(SrcFolder)\**\Module.txt" />
</ItemGroup>
<FileUpdateLines Files="@(Version-Modules)"
Regex="^(orchardversion|version)(\s*):(\s*)(.*)"
ReplacementText="${1}${2}:${3}$(Version)"
IgnoreCase="True"/>
<FileUpdateLines Files="@(Version-AssemblyInfos)"
Regex="^\[assembly:(\s)*(AssemblyVersion|AssemblyFileVersion)(\s)*\(&quot;(.*)&quot;\)(\s)*\]"
ReplacementText="[assembly:${1}${2}${3}(&quot;$(Version)&quot;)${5}]"
IgnoreCase="True"/>
</Target>
</Project>