Created
May 1, 2014 14:44
-
-
Save russgray/3d3cbdda7de79b4c7c1b to your computer and use it in GitHub Desktop.
Example msbuild script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Start"> | |
<Import Project="lib\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" /> | |
<!-- Variables --> | |
<PropertyGroup> | |
<!-- Release Folder --> | |
<!-- To change the output folder, use the following parameter: /p:BuildDir=C:\BuildTest--> | |
<ReleaseDir>release</ReleaseDir> | |
<!-- Build Folder --> | |
<OutDir>src\Recordset.Net\bin\Release</OutDir> | |
<!-- path to XUnit MSBuild runner --> | |
<XUnitDll>lib\xunit\xunit.runner.msbuild.dll</XUnitDll> | |
<!-- Build Folder for test assembly --> | |
<TestOutDir>src\Recordset.Net.Tests\bin\Release</TestOutDir> | |
<!-- run unit tests? --> | |
<RunTests>0</RunTests> | |
<!-- create NuGet package? --> | |
<CreatePackage>0</CreatePackage> | |
<!-- temporary NuGet working folder --> | |
<NuGetDir>nuget-tmp</NuGetDir> | |
<!-- create zip file? --> | |
<CreateZip>0</CreateZip> | |
</PropertyGroup> | |
<!-- "Autostart" --> | |
<Target Name="Start"> | |
<CallTarget Targets="DeleteFolders"/> | |
<CallTarget Targets="Build"/> | |
<CallTarget Condition="$(RunTests) == '1'" Targets="RunTests"/> | |
<CallTarget Targets="CopyRelease"/> | |
<CallTarget Condition="$(CreatePackage) == '1'" Targets="NuGet"/> | |
<CallTarget Condition="$(CreateZip) == '1'" Targets="Zip"/> | |
</Target> | |
<!-- delete build folders --> | |
<Target Name="DeleteFolders"> | |
<RemoveDir Directories="$(ReleaseDir)"/> | |
<RemoveDir Directories="$(NuGetDir)"/> | |
</Target> | |
<!-- compile solution as release --> | |
<Target Name="Build"> | |
<MSBuild Projects="src\Recordset.Net.sln" Properties="Configuration=Release"/> | |
</Target> | |
<!-- run unit tests --> | |
<UsingTask AssemblyFile="$(XUnitDll)" TaskName="Xunit.Runner.MSBuild.xunit"/> | |
<Target Name="RunTests"> | |
<xunit Assembly="$(TestOutDir)\Recordset.Net.Tests.dll" /> | |
</Target> | |
<!-- copy files to release folder --> | |
<Target Name="CopyRelease"> | |
<MakeDir Directories="$(ReleaseDir)\bin"/> | |
<ItemGroup> | |
<ReleaseFiles | |
Include="$(OutDir)\*.*; | |
readme-release.txt; | |
License.txt" | |
Exclude="$(OutDir)\*.pdb; | |
$(OutDir)\Interop.ADODB.dll"> | |
</ReleaseFiles> | |
</ItemGroup> | |
<Copy SourceFiles="@(ReleaseFiles)" DestinationFolder="$(ReleaseDir)\bin"/> | |
<Move SourceFiles="$(ReleaseDir)\bin\readme-release.txt" DestinationFiles="$(ReleaseDir)\bin\readme.txt" /> | |
</Target> | |
<!-- make NuGet package--> | |
<Target Name="NuGet"> | |
<MakeDir Directories="$(NuGetDir)\lib\net40"/> | |
<MakeDir Directories="$(ReleaseDir)\nuget"/> | |
<!-- 1. copy the whole release folder (except the assembly and "normal" readme) and the nuspec file into the temp. NuGet folder --> | |
<ItemGroup> | |
<PackageFiles1 | |
Include="$(ReleaseDir)\bin\*.*; | |
nuget\Recordset.Net.nuspec" | |
Exclude="$(ReleaseDir)\bin\*.dll; | |
$(ReleaseDir)\bin\*.xml"> | |
</PackageFiles1> | |
</ItemGroup> | |
<Copy SourceFiles="@(PackageFiles1)" DestinationFolder="$(NuGetDir)"/> | |
<!-- 2. copy the assembly into the net40 subfolder --> | |
<ItemGroup> | |
<PackageFiles2 | |
Include="$(ReleaseDir)\bin\*.dll; | |
$(ReleaseDir)\bin\*.xml"> | |
</PackageFiles2> | |
</ItemGroup> | |
<Copy SourceFiles="@(PackageFiles2)" DestinationFolder="$(NuGetDir)\lib\net40"/> | |
<!-- 3. create package --> | |
<Exec Command="lib\nuget\nuget.exe pack $(NuGetDir)\recordset.net.nuspec -OutputDirectory $(ReleaseDir)\nuget -Version $(VersionNumber)"></Exec> | |
</Target> | |
<!-- create zip file with content of release\bin folder --> | |
<Target Name="Zip"> | |
<CreateItem Include="$(ReleaseDir)\bin\*.*" > | |
<Output ItemName="ZipFiles" TaskParameter="Include"/> | |
</CreateItem> | |
<Zip ZipFileName="$(ReleaseDir)\zip\recordset.net-$(VersionNumber).zip" WorkingDirectory="$(ReleaseDir)\bin" Files="@(ZipFiles)" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment