Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Add more build infrastructure
Browse files Browse the repository at this point in the history
This adds basic build/clean.cmd as well as traversal projects.
  • Loading branch information
weshaggard committed Sep 2, 2016
1 parent ccbe4e6 commit 1c79b3b
Show file tree
Hide file tree
Showing 11 changed files with 373 additions and 14 deletions.
2 changes: 1 addition & 1 deletion BuildToolsVersion.txt
@@ -1 +1 @@
1.0.26-prerelease-00711-02
1.0.26-prerelease-00731-01
2 changes: 2 additions & 0 deletions build.cmd
@@ -0,0 +1,2 @@
@call %~dp0run.cmd build-managed %*
@exit /b %ERRORLEVEL%
29 changes: 29 additions & 0 deletions clean.cmd
@@ -0,0 +1,29 @@
@if "%_echo%" neq "on" echo off
setlocal EnableDelayedExpansion

echo Stop VBCSCompiler.exe execution.
for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq VBCSCompiler.exe" /fo csv') do taskkill /f /PID %%~F

if [%1] == [-all] (
echo Cleaning entire working directory ...
call git clean -xdf
exit /b !ERRORLEVEL!
)

if [%1]==[] set __args=-b
call %~dp0run.cmd clean %__args% %*
exit /b %ERRORLEVEL%

:Usage
echo.
echo Repository cleaning script.
echo.
echo Options:
echo -b - Deletes the binary output directory.
echo -p - Deletes the repo-local nuget package directory.
echo -c - Deletes the user-local nuget package cache.
echo -all - Combines all of the above.
echo.
echo If no option is specified then clean.cmd -b is implied.

exit /b 1
150 changes: 150 additions & 0 deletions config.json
@@ -0,0 +1,150 @@
{
"settings": {
"ConfigurationGroup": {
"description": "Sets the configuration group as Release or Debug",
"valueType": "property",
"values": ["Release", "Debug"],
"defaultValue": "Debug"
},
"MsBuildLogging": {
"description": "MsBuild logging options.",
"valueType": "passThrough",
"values": [],
"defaultValue": "/flp:v=normal"
},
"MsBuildWarning": {
"description": "MsBuild warning logging.",
"valueType": "passThrough",
"values": [],
"defaultValue": "/flp2:warningsonly;logfile=msbuild.wrn"
},
"MsBuildError": {
"description": "MsBuild error logging.",
"valueType": "passThrough",
"values": [],
"defaultValue": "/flp3:errorsonly;logfile=msbuild.err"
},
"MsBuildParameters": {
"description": "MsBuild building options.",
"valueType": "passThrough",
"values": [],
"defaultValue": "/nologo /maxcpucount /verbosity:minimal /clp:Summary"
},
"MsBuildBinClashLogger-Windows": {
"description": "MsBuild Bin clash logger options for Windows.",
"valueType": "passThrough",
"values": [],
"defaultValue": "/l:BinClashLogger,Tools\\net45\\Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log"
},
"Project": {
"description": "Project where the commands are going to be applied.",
"valueType": "passThrough",
"values": [],
"defaultValue": ""
},
"CleanAllProjects": {
"description": "MsBuild target that deletes the binary output directory.",
"valueType": "target",
"values": [],
"defaultValue": ""
},
"CleanPackages": {
"description": "MsBuild target that deletes the repo-local nuget package directory.",
"valueType": "target",
"values": [],
"defaultValue": ""
},
"CleanPackagesCache": {
"description": "MsBuild target that deletes the user-local nuget package cache.",
"valueType": "target",
"values": [],
"defaultValue": ""
}
},
"commands": {
"build-managed":{
"alias":{
"binaries":{
"description": "Only builds binaries. It doesn't restore packages.",
"settings":{
"RestoreDuringBuild": false,
"BuildTests": false,
"BuildPackages": false
}
},
"debug":{
"description": "Sets ConfigurationGroup=Debug or the value passed by the user.",
"settings":{
"ConfigurationGroup": "Debug"
}
},
"release":{
"description": "Sets ConfigurationGroup=Release or the value passed by the user.",
"settings":{
"ConfigurationGroup": "Release"
}
},
},
"defaultValues":{
"toolName": "msbuild",
"settings": {
"ConfigurationGroup": "default",
"MsBuildLogging":"default",
"MsBuildWarning":"default",
"MsBuildError":"default"
}
}
},
"clean":{
"alias":{
"b":{
"description": "Deletes the binary output directory.",
"settings":{
"CleanAllProjects": "default"
}
},
"p":{
"description": "Deletes the repo-local nuget package directory.",
"settings":{
"CleanPackages": "default"
}
},
"c":{
"description": "Deletes the user-local nuget package cache.",
"settings":{
"CleanPackagesCache": "default"
}
}
},
"defaultValues":{
"toolName": "msbuild",
"settings": {
"MsBuildLogging":"/flp:v=normal;LogFile=clean.log"
}
}
}
},
"tools": {
"msbuild": {
"osSpecific": {
"windows": {
"defaultParameters": "/nologo /verbosity:minimal /clp:Summary /maxcpucount /nodeReuse:false /l:BinClashLogger,Tools\\net45\\Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log",
"path": "Tools/msbuild.cmd"
},
},
"valueTypes": {
"property": "/p:{name}={value}",
"target": "/t:{name}",
"internal": "/{name}"
}
},
"terminal": {
"osSpecific": {
"windows": {
"filesExtension": "cmd"
},
},
"valueTypes": {}
}
}
}
17 changes: 17 additions & 0 deletions dir.proj
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="netstandard/ref/*.csproj" />
<Project Include="netstandard/src/*.builds" />
<Project Include="platforms/dir.proj" />
</ItemGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />

