Add build configs to config file
This commit is contained in:
Родитель
c94ce10367
Коммит
c4d403a9a8
29
build.cake
29
build.cake
|
@ -74,32 +74,13 @@ Setup(context =>
|
|||
AppCenterModules = AppCenterModule.ReadAppCenterModules(ConfigFile, NuspecFolder, version);
|
||||
});
|
||||
|
||||
Task("Build").IsDependentOn("MacBuild").IsDependentOn("WindowsBuild");
|
||||
|
||||
Task("MacBuild")
|
||||
.WithCriteria(() => IsRunningOnUnix())
|
||||
Task("Build")
|
||||
.IsDependentOn("Externals")
|
||||
.Does(() =>
|
||||
{
|
||||
// Run externals here instead of using dependency so that this doesn't get called on windows
|
||||
RunTarget("Externals");
|
||||
// Build solution
|
||||
NuGetRestore("./AppCenter-SDK-Build-Mac.sln");
|
||||
MSBuild("./AppCenter-SDK-Build-Mac.sln", settings => settings.SetConfiguration("Release"));
|
||||
}).OnError(HandleError);
|
||||
|
||||
// Building Windows code task
|
||||
Task("WindowsBuild")
|
||||
.WithCriteria(() => !IsRunningOnUnix())
|
||||
.Does(() =>
|
||||
{
|
||||
var solutionName = "./AppCenter-SDK-Build-Windows.sln";
|
||||
// Build solution
|
||||
NuGetRestore(solutionName);
|
||||
MSBuild(solutionName, settings => settings.SetConfiguration("Release").WithProperty("Platform", "x86"));
|
||||
MSBuild(solutionName, settings => settings.SetConfiguration("Release").WithProperty("Platform", "x64"));
|
||||
MSBuild(solutionName, settings => settings.SetConfiguration("Release").WithProperty("Platform", "ARM"));
|
||||
MSBuild(solutionName, settings => settings.SetConfiguration("Release")); // any cpu
|
||||
MSBuild(solutionName, settings => settings.SetConfiguration("Reference")); // any cpu
|
||||
var platformId = IsRunningOnUnix() ? "mac" : "windows";
|
||||
var buildGroup = new BuildGroup(platformId, ConfigFile);
|
||||
buildGroup.ExecuteBuilds();
|
||||
}).OnError(HandleError);
|
||||
|
||||
Task("PrepareAssemblies").IsDependentOn("Build").Does(()=>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<config>
|
||||
<group id="ios" folder="iOSAssemblies" downloadWindows="true" downloadMac="false" nuspecKey="$ios_dir$">
|
||||
<group id="ios" folder="iOSAssemblies" buildGroup="mac" nuspecKey="$ios_dir$">
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter.iOS/bin/Release/Microsoft.AppCenter.dll"/>
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter.iOS/bin/Release/Microsoft.AppCenter.iOS.Bindings.dll"/>
|
||||
<assembly path="SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.iOS/bin/Release/Microsoft.AppCenter.Analytics.dll"/>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<assembly path="SDK/AppCenterPush/Microsoft.AppCenter.Push.iOS/bin/Release/Microsoft.AppCenter.Push.dll"/>
|
||||
<assembly path="SDK/AppCenterPush/Microsoft.AppCenter.Push.iOS.Bindings/bin/Release/Microsoft.AppCenter.Push.iOS.Bindings.dll"/>
|
||||
</group>
|
||||
<group id="android" folder="AndroidAssmeblies" downloadWindows="true" downloadMac="false" nuspecKey="$android_dir$">
|
||||
<group id="android" folder="AndroidAssmeblies" buildGroup="mac" nuspecKey="$android_dir$">
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter.Android/bin/Release/Microsoft.AppCenter.dll"/>
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter.Android/bin/Release/Microsoft.AppCenter.Android.Bindings.dll"/>
|
||||
<assembly path="SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Android/bin/Release/Microsoft.AppCenter.Analytics.dll"/>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<assembly path="SDK/AppCenterRum/Microsoft.AppCenter.Rum.Android/bin/Release/Microsoft.AppCenter.Rum.dll"/>
|
||||
<assembly path="SDK/AppCenterRum/Microsoft.AppCenter.Rum.Android.Bindings/bin/Release/Microsoft.AppCenter.Rum.Android.Bindings.dll"/>
|
||||
</group>
|
||||
<group id="pcl" folder="PCLAssemblies" downloadWindows="true" downloadMac="false" nuspecKey="$pcl_dir$">
|
||||
<group id="pcl" folder="PCLAssemblies" buildGroup="mac" nuspecKey="$pcl_dir$">
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter/bin/Release/portable-net45+win8+wpa81+wp8/Microsoft.AppCenter.dll"/>
|
||||
<assembly path="SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics/bin/Release/portable-net45+win8+wpa81+wp8/Microsoft.AppCenter.Analytics.dll"/>
|
||||
<assembly path="SDK/AppCenterCrashes/Microsoft.AppCenter.Crashes/bin/Release/portable-net45+win8+wpa81+wp8/Microsoft.AppCenter.Crashes.dll"/>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<assembly path="SDK/AppCenterPush/Microsoft.AppCenter.Push/bin/Release/portable-net45+win8+wpa81+wp8/Microsoft.AppCenter.Push.dll"/>
|
||||
<assembly path="SDK/AppCenterRum/Microsoft.AppCenter.Rum/bin/Release/portable-net45+win8+wpa81+wp8/Microsoft.AppCenter.Rum.dll"/>
|
||||
</group>
|
||||
<group id="netstandard" folder="NETStandardAssemblies" downloadWindows="true" downloadMac="false" nuspecKey="$netstandard_dir$">
|
||||
<group id="netstandard" folder="NETStandardAssemblies" buildGroup="mac" nuspecKey="$netstandard_dir$">
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter/bin/Release/netstandard1.0/Microsoft.AppCenter.dll"/>
|
||||
<assembly path="SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics/bin/Release/netstandard1.0/Microsoft.AppCenter.Analytics.dll"/>
|
||||
<assembly path="SDK/AppCenterCrashes/Microsoft.AppCenter.Crashes/bin/Release/netstandard1.0/Microsoft.AppCenter.Crashes.dll"/>
|
||||
|
@ -42,12 +42,12 @@
|
|||
<assembly path="SDK/AppCenterPush/Microsoft.AppCenter.Push/bin/Release/netstandard1.0/Microsoft.AppCenter.Push.dll"/>
|
||||
<assembly path="SDK/AppCenterRum/Microsoft.AppCenter.Rum/bin/Release/netstandard1.0/Microsoft.AppCenter.Rum.dll"/>
|
||||
</group>
|
||||
<group id="windows_desktop" folder="WindowsDesktopAssemblies" downloadWindows="false" downloadMac="true" nuspecKey="$windows_desktop_dir$">
|
||||
<group id="windows_desktop" folder="WindowsDesktopAssemblies" buildGroup="windows" nuspecKey="$windows_desktop_dir$">
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter.WindowsDesktop/bin/Release/Microsoft.AppCenter.dll"/>
|
||||
<assembly path="SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.WindowsDesktop/bin/Release/Microsoft.AppCenter.Analytics.dll"/>
|
||||
<assembly path="SDK/AppCenterCrashes/Microsoft.AppCenter.Crashes.WindowsDesktop/bin/Release/Microsoft.AppCenter.Crashes.dll"/>
|
||||
</group>
|
||||
<group id="uwp" folder="UWPAssemblies" downloadWindows="false" downloadMac="true" nuspecKey="$uwp_dir$">
|
||||
<group id="uwp" folder="UWPAssemblies" buildGroup="windows" nuspecKey="$uwp_dir$">
|
||||
<!-- Non architecture-specific -->
|
||||
<assembly path="nuget/Microsoft.AppCenter.Crashes.targets"/>
|
||||
<assembly path="SDK/AppCenter/Microsoft.AppCenter.UWP/bin/Release/Microsoft.AppCenter.dll"/>
|
||||
|
@ -95,4 +95,14 @@
|
|||
<module androidModule="app-center-rum-release.aar"
|
||||
dotnetModule="SDK/AppCenterRum/Microsoft.AppCenter.Rum"
|
||||
nuspec="AppCenterRum.nuspec"/>
|
||||
<buildGroup platformId="mac" solutionPath="AppCenter-SDK-Build-Mac.sln">
|
||||
<build configuration="Release"/>
|
||||
</buildGroup>
|
||||
<buildGroup platformId="windows" solutionPath="AppCenter-SDK-Build-Windows.sln">
|
||||
<build configuration="Release" platform="x86"/>
|
||||
<build configuration="Release" platform="x64"/>
|
||||
<build configuration="Release" platform="ARM"/>
|
||||
<build configuration="Release"/>
|
||||
<build configuration="Reference"/>
|
||||
</buildGroup>
|
||||
</config>
|
||||
|
|
|
@ -129,15 +129,15 @@ public class AssemblyGroup
|
|||
public bool Download { get; set; }
|
||||
private AssemblyGroup(XmlNode groupNode, AssemblyGroup parent = null)
|
||||
{
|
||||
string downloadString = Statics.Context.IsRunningOnUnix() ? "downloadMac" : "downloadWindows";
|
||||
AssemblyPaths = new List<string>();
|
||||
Subgroups = new List<AssemblyGroup>();
|
||||
Id = groupNode.Attributes.GetNamedItem("id").Value;
|
||||
NuspecKey = groupNode.Attributes.GetNamedItem("nuspecKey")?.Value;
|
||||
var downloadValue = groupNode.Attributes.GetNamedItem(downloadString)?.Value;
|
||||
if (downloadValue != null)
|
||||
var buildGroup = groupNode.Attributes.GetNamedItem("buildGroup")?.Value;
|
||||
var platformString = Statics.Context.IsRunningOnUnix() ? "mac" : "windows";
|
||||
if (buildGroup != null)
|
||||
{
|
||||
Download = (downloadValue == "true");
|
||||
Download = (buildGroup != platformString);
|
||||
}
|
||||
else if (parent != null)
|
||||
{
|
||||
|
@ -161,4 +161,82 @@ public class AssemblyGroup
|
|||
}
|
||||
}
|
||||
|
||||
public class BuildGroup
|
||||
{
|
||||
private string _platformId;
|
||||
private string _solutionPath;
|
||||
private IList<BuildConfig> _builds;
|
||||
|
||||
private class BuildConfig
|
||||
{
|
||||
private string _platform { get; set; }
|
||||
private string _configuration { get; set; }
|
||||
public BuildConfig(string platform, string configuration)
|
||||
{
|
||||
_platform = platform;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void Build(string solutionPath)
|
||||
{
|
||||
Statics.Context.MSBuild(solutionPath, settings => {
|
||||
settings.SetConfiguration(_configuration);
|
||||
if (_platform != null)
|
||||
{
|
||||
// Use this instead of set target platform
|
||||
settings.WithProperty("Platform", "x86");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public BuildGroup(string platformId, string configFilePath)
|
||||
{
|
||||
_platformId = platformId;
|
||||
XmlReader reader = XmlReader.Create(configFilePath);
|
||||
_builds = new List<BuildConfig>();
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.Name == "buildGroup")
|
||||
{
|
||||
XmlDocument buildGroup = new XmlDocument();
|
||||
var node = buildGroup.ReadNode(reader);
|
||||
if (buildGroup.Attributes.GetNamedItem("platformId").Value == _platformId)
|
||||
{
|
||||
ApplyBuildGroupNode(buildGroup);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteBuilds()
|
||||
{
|
||||
Statics.Context.NuGetRestore(_solutionPath);
|
||||
foreach (var buildConfig in _builds)
|
||||
{
|
||||
buildConfig.Build(_solutionPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyBuildGroupNode(XmlNode buildGroup)
|
||||
{
|
||||
if (buildGroup.Attributes.GetNamedItem("platformId").Value != _platformId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_solutionPath = buildGroup.Attributes.GetNamedItem("solutionPath").Value;
|
||||
for (int i = 0; i < buildGroup.ChildNodes.Count; ++i)
|
||||
{
|
||||
var childNode = buildGroup.ChildNodes.Item(i);
|
||||
if (childNode.Name == "build")
|
||||
{
|
||||
var platform = buildGroup.Attributes.GetNamedItem("platform")?.Value;
|
||||
var configuration = buildGroup.Attributes.GetNamedItem("configuration")?.Value;
|
||||
_builds.Add(new BuildConfig(platform, configuration));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче