Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH1540: Update to latest Roslyn #1645

Merged
merged 5 commits into from
Jul 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ Copyright © .NET Foundation, Patrik Svensson, Mattias Karlsson, Gary Ewan Park,
Cake is provided as-is under the MIT license. For more information see [LICENSE](https://github.com/cake-build/cake/blob/develop/LICENSE).

* For Roslyn, see https://github.com/dotnet/roslyn/blob/master/License.txt
* For Mono.CSharp, see https://github.com/mono/mono/blob/master/mcs/LICENSE
* For Autofac, see https://github.com/autofac/Autofac/blob/master/LICENSE
* For NuGet.Core, see https://github.com/NuGet/Home/blob/dev/LICENSE.txt

Expand Down
74 changes: 50 additions & 24 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ Setup(context =>
parameters.Version.CakeVersion,
parameters.IsTagged);

var releaseNotes = string.Join("\n", parameters.ReleaseNotes.Notes.ToArray()).Replace("\"", "\"\"");

msBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", parameters.Version.SemVersion)
.WithProperty("AssemblyVersion", parameters.Version.Version)
.WithProperty("FileVersion", parameters.Version.Version);
.WithProperty("FileVersion", parameters.Version.Version)
.WithProperty("PackageReleaseNotes", string.Concat("\"", releaseNotes, "\""));

if(!parameters.IsRunningOnWindows)
{
// Use targeting pack when not running on Windows.
Information("Build will use NET462 targeting pack since not building on Windows.");
msBuildSettings.WithProperty("UseTargetingPack", "true");
}
});

Teardown(context =>
Expand Down Expand Up @@ -144,45 +154,45 @@ Task("Copy-Files")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
// .NET 4.5
// .NET 4.6.2
DotNetCorePublish("./src/Cake", new DotNetCorePublishSettings
{
Framework = "net45",
Framework = "net462",
VersionSuffix = parameters.Version.DotNetAsterix,
Configuration = parameters.Configuration,
OutputDirectory = parameters.Paths.Directories.ArtifactsBinNet45,
Verbosity = DotNetCoreVerbosity.Minimal
OutputDirectory = parameters.Paths.Directories.ArtifactsBinFullFx,
MSBuildSettings = msBuildSettings
});

// .NET Core
DotNetCorePublish("./src/Cake", new DotNetCorePublishSettings
{
Framework = "netcoreapp1.0",
Configuration = parameters.Configuration,
OutputDirectory = parameters.Paths.Directories.ArtifactsBinNetCoreApp10,
Verbosity = DotNetCoreVerbosity.Minimal
OutputDirectory = parameters.Paths.Directories.ArtifactsBinNetCore,
MSBuildSettings = msBuildSettings
});

// Copy license
CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinNet45);
CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinNetCoreApp10);
CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinFullFx);
CopyFileToDirectory("./LICENSE", parameters.Paths.Directories.ArtifactsBinNetCore);

// Copy Cake.XML (since publish does not do this anymore)
CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/net45/Cake.xml", parameters.Paths.Directories.ArtifactsBinNet45);
CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/netcoreapp1.0/netcoreapp1.0/Cake.xml", parameters.Paths.Directories.ArtifactsBinNetCoreApp10);
CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/net462/Cake.xml", parameters.Paths.Directories.ArtifactsBinFullFx);
CopyFileToDirectory("./src/Cake/bin/" + parameters.Configuration + "/netcoreapp1.0/netcoreapp1.0/Cake.xml", parameters.Paths.Directories.ArtifactsBinNetCore);
});