<!-- Override CleanAllProjects from dir.traversal.targets and just remove the full BinDir -->
<Target Name="CleanAllProjects">
<RemoveDir Directories="$(BinDir)" />
</Target>
</Project>

60 changes: 53 additions & 7 deletions dir.props
Expand Up @@ -48,21 +48,61 @@
</PropertyGroup>

<!--
If Configuration is empty that means we are not being built in VS
Projects that have no OS-specific implementations just use Debug and Release for $(Configuration).
Projects that do have OS-specific implementations use OS_Debug and OS_Release, for all OS's we support even
if the code is the same between some OS's (so if you have some project that just calls POSIX APIs, we still have
OSX_[Debug|Release] and Linux_[Debug|Release] configurations. We do this so that we place all the output under
a single binary folder and can have a similar experience between the command line and Visual Studio.
-->

<!--
If Configuration is empty that means we are not being built in VS and so folks need to explicitly pass the different
values for $(ConfigurationGroup), $(TargetGroup), or $(OSGroup) or accept the defaults for them.
-->
<PropertyGroup Condition="'$(Configuration)'==''">
<ConfigurationGroup Condition="'$(ConfigurationGroup)'==''">Debug</ConfigurationGroup>
<Configuration>$(ConfigurationGroup)</Configuration>
<Configuration Condition="'$(TargetGroup)'!=''">$(TargetGroup)_$(Configuration)</Configuration>
<Configuration Condition="'$(OSGroup)'!='' and '$(OSGroup)'!='AnyOS'">$(OSGroup)_$(Configuration)</Configuration>
</PropertyGroup>

<!--
If Configuration is set then someone explicitly passed it in or we are building from VS. In either case
default $(ConfigurationGroup) from the Configuration if it isn't already explicitly set.
If Configuration is set then someone explicitly passed it in or we building from VS. In either case
default $(ConfigurationGroup), $(TargetGroup), or $(OSGroup) from the Configuration if they aren't
already explicitly set.
-->
<PropertyGroup Condition="'$(Configuration)'!=''">
<ConfigurationGroup Condition="'$(ConfigurationGroup)'=='' and $(Configuration.EndsWith('Debug'))">Debug</ConfigurationGroup>
<ConfigurationGroup Condition="'$(ConfigurationGroup)'=='' and $(Configuration.EndsWith('Release'))">Release</ConfigurationGroup>
<ConfigurationGroup Condition="'$(ConfigurationGroup)'==''">Debug</ConfigurationGroup>

