Browse Source

Fixed build script for windows

pull/919/head
Nikita Tsukanov 9 years ago
parent
commit
4bb5ebf070
  1. 2
      appveyor.yml
  2. 73
      build.cake
  3. 52
      packages.cake
  4. 2
      src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj
  5. 2
      src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj

2
appveyor.yml

@ -1,4 +1,4 @@
os: Visual Studio 2015 os: Visual Studio 2017
platform: platform:
- Any CPU - Any CPU
configuration: configuration:

73
build.cake

@ -96,46 +96,10 @@ Task("Clean")
CleanDirectory(parameters.TestsRoot); CleanDirectory(parameters.TestsRoot);
}); });
Task("Prepare-XBuild-Solution")
.Does(() =>
{
var blacklistedProjects = new[]
{
"Avalonia.Win32.NetStandard",
"Avalonia.DotNetCoreRuntime",
"Avalonia.Skia.Desktop.NetStandard",
"Avalonia.Gtk3"
};
var blacklistedGuids = System.IO.File.ReadAllLines(parameters.MSBuildSolution)
.Where(l=>l.StartsWith("Project") && blacklistedProjects.Any(p=>l.Contains(p)))
.Select(l => l.Split(',').Select(part => part.Trim()).FirstOrDefault(part => part.StartsWith("\"{")))
.Where(g=>g!=null)
.Select(l=>l.Trim(new[]{'"', '}', '{'}).ToLower()).ToArray();
Console.WriteLine("Blacklisted guids are: " + string.Join(",", blacklistedGuids));
var removeUntilEndProject = false;
System.IO.File.WriteAllLines(parameters.XBuildSolution, System.IO.File.ReadAllLines(parameters.MSBuildSolution)
.Where(l =>
{
if(removeUntilEndProject)
{
if(l.StartsWith("EndProject"))
removeUntilEndProject = false;
return false;
}
var blacklist = blacklistedGuids.Any(g => l.ToLower().Contains(g));
if(blacklist && l.StartsWith("Project"))
removeUntilEndProject = true;
return !blacklist;
}));
});
Task("Restore-NuGet-Packages") Task("Restore-NuGet-Packages")
.IsDependentOn("Clean") .IsDependentOn("Clean")
.IsDependentOn("Prepare-XBuild-Solution") .WithCriteria(parameters.IsRunningOnWindows)
.Does(() => .Does(() =>
{ {
var maxRetryCount = 5; var maxRetryCount = 5;
@ -168,6 +132,14 @@ Task("Restore-NuGet-Packages")
}); });
}); });
void DotNetCoreBuild()
{
}
Task("DotNetCoreBuild")
.IsDependentOn("Clean")
.Does(() => DotNetCoreBuild());
Task("Build") Task("Build")
.IsDependentOn("Restore-NuGet-Packages") .IsDependentOn("Restore-NuGet-Packages")
.Does(() => .Does(() =>
@ -179,25 +151,34 @@ Task("Build")
settings.WithProperty("Platform", "\"" + parameters.Platform + "\""); settings.WithProperty("Platform", "\"" + parameters.Platform + "\"");
settings.SetVerbosity(Verbosity.Minimal); settings.SetVerbosity(Verbosity.Minimal);
settings.WithProperty("Windows", "True"); settings.WithProperty("Windows", "True");
settings.UseToolVersion(MSBuildToolVersion.VS2015); settings.UseToolVersion(MSBuildToolVersion.VS2017);
settings.SetNodeReuse(false); settings.SetNodeReuse(false);
}); });
} }
else else
{ {
XBuild(parameters.XBuildSolution, settings => { DotNetCoreBuild();
settings.SetConfiguration(parameters.Configuration);
settings.WithProperty("Platform", "\"" + parameters.Platform + "\"");
settings.SetVerbosity(Verbosity.Minimal);
});
} }
}); });
void RunDotNetCoreTest()
{
}
Task("Run-Net-Core-Unit-Tests")
.IsDependentOn("Clean")
.Does(() => RunDotNetCoreTest());
Task("Run-Unit-Tests") Task("Run-Unit-Tests")
.IsDependentOn("Build") .IsDependentOn("Build")
.WithCriteria(() => !parameters.SkipTests) .WithCriteria(() => !parameters.SkipTests)
.Does(() => .Does(() =>
{ {
if(parameters.IsRunningOnWindows)
{
RunDotNetCoreTest();
}
var unitTests = GetDirectories("./tests/Avalonia.*.UnitTests") var unitTests = GetDirectories("./tests/Avalonia.*.UnitTests")
.Select(dir => System.IO.Path.GetFileName(dir.FullPath)) .Select(dir => System.IO.Path.GetFileName(dir.FullPath))
.Where(name => parameters.IsRunningOnWindows ? true : !(name.IndexOf("Direct2D", StringComparison.OrdinalIgnoreCase) >= 0)) .Where(name => parameters.IsRunningOnWindows ? true : !(name.IndexOf("Direct2D", StringComparison.OrdinalIgnoreCase) >= 0))
@ -236,7 +217,11 @@ Task("Run-Unit-Tests")
{ {
CopyDirectory(test.GetDirectory(), parameters.TestsRoot); CopyDirectory(test.GetDirectory(), parameters.TestsRoot);
} }
CopyFile(System.IO.Path.Combine(packages.NugetPackagesDir, "SkiaSharp", packages.SkiaSharpVersion,
"runtimes", "win7-x86", "native", "libSkiaSharp.dll"),
System.IO.Path.Combine(parameters.TestsRoot.ToString(), "libSkiaSharp.dll"));
var testsInDirectoryToRun = new List<FilePath>(); var testsInDirectoryToRun = new List<FilePath>();
if(parameters.IsRunningOnWindows) if(parameters.IsRunningOnWindows)
{ {

52
packages.cake

@ -1,9 +1,12 @@
using System.Xml.Linq;
public class Packages public class Packages
{ {
public List<NuGetPackSettings> NuspecNuGetSettings { get; private set; } public List<NuGetPackSettings> NuspecNuGetSettings { get; private set; }
public FilePath[] NugetPackages { get; private set; } public FilePath[] NugetPackages { get; private set; }
public FilePath[] BinFiles { get; private set; } public FilePath[] BinFiles { get; private set; }
public string NugetPackagesDir {get; private set;}
public string SkiaSharpVersion {get; private set; }
public Packages(ICakeContext context, Parameters parameters) public Packages(ICakeContext context, Parameters parameters)
{ {
// NUGET NUSPECS // NUGET NUSPECS
@ -23,21 +26,27 @@ public class Packages
// Value is Tuple where Item1: Package Version, Item2: The packages.config file path. // Value is Tuple where Item1: Package Version, Item2: The packages.config file path.
var packageVersions = new Dictionary<string, IList<Tuple<string,string>>>(); var packageVersions = new Dictionary<string, IList<Tuple<string,string>>>();
System.IO.Directory.EnumerateFiles(((DirectoryPath)context.Directory("./src")).FullPath, "packages.config", SearchOption.AllDirectories).ToList().ForEach(fileName => System.IO.Directory.EnumerateFiles(((DirectoryPath)context.Directory("./src")).FullPath,
"*.csproj", SearchOption.AllDirectories).ToList().ForEach(fileName =>
{ {
if (!ignoredSubModulesPaths.Any(i => normalizePath(fileName).Contains(normalizePath(i)))) if (!ignoredSubModulesPaths.Any(i => normalizePath(fileName).Contains(normalizePath(i))))
{ {
var file = new PackageReferenceFile(fileName); var xdoc = XDocument.Load(fileName);
foreach (PackageReference packageReference in file.GetPackageReferences()) foreach (var reference in xdoc.Descendants().Where(x => x.Name.LocalName == "PackageReference"))
{ {
var name = reference.Attribute("Include").Value;
var versionAttribute = reference.Attribute("Version");
var version = versionAttribute != null
? versionAttribute.Value
: reference.Elements().First(x=>x.Name.LocalName == "Version").Value;
IList<Tuple<string, string>> versions; IList<Tuple<string, string>> versions;
packageVersions.TryGetValue(packageReference.Id, out versions); packageVersions.TryGetValue(name, out versions);
if (versions == null) if (versions == null)
{ {
versions = new List<Tuple<string, string>>(); versions = new List<Tuple<string, string>>();
packageVersions[packageReference.Id] = versions; packageVersions[name] = versions;
} }
versions.Add(Tuple.Create(packageReference.Version.ToString(), fileName)); versions.Add(Tuple.Create(version, fileName));
} }
} }
}); });
@ -65,7 +74,7 @@ public class Packages
var SplatVersion = packageVersions["Splat"].FirstOrDefault().Item1; var SplatVersion = packageVersions["Splat"].FirstOrDefault().Item1;
var SpracheVersion = packageVersions["Sprache"].FirstOrDefault().Item1; var SpracheVersion = packageVersions["Sprache"].FirstOrDefault().Item1;
var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1; var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1;
var SkiaSharpVersion = packageVersions["SkiaSharp"].FirstOrDefault().Item1; SkiaSharpVersion = packageVersions["SkiaSharp"].FirstOrDefault().Item1;
var SharpDXVersion = packageVersions["SharpDX"].FirstOrDefault().Item1; var SharpDXVersion = packageVersions["SharpDX"].FirstOrDefault().Item1;
var SharpDXDirect2D1Version = packageVersions["SharpDX.Direct2D1"].FirstOrDefault().Item1; var SharpDXDirect2D1Version = packageVersions["SharpDX.Direct2D1"].FirstOrDefault().Item1;
var SharpDXDirect3D11Version = packageVersions["SharpDX.Direct3D11"].FirstOrDefault().Item1; var SharpDXDirect3D11Version = packageVersions["SharpDX.Direct3D11"].FirstOrDefault().Item1;
@ -81,6 +90,11 @@ public class Packages
context.Information("Package: SharpDX.Direct3D11, version: {0}", SharpDXDirect3D11Version); context.Information("Package: SharpDX.Direct3D11, version: {0}", SharpDXDirect3D11Version);
context.Information("Package: SharpDX.DXGI, version: {0}", SharpDXDXGIVersion); context.Information("Package: SharpDX.DXGI, version: {0}", SharpDXDXGIVersion);
var nugetPackagesDir = System.Environment.GetEnvironmentVariable("NUGET_HOME")
?? System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("USERPROFILE"), ".nuget");
NugetPackagesDir = System.IO.Path.Combine(nugetPackagesDir, "packages");
var SetNuGetNuspecCommonProperties = new Action<NuGetPackSettings> ((nuspec) => { var SetNuGetNuspecCommonProperties = new Action<NuGetPackSettings> ((nuspec) => {
nuspec.Version = parameters.Version; nuspec.Version = parameters.Version;
nuspec.Authors = new [] { "Avalonia Team" }; nuspec.Authors = new [] { "Avalonia Team" };
@ -129,12 +143,12 @@ public class Packages
}; };
var coreLibrariesFiles = coreLibraries.Select((lib) => { var coreLibrariesFiles = coreLibraries.Select((lib) => {
return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/" + lib[1] + lib[2]); return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/netstandard1.1/" + lib[1] + lib[2]);
}).ToList(); }).ToList();
var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => {
return new NuSpecContent { return new NuSpecContent {
Source = file.FullPath, Target = "lib/portable-windows8+net45" Source = file.FullPath, Target = "lib/netstandard1.1"
}; };
}); });
@ -161,7 +175,7 @@ public class Packages
var netCoreRuntimePlatformExtensions = new [] {".xml", ".dll"}; var netCoreRuntimePlatformExtensions = new [] {".xml", ".dll"};
var netCoreRuntimePlatform = netCoreRuntimePlatformExtensions.Select(libSuffix => { var netCoreRuntimePlatform = netCoreRuntimePlatformExtensions.Select(libSuffix => {
return new NuSpecContent { return new NuSpecContent {
Source = ((FilePath)context.File("./src/Avalonia.DotNetCoreRuntime/bin/" + parameters.DirSuffix + "/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath, Source = ((FilePath)context.File("./src/Avalonia.DotNetCoreRuntime/bin/" + parameters.DirSuffix + "/netcoreapp1.0/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath,
Target = "lib/netcoreapp1.0" Target = "lib/netcoreapp1.0"
}; };
}); });
@ -180,12 +194,12 @@ public class Packages
new NuSpecDependency() { Id = "Splat", Version = SplatVersion }, new NuSpecDependency() { Id = "Splat", Version = SplatVersion },
new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion }, new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion }, new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion },
new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" },
//.NET Core //.NET Core
new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" },
new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp1.0", Version = "1.6.0" }, new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp1.0", Version = "1.6.0" },
new NuSpecDependency() { Id = "Microsoft.NETCore.Portable.Compatibility", TargetFramework = "netcoreapp1.0", Version = "1.0.1" }, new NuSpecDependency() { Id = "Microsoft.NETCore.Portable.Compatibility", TargetFramework = "netcoreapp1.0", Version = "1.0.1" },
new NuSpecDependency() { Id = "Splat", TargetFramework = "netcoreapp1.0", Version = "2.0.0" }, new NuSpecDependency() { Id = "Splat", TargetFramework = "netcoreapp1.0", Version = SplatVersion },
new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp1.0", Version = "2.3.0" }, new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp1.0", Version = SerilogVersion },
new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp1.0", Version = SpracheVersion }, new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp1.0", Version = SpracheVersion },
new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp1.0", Version = SystemReactiveVersion } new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp1.0", Version = SystemReactiveVersion }
}, },
@ -208,9 +222,9 @@ public class Packages
}, },
Files = new [] Files = new []
{ {
new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/portable-windows8+net45" } new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/netstandard1.1" }
}, },
BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix), BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix + "/netstandard1.1"),
OutputDirectory = parameters.NugetRoot OutputDirectory = parameters.NugetRoot
} }
}; };
@ -324,7 +338,7 @@ public class Packages
Files = new [] Files = new []
{ {
new NuSpecContent { Source = "Avalonia.Win32/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/net45" }, new NuSpecContent { Source = "Avalonia.Win32/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/netstandard1.1" } new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/netstandard1.1/Avalonia.Win32.dll", Target = "lib/netstandard1.1" }
}, },
BasePath = context.Directory("./src/Windows"), BasePath = context.Directory("./src/Windows"),
OutputDirectory = parameters.NugetRoot OutputDirectory = parameters.NugetRoot
@ -381,7 +395,7 @@ public class Packages
{ {
new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.1" } new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.1" }
}, },
BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix), BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix + "/netstandard1.1"),
OutputDirectory = parameters.NugetRoot OutputDirectory = parameters.NugetRoot
}, },
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -420,7 +434,7 @@ public class Packages
Files = new [] Files = new []
{ {
new NuSpecContent { Source = "Avalonia.Skia.Desktop/bin/" + parameters.DirSuffixSkia + "/Avalonia.Skia.Desktop.dll", Target = "lib/net45" }, new NuSpecContent { Source = "Avalonia.Skia.Desktop/bin/" + parameters.DirSuffixSkia + "/Avalonia.Skia.Desktop.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Avalonia.Skia.Desktop.NetStandard/bin/" + parameters.DirSuffix + "/Avalonia.Skia.Desktop.dll", Target = "lib/netcoreapp1.0" } new NuSpecContent { Source = "Avalonia.Skia.Desktop.NetStandard/bin/" + parameters.DirSuffix + "/netstandard1.3/Avalonia.Skia.Desktop.dll", Target = "lib/netcoreapp1.0" }
}, },
BasePath = context.Directory("./src/Skia/"), BasePath = context.Directory("./src/Skia/"),
OutputDirectory = parameters.NugetRoot OutputDirectory = parameters.NugetRoot

2
src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework> <TargetFramework>netcoreapp1.0</TargetFramework>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems> <EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup> </PropertyGroup>

2
src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj

@ -3,6 +3,8 @@
<TargetFramework>netstandard1.1</TargetFramework> <TargetFramework>netstandard1.1</TargetFramework>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems> <EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>Avalonia.Win32</RootNamespace>
<AssemblyName>Avalonia.Win32</AssemblyName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

Loading…
Cancel
Save