Task("Zip-Files")
.IsDependentOn("Copy-Files")
.Does(() =>
{
// .NET 4.5
var homebrewFiles = GetFiles( parameters.Paths.Directories.ArtifactsBinNet45.FullPath + "/**/*");
Zip(parameters.Paths.Directories.ArtifactsBinNet45, parameters.Paths.Files.ZipArtifactPathDesktop, homebrewFiles);
// .NET 4.6.2
var homebrewFiles = GetFiles( parameters.Paths.Directories.ArtifactsBinFullFx.FullPath + "/**/*");
Zip(parameters.Paths.Directories.ArtifactsBinFullFx, parameters.Paths.Files.ZipArtifactPathDesktop, homebrewFiles);

// .NET Core
var coreclrFiles = GetFiles( parameters.Paths.Directories.ArtifactsBinNetCoreApp10.FullPath + "/**/*");
Zip(parameters.Paths.Directories.ArtifactsBinNetCoreApp10, parameters.Paths.Files.ZipArtifactPathCoreClr, coreclrFiles);
var coreclrFiles = GetFiles( parameters.Paths.Directories.ArtifactsBinNetCore.FullPath + "/**/*");
Zip(parameters.Paths.Directories.ArtifactsBinNetCore, parameters.Paths.Files.ZipArtifactPathCoreClr, coreclrFiles);
});

Task("Create-Chocolatey-Packages")
Expand All @@ -193,12 +203,19 @@ Task("Create-Chocolatey-Packages")
{
foreach(var package in parameters.Packages.Chocolatey)
{
var netFxFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinFullFx).FullPath;
var curDirLength = MakeAbsolute(Directory("./")).FullPath.Length + 1;

// Create package.
ChocolateyPack(package.NuspecPath, new ChocolateyPackSettings {
Version = parameters.Version.SemVersion,
ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(),
OutputDirectory = parameters.Paths.Directories.NugetRoot,
Files = parameters.Paths.ChocolateyFiles
Files = GetFiles(netFxFullArtifactPath + "/**/*")
.Where(file => file.FullPath.IndexOf("/runtimes/", StringComparison.OrdinalIgnoreCase) < 0)
.Select(file=>"../" + file.FullPath.Substring(curDirLength))
.Select(file=> new ChocolateyNuSpecContent { Source = file })
.ToArray()
});
}
});
Expand All @@ -221,41 +238,50 @@ Task("Create-NuGet-Packages")
Configuration = parameters.Configuration,
OutputDirectory = parameters.Paths.Directories.NugetRoot,
NoBuild = true,
IncludeSymbols = true,
MSBuildSettings = msBuildSettings
});
}

// Cake - Symbols - .NET 4.5
// Cake - Symbols - .NET 4.6.2
NuGetPack("./nuspec/Cake.symbols.nuspec", new NuGetPackSettings {
Version = parameters.Version.SemVersion,
ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(),
BasePath = parameters.Paths.Directories.ArtifactsBinNet45,
BasePath = parameters.Paths.Directories.ArtifactsBinFullFx,
OutputDirectory = parameters.Paths.Directories.NugetRoot,
Symbols = true,
NoPackageAnalysis = true
});

// Cake - .NET 4.5
var netFxFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinFullFx).FullPath;
var netFxFullArtifactPathLength = netFxFullArtifactPath.Length+1;

// Cake - .NET 4.6.2
NuGetPack("./nuspec/Cake.nuspec", new NuGetPackSettings {
Version = parameters.Version.SemVersion,
ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(),
BasePath = parameters.Paths.Directories.ArtifactsBinNet45,
BasePath = netFxFullArtifactPath,
OutputDirectory = parameters.Paths.Directories.NugetRoot,
Symbols = false,
NoPackageAnalysis = true
NoPackageAnalysis = true,
Files = GetFiles(netFxFullArtifactPath + "/**/*")
.Where(file => file.FullPath.IndexOf("/runtimes/", StringComparison.OrdinalIgnoreCase) < 0)
.Select(file=>file.FullPath.Substring(netFxFullArtifactPathLength))
.Select(file=> new NuSpecContent { Source = file, Target = file })
.ToArray()
});

// Cake Symbols - .NET Core
NuGetPack("./nuspec/Cake.CoreCLR.symbols.nuspec", new NuGetPackSettings {
Version = parameters.Version.SemVersion,
ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(),
BasePath = parameters.Paths.Directories.ArtifactsBinNetCoreApp10,
BasePath = parameters.Paths.Directories.ArtifactsBinNetCore,
OutputDirectory = parameters.Paths.Directories.NugetRoot,
Symbols = true,
NoPackageAnalysis = true
});

var netCoreFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinNetCoreApp10).FullPath;
var netCoreFullArtifactPath = MakeAbsolute(parameters.Paths.Directories.ArtifactsBinNetCore).FullPath;
var netCoreFullArtifactPathLength = netCoreFullArtifactPath.Length+1;

// Cake - .NET Core
Expand Down
99 changes: 14 additions & 85 deletions build/paths.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ public class BuildPaths
{
public BuildFiles Files { get; private set; }
public BuildDirectories Directories { get; private set; }
public ICollection<ChocolateyNuSpecContent> ChocolateyFiles { get; private set; }

public static BuildPaths GetPaths(
ICakeContext context,
Expand All @@ -23,57 +22,15 @@ public class BuildPaths
throw new ArgumentNullException("semVersion");
}

var buildDir = context.Directory("./src/Cake/bin") + context.Directory(configuration);
var artifactsDir = (DirectoryPath)(context.Directory("./artifacts") + context.Directory("v" + semVersion));
var artifactsBinDir = artifactsDir.Combine("bin");
var artifactsBinNet45 = artifactsBinDir.Combine("net45");
var artifactsBinNetCoreApp10 = artifactsBinDir.Combine("netcoreapp1.0");
var artifactsBinFullFx = artifactsBinDir.Combine("net462");
var artifactsBinNetCore = artifactsBinDir.Combine("netcoreapp1.0");
var testResultsDir = artifactsDir.Combine("test-results");
var nugetRoot = artifactsDir.Combine("nuget");
var testingDir = context.Directory("./src/Cake.Testing/bin") + context.Directory(configuration);

var cakeFiles = new FilePath[] {
context.File("Cake.exe"),
context.File("Cake.pdb"),
context.File("Cake.Core.dll"),
context.File("Cake.Core.pdb"),
context.File("Cake.Core.xml"),
context.File("Cake.NuGet.dll"),
context.File("Cake.NuGet.pdb"),
context.File("Cake.NuGet.xml"),
context.File("Cake.Common.dll"),
context.File("Cake.Common.pdb"),
context.File("Cake.Common.xml"),
context.File("Mono.CSharp.dll"),
context.File("Autofac.dll"),
context.File("NuGet.Core.dll")
};

var cakeAssemblyPaths = cakeFiles.Concat(new FilePath[] {"LICENSE"})
.Select(file => buildDir.Path.CombineWithFilePath(file))
.ToArray();

var testingAssemblyPaths = new FilePath[] {
testingDir + context.File("Cake.Testing.dll"),
testingDir + context.File("Cake.Testing.pdb"),
testingDir + context.File("Cake.Testing.xml")
};

var repoFilesPaths = new FilePath[] {
"LICENSE",
"README.md",
"ReleaseNotes.md"
};

var artifactSourcePaths = cakeAssemblyPaths.Concat(testingAssemblyPaths.Concat(repoFilesPaths)).ToArray();

var relPath = new DirectoryPath("./").MakeAbsolute(context.Environment).GetRelativePath(artifactsBinNet45.MakeAbsolute(context.Environment));
var chocolateyFiles = cakeFiles.Concat(new FilePath[] {"LICENSE"})
.Select(file => new ChocolateyNuSpecContent {Source = "../" + relPath.CombineWithFilePath(file).FullPath})
.ToArray();

var zipArtifactPathCoreClr = artifactsDir.CombineWithFilePath("Cake-bin-coreclr-v" + semVersion + ".zip");
var zipArtifactPathDesktop = artifactsDir.CombineWithFilePath("Cake-bin-net45-v" + semVersion + ".zip");
var zipArtifactPathDesktop = artifactsDir.CombineWithFilePath("Cake-bin-net462-v" + semVersion + ".zip");

var testCoverageOutputFilePath = testResultsDir.CombineWithFilePath("OpenCover.xml");

Expand All @@ -83,69 +40,41 @@ public class BuildPaths
testResultsDir,
nugetRoot,
artifactsBinDir,
artifactsBinNet45,
artifactsBinNetCoreApp10);
artifactsBinFullFx,
artifactsBinNetCore);