<BuildAllOSGroups Condition="'$(BuildAllOSGroups)' == ''">true</BuildAllOSGroups>

<OSGroup Condition="'$(OSGroup)'=='' and $(Configuration.StartsWith('Windows'))">Windows_NT</OSGroup>
<OSGroup Condition="'$(OSGroup)'=='' and $(Configuration.StartsWith('Unix'))">Unix</OSGroup>
<OSGroup Condition="'$(OSGroup)'=='' and $(Configuration.StartsWith('Linux'))">Linux</OSGroup>
<OSGroup Condition="'$(OSGroup)'=='' and $(Configuration.StartsWith('OSX'))">OSX</OSGroup>
<OSGroup Condition="'$(OSGroup)'=='' and $(Configuration.StartsWith('FreeBSD'))">FreeBSD</OSGroup>
<OSGroup Condition="'$(OSGroup)'=='' and $(Configuration.StartsWith('NetBSD'))">NetBSD</OSGroup>
<OSGroup Condition="'$(OSGroup)'==''">AnyOS</OSGroup>

<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('netcore50aot'))">netcore50aot</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('netstandard13aot'))">netstandard13aot</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('netstandard15aot'))">netstandard15aot</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('netcore50'))">netcore50</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('netcoreapp1.0'))">netcoreapp1.0</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('netcoreapp1.1'))">netcoreapp1.1</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('dnxcore50'))">dnxcore50</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('net463'))">net463</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('net462'))">net462</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('net461'))">net461</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('net46'))">net46</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('net45'))">net45</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('net451'))">net451</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('win8'))">win8</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('wpa81'))">wpa81</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('uap101aot'))">uap101aot</TargetGroup>
<TargetGroup Condition="'$(TargetGroup)'=='' and $(Configuration.Contains('uap101'))">uap101</TargetGroup>
</PropertyGroup>

<!-- Set up Default symbol and optimization for Configuration -->
Expand Down Expand Up @@ -106,13 +146,19 @@

<!-- Set up the default output and intermediate paths -->
<PropertyGroup>
<OSPlatformConfig>$(OSGroup).$(Platform).$(ConfigurationGroup)</OSPlatformConfig>
<TargetOutputRelPath Condition="'$(TargetGroup)'!=''">$(TargetGroup)/</TargetOutputRelPath>

<BaseOutputPath Condition="'$(BaseOutputPath)'==''">$(BinDir)</BaseOutputPath>
<OutputPath Condition="'$(OutputPath)'==''">$(BaseOutputPath)$(MSBuildProjectName)/$(OutputPathSubfolder)</OutputPath>
<OutputPathSubfolder Condition="'$(IsCompatAssembly)'=='true'">/Compat</OutputPathSubfolder>
<OutputPath Condition="'$(OutputPath)'==''">$(BaseOutputPath)$(OSPlatformConfig)/$(MSBuildProjectName)/$(TargetOutputRelPath)$(OutputPathSubfolder)</OutputPath>

<IntermediateOutputRootPath Condition="'$(IntermediateOutputRootPath)' == ''">$(BaseIntermediateOutputPath)$(OSPlatformConfig)/</IntermediateOutputRootPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(IntermediateOutputRootPath)$(MSBuildProjectName)/$(TargetOutputRelPath)</IntermediateOutputPath>

<IntermediateOutputRootPath Condition="'$(IntermediateOutputRootPath)' == ''">$(BaseIntermediateOutputPath)</IntermediateOutputRootPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(IntermediateOutputRootPath)$(MSBuildProjectName)</IntermediateOutputPath>
<TestPath Condition="'$(TestPath)'==''">$(TestWorkingDir)$(OSPlatformConfig)/$(MSBuildProjectName)/</TestPath>

