Skip to content

Commit

Permalink
Add build script
Browse files Browse the repository at this point in the history
  • Loading branch information
veblush committed Nov 15, 2015
1 parent 6ec0fa9 commit 1bb8bf6
Show file tree
Hide file tree
Showing 23 changed files with 284 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -172,6 +172,7 @@ ClientBin/
*.publishsettings
node_modules/
orleans.codegen.cs
.fake

# RIA/Silverlight projects
Generated_Code/
Expand Down
2 changes: 2 additions & 0 deletions NOTE.md
@@ -0,0 +1,2 @@
# TODO
## Extensions
11 changes: 11 additions & 0 deletions build.cmd
@@ -0,0 +1,11 @@
@echo off

pushd %~dp0

tools\nuget\NuGet.exe update -self
tools\nuget\NuGet.exe install FAKE -ConfigFile tools\nuget\Nuget.Config -OutputDirectory src\packages -ExcludeVersion -Version 4.7.3

set encoding=utf-8
src\packages\FAKE\tools\FAKE.exe build.fsx %*

popd
53 changes: 53 additions & 0 deletions build.fsx
@@ -0,0 +1,53 @@
#I @"packages/FAKE/tools"
#r "FakeLib.dll"

open Fake
open Fake.FileHelper
open System.IO

// ---------------------------------------------------------------------------- Variables

let buildSolutionFile = "./src/Common.Logging.sln"
let buildConfiguration = "Release"
let binDir = "bin"

// ------------------------------------------------------------------------- Unity Helper

let UnityPath =
@"C:\Program Files\Unity\Editor\Unity.exe"

let Unity projectPath args =
let result = Shell.Exec(UnityPath, "-quit -batchmode -logFile -projectPath \"" + projectPath + "\" " + args)
if result < 0 then failwithf "Unity exited with error %d" result

// ------------------------------------------------------------------------------ Targets

Target "Clean" (fun _ ->
CleanDirs [binDir]
)

Target "Build" (fun _ ->
!! buildSolutionFile
|> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration ]
|> Log "Build-Output: "
Unity (Path.GetFullPath "src/Sample") "-executeMethod PackageBuilder.BuildPackage"
(!! "src/Sample/*.unitypackage") |> Seq.iter (fun p -> MoveFile binDir p)
)

Target "Help" (fun _ ->
List.iter printfn [
"usage:"
"build [target]"
""
" Targets for building:"
" * Build Build"
""]
)

// --------------------------------------------------------------------------- Dependency

// Build order
"Clean"
==> "Build"

RunTargetOrDefault "Help"
10 changes: 9 additions & 1 deletion src/Common.Logging.Extension/Common.Logging.Extension.csproj
Expand Up @@ -41,7 +41,7 @@
<Reference Include="System.Data" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\unity3d\UnityEngine.dll</HintPath>
<HintPath>..\..\tools\unity3d\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -58,6 +58,14 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>$(SolutionDir)..\tools\unity3d\pdb2mdb.exe $(TargetDir)Common.Logging.dll
$(SolutionDir)..\tools\unity3d\pdb2mdb.exe $(TargetDir)Common.Logging.Core.dll
$(SolutionDir)..\tools\unity3d\pdb2mdb.exe $(TargetDir)Common.Logging.Extension.dll
COPY /Y $(TargetDir)Common.Logging.dll* $(SolutionDir)\Sample\Assets\Middleware\CommonLogging
COPY /Y $(TargetDir)Common.Logging.Core.dll* $(SolutionDir)\Sample\Assets\Middleware\CommonLogging
COPY /Y $(TargetDir)Common.Logging.Extension.dll* $(SolutionDir)\Sample\Assets\Middleware\CommonLogging</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
10 changes: 5 additions & 5 deletions src/Common.Logging.Extension/Properties/AssemblyInfo.cs
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Common.Logging.Extension")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Common.Logging.Extension")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCompany("Saladbowl Creative")]
[assembly: AssemblyProduct("Common Logging Extensions for Unity3D")]
[assembly: AssemblyCopyright("Copyright © Saladbowl Creative 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("3.3.1.0")]
[assembly: AssemblyFileVersion("3.3.1.0")]
2 changes: 1 addition & 1 deletion src/Common.Logging.Unity3D/Common.Logging.Unity3D.csproj
Expand Up @@ -43,7 +43,7 @@
<Reference Include="System.Data" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\unity3d\UnityEngine.dll</HintPath>
<HintPath>..\..\tools\unity3d\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Common.Logging.Unity3D/Properties/AssemblyInfo.cs
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.3.0.0")]
[assembly: AssemblyFileVersion("3.3.0.0")]
[assembly: AssemblyVersion("3.3.1.0")]
[assembly: AssemblyFileVersion("3.3.1.0")]

[assembly: System.Security.SecurityTransparent]
[assembly: TypeForwardedTo(typeof(FormatMessageHandler))]
Expand Down
5 changes: 4 additions & 1 deletion src/Sample/.gitignore
Expand Up @@ -18,4 +18,7 @@
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt
sysinfo.txt

# UnityPackage
*.unitypackage
9 changes: 9 additions & 0 deletions src/Sample/Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/Sample/Assets/Editor/PackageBuilder.cs
@@ -0,0 +1,19 @@
using UnityEditor;
using UnityEngine;

public static class PackageBuilder
{
[MenuItem("Assets/BuildPackage")]
public static void BuildPackage()
{
var assetPaths = new string[]
{
"Assets/Middleware/CommonLogging",
"Assets/Middleware/CommonLoggingSample",
};

var packagePath = "Common-Logging-Unity3D.unitypackage";
var options = ExportPackageOptions.Recurse;
AssetDatabase.ExportPackage(assetPaths, packagePath, options);
}
}
12 changes: 12 additions & 0 deletions src/Sample/Assets/Editor/PackageBuilder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified src/Sample/Assets/Middleware/CommonLogging/Common.Logging.dll
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions tools/nuget/NuGet.Config
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<activePackageSource>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</activePackageSource>
</configuration>
144 changes: 144 additions & 0 deletions tools/nuget/NuGet.targets
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
</PropertyGroup>

<PropertyGroup>
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
</PropertyGroup>

<PropertyGroup>
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
Binary file added tools/nuget/nuget.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions tools/nuget/packages.config
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>
File renamed without changes.
File renamed without changes.

0 comments on commit 1bb8bf6

Please sign in to comment.