// Files
var buildFiles = new BuildFiles(
context,
cakeAssemblyPaths,
testingAssemblyPaths,
repoFilesPaths,
artifactSourcePaths,
zipArtifactPathCoreClr,
zipArtifactPathDesktop,
testCoverageOutputFilePath);

return new BuildPaths
{
Files = buildFiles,
Directories = buildDirectories,
ChocolateyFiles = chocolateyFiles
Directories = buildDirectories
};
}
}

public class BuildFiles
{
public ICollection<FilePath> CakeAssemblyPaths { get; private set; }
public ICollection<FilePath> TestingAssemblyPaths { get; private set; }
public ICollection<FilePath> RepoFilesPaths { get; private set; }
public ICollection<FilePath> ArtifactsSourcePaths { get; private set; }
public FilePath ZipArtifactPathCoreClr { get; private set; }
public FilePath ZipArtifactPathDesktop { get; private set; }
public FilePath TestCoverageOutputFilePath { get; private set; }

public BuildFiles(
ICakeContext context,
FilePath[] cakeAssemblyPaths,
FilePath[] testingAssemblyPaths,
FilePath[] repoFilesPaths,
FilePath[] artifactsSourcePaths,
FilePath zipArtifactPathCoreClr,
FilePath zipArtifactPathDesktop,
FilePath testCoverageOutputFilePath
)
{
CakeAssemblyPaths = Filter(context, cakeAssemblyPaths);
TestingAssemblyPaths = Filter(context, testingAssemblyPaths);
RepoFilesPaths = Filter(context, repoFilesPaths);
ArtifactsSourcePaths = Filter(context, artifactsSourcePaths);
ZipArtifactPathCoreClr = zipArtifactPathCoreClr;
ZipArtifactPathDesktop = zipArtifactPathDesktop;
TestCoverageOutputFilePath = testCoverageOutputFilePath;
}

private static FilePath[] Filter(ICakeContext context, FilePath[] files)
{
// Not a perfect solution, but we need to filter PDB files
// when building on an OS that's not Windows (since they don't exist there).
if(!context.IsRunningOnWindows())
{
return files.Where(f => !f.FullPath.EndsWith("pdb")).ToArray();
}
return files;
}
}

public class BuildDirectories
Expand All @@ -154,32 +83,32 @@ public class BuildDirectories
public DirectoryPath TestResults { get; private set; }
public DirectoryPath NugetRoot { get; private set; }
public DirectoryPath ArtifactsBin { get; private set; }
public DirectoryPath ArtifactsBinNet45 { get; private set; }
public DirectoryPath ArtifactsBinNetCoreApp10 { get; private set; }
public DirectoryPath ArtifactsBinFullFx { get; private set; }
public DirectoryPath ArtifactsBinNetCore { get; private set; }
public ICollection<DirectoryPath> ToClean { get; private set; }

public BuildDirectories(
DirectoryPath artifactsDir,
DirectoryPath testResultsDir,
DirectoryPath nugetRoot,
DirectoryPath artifactsBinDir,
DirectoryPath artifactsBinNet45,
DirectoryPath artifactsBinNetCoreApp10
DirectoryPath artifactsBinFullFx,
DirectoryPath artifactsBinNetCore
)
{
Artifacts = artifactsDir;
TestResults = testResultsDir;
NugetRoot = nugetRoot;
ArtifactsBin = artifactsBinDir;
ArtifactsBinNet45 = artifactsBinNet45;
ArtifactsBinNetCoreApp10 = artifactsBinNetCoreApp10;
ArtifactsBinFullFx = artifactsBinFullFx;
ArtifactsBinNetCore = artifactsBinNetCore;
ToClean = new[] {
Artifacts,
TestResults,
NugetRoot,
ArtifactsBin,
ArtifactsBinNet45,
ArtifactsBinNetCoreApp10
ArtifactsBinFullFx,
ArtifactsBinNetCore
};
}
}
Loading