<PackagesBasePath Condition="'$(PackagesBasePath)'==''">$(BinDir)</PackagesBasePath>
<PackagesBasePath Condition="'$(PackagesBasePath)'==''">$(BinDir)$(OSPlatformConfig)</PackagesBasePath>
<PackageOutputPath Condition="'$(PackageOutputPath)'==''">$(PackageOutputRoot)$(ConfigurationGroup)/</PackageOutputPath>
<SymbolPackageOutputPath Condition="'$(SymbolPackageOutputPath)'==''">$(PackageOutputPath)symbols/</SymbolPackageOutputPath>
</PropertyGroup>
Expand Down
75 changes: 75 additions & 0 deletions dir.traversal.targets
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="FilterProjects">
<ItemGroup>
<!-- list each append as a seperate item to force re-evaluation of AdditionalProperties metadata -->
<Project>
<AdditionalProperties Condition="'%(Project.TargetGroup)'!=''">TargetGroup=%(Project.TargetGroup);%(Project.AdditionalProperties)</AdditionalProperties>
</Project>
</ItemGroup>
</Target>

<Target Name="BuildAllProjects" DependsOnTargets="FilterProjects">
<PropertyGroup>
<DefaultBuildAllTarget Condition="'$(DefaultBuildAllTarget)'==''">$(MSBuildProjectDefaultTargets)</DefaultBuildAllTarget>
</PropertyGroup>

<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
however since the project names are unique it will essentially force each to run in its own batch -->
<MSBuild Targets="$(DefaultBuildAllTarget)"
Projects="@(Project)"
Condition="'$(SerializeProjects)'=='true' AND '%(Identity)' != ''"
Properties="DefaultBuildAllTarget=$(DefaultBuildAllTarget);BuildAllProjects=true"
ContinueOnError="ErrorAndContinue" />

<MSBuild Targets="$(DefaultBuildAllTarget)"
Projects="@(Project)"
Condition="'$(SerializeProjects)'!='true'"
Properties="DefaultBuildAllTarget=$(DefaultBuildAllTarget);BuildAllProjects=true"
BuildInParallel="true"
ContinueOnError="ErrorAndContinue" />

<!-- Given we ErrorAndContinue we need to propagate the error if the overall task failed -->
<Error Condition="'$(MSBuildLastTaskResult)'=='false'" />
</Target>

<Target Name="CleanAllProjects" DependsOnTargets="FilterProjects">
<PropertyGroup>
<DefaultCleanAllTarget Condition="'$(DefaultCleanAllTarget)'==''">Clean</DefaultCleanAllTarget>
</PropertyGroup>

<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
however since the project names are unique it will essentially force each to run in its own batch -->
<MSBuild Targets="$(DefaultCleanAllTarget)"
Projects="@(Project)"
Condition="'$(SerializeProjects)'=='true' AND '%(Identity)' != ''"
Properties="CleanAllProjects=true"
ContinueOnError="ErrorAndContinue" />

<MSBuild Targets="$(DefaultCleanAllTarget)"
Projects="@(Project)"
Condition="'$(SerializeProjects)'!='true'"
Properties="CleanAllProjects=true"
BuildInParallel="true"
ContinueOnError="ErrorAndContinue" />

<!-- Given we ErrorAndContinue we need to propagate the error if the overall task failed -->
<Error Condition="'$(MSBuildLastTaskResult)'=='false'" />
</Target>

<PropertyGroup>
<TraversalBuildDependsOn>
BuildAllProjects;
$(TraversalBuildDependsOn);
</TraversalBuildDependsOn>

<TraversalCleanDependsOn>
CleanAllProjects;
$(TraversalCleanDependsOn);
</TraversalCleanDependsOn>
</PropertyGroup>

<Target Name="Build" DependsOnTargets="$(TraversalBuildDependsOn)" />
<Target Name="Clean" DependsOnTargets="$(TraversalCleanDependsOn)" />
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
</Project>
14 changes: 14 additions & 0 deletions platforms/dir.proj
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="net461/*.csproj">
<TargetGroup>net461</TargetGroup>
</Project>
<Project Include="xamarin.ios/*.csproj">
<TargetGroup>xamarin.ios</TargetGroup>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

0 comments on commit 1c79b3b

Please sign in to comment.