Skip to content

Instantly share code, notes, and snippets.

@jplindgren
Last active December 24, 2015 08:29
Show Gist options
  • Save jplindgren/6770895 to your computer and use it in GitHub Desktop.
Save jplindgren/6770895 to your computer and use it in GitHub Desktop.
Exemplo Arquivo .Build (Uso com MSBuild)
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="BuildComplete" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- General Paths -->
<RootPath>$(MSBuildProjectDirectory)</RootPath>
<SrcPath>$(RootPath)\src</SrcPath>
<ReportsPath>$(RootPath)\reports</ReportsPath>
<ToolsPath>$(RootPath)\tools</ToolsPath>
<Packages>$(SrcPath)\packages</Packages>
<ExternalLib>$(SrcPath)\lib</ExternalLib>
<!-- General Configuration -->
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
<DefineSolutionProperties>false</DefineSolutionProperties>
<MessageBuildComplete>### Build Completo ###</MessageBuildComplete>
<!-- Messages -->
<MessageStartBuilding>Compilando projetos...</MessageStartBuilding>
<MessageStartPublishing>Publicando...</MessageStartPublishing>
<MessageCleaningStuff>Limpando a sujeira...</MessageCleaningStuff>
<MessageStartReporting>Gerando relatórios...</MessageStartReporting>
<!-- Learning -->
<NiceArticleAboutContinousIntegration>http://marcofranssen.nl/ci-with-jenkins-msbuild-nuget-and-git-part-1/</NiceArticleAboutContinousIntegration>
<NiceArticleAboutWebConfigTransform>http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html</NiceArticleAboutWebConfigTransform>
<NiceArticleAboutPublishWithMSBuild>http://codingcockerel.co.uk/2008/05/18/how-to-publish-a-web-site-with-msbuild/</NiceArticleAboutPublishWithMSBuild>
<!-- Tests -->
<TestExecutable>MSTest.exe</TestExecutable>
<!-- Publishing -->
<WebDirPublishPath>$(RootPath)\WebPublished\</WebDirPublishPath>
<WebDirPublishBinPath>$(WebDirPublishPath)\bin\</WebDirPublishBinPath>
</PropertyGroup>
<ItemGroup>
<ProjectFiles Include="**\*.csproj" />
</ItemGroup>
<Target Name="Clean">
<Message Importance="High" Text="$(MessageCleaningStuff)" />
<RemoveDir Directories="$(ReportsPath)" Condition="Exists('$(ReportsPath)')" />
<MakeDir Directories = "$(ReportsPath);$(ReportsPath)\MSpec;$(ReportsPath)\Coverage" />
<!-- Clean the source code projects -->
<MSBuild Projects="@(ProjectFiles)"
ContinueOnError="false"
Targets="Clean"
Properties="Configuration=$(Configuration)" />
</Target>
<Target Name="Compile" DependsOnTargets="Clean" >
<Message Importance="High" Text="$(MessageStartBuilding)" />
<MSBuild Projects="$(SrcPath)\Sentinela.Dominio\Sentinela.Dominio.csproj"
Properties="Configuration=$(Configuration);Platform=$(Platform)" />
<MSBuild Projects="$(SrcPath)\Sentinela.Dao\Sentinela.Dao.csproj"
Properties="Configuration=$(Configuration);Platform=$(Platform)" />
<MSBuild Projects="$(SrcPath)\Sentinela.MVC.UI\Sentinela.MVC.UI.csproj"
Properties="Configuration=$(Configuration);Platform=$(Platform)"
BuildInParallel="true" />
</Target>
<Target Name="TransformLog">
<Message Importance="High" Text="$(MessageStartReporting)" />
<XslTransformation XmlInputPaths="$(RootPath)\msbuild-output.xml" XslInputPath="$(RootPath)\msbuild.xsl" OutputPaths="$(ReportsPath)\log.html" />
</Target>
<Target Name="BuildComplete" DependsOnTargets="Compile" >
<Message Importance="High" Text="$(MessageBuildComplete)" />
<Message Importance="High" Text="$(MessageStartPublishing)" />
<RemoveDir Directories="$(WebDirPublishPath)" ContinueOnError="true" />
<PropertyGroup>
<!--TestSuccessOrNot is the property specify whether the Test is sucess or not -->
<TestSuccessOrNot>1</TestSuccessOrNot>
</PropertyGroup>
<Exec Command="$(TestExecutable) /testcontainer:$(SrcPath)\Sentinela.Tests\bin\$(Configuration)\Sentinela.Tests.dll" >
<Output TaskParameter="ExitCode" PropertyName="TestSuccessOrNot"/>
</Exec>
<MSBuild Condition ="'$(TestSuccessOrNot)'=='0'"
Projects="$(SrcPath)\Sentinela.MVC.UI\Sentinela.MVC.UI.csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="WebProjectOutputDir=$(WebDirPublishPath);OutDir=$(WebDirPublishBinPath)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment