Build and project cleanup

This commit is contained in:
David Fowler 2016-02-15 09:42:17 -08:00
parent b1cba2156b
commit 078d6a8d5f
12 changed files with 151 additions and 147 deletions

View file

@ -127,6 +127,7 @@ namespace Microsoft.DotNet.Cli.Build
var result = CompileStage(c,
dotnet: DotNetCli.Stage1,
outputDir: Dirs.Stage2);
if (!result.Success)
{
return result;
@ -137,7 +138,7 @@ namespace Microsoft.DotNet.Cli.Build
{
var packagingOutputDir = Path.Combine(Dirs.Stage2Compilation, "forPackaging");
Mkdirp(packagingOutputDir);
foreach(var project in ProjectsToPack)
foreach (var project in ProjectsToPack)
{
// Just build them, we'll pack later
DotNetCli.Stage1.Build(
@ -210,7 +211,7 @@ namespace Microsoft.DotNet.Cli.Build
File.Copy(Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(binDir, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true);
// Corehostify binaries
foreach(var binaryToCorehostify in BinariesForCoreHost)
foreach (var binaryToCorehostify in BinariesForCoreHost)
{
try
{
@ -219,7 +220,7 @@ namespace Microsoft.DotNet.Cli.Build
File.Delete(Path.Combine(binDir, $"{binaryToCorehostify}.exe"));
File.Copy(Path.Combine(binDir, $"corehost{Constants.ExeSuffix}"), Path.Combine(binDir, binaryToCorehostify + Constants.ExeSuffix));
}
catch(Exception ex)
catch (Exception ex)
{
return c.Failed($"Failed to corehostify '{binaryToCorehostify}': {ex.ToString()}");
}
@ -234,7 +235,7 @@ namespace Microsoft.DotNet.Cli.Build
// Copy AppDeps
result = CopyAppDeps(c, binDir);
if(!result.Success)
if (!result.Success)
{
return result;
}

View file

@ -25,10 +25,11 @@ namespace Microsoft.DotNet.Cli.Build
var configEnv = Environment.GetEnvironmentVariable("CONFIGURATION");
if(string.IsNullOrEmpty(configEnv))
if (string.IsNullOrEmpty(configEnv))
{
configEnv = "Debug";
}
c.BuildContext["Configuration"] = configEnv;
c.Info($"Building {c.BuildContext["Configuration"]} to: {Dirs.Output}");
@ -160,22 +161,22 @@ cmake is required to build the native host 'corehost'";
try
{
// Read the cache file
if(File.Exists(cacheTimeFile))
if (File.Exists(cacheTimeFile))
{
var content = File.ReadAllText(cacheTimeFile);
if(!string.IsNullOrEmpty(content))
if (!string.IsNullOrEmpty(content))
{
cacheTime = DateTime.ParseExact("O", content, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
}
}
}
catch(Exception ex)
catch (Exception ex)
{
c.Warn($"Error reading NuGet cache time file, leaving the cache alone");
c.Warn($"Error Detail: {ex.ToString()}");
}
if(cacheTime == null || (cacheTime.Value.AddHours(cacheExpiration) < DateTime.UtcNow))
if (cacheTime == null || (cacheTime.Value.AddHours(cacheExpiration) < DateTime.UtcNow))
{
// Cache has expired or the status is unknown, clear it and write the file
c.Info("Clearing NuGet cache");
@ -204,9 +205,9 @@ cmake is required to build the native host 'corehost'";
var lines = File.ReadAllLines(path);
var dict = new Dictionary<string, string>();
c.Verbose("Branch Info:");
foreach(var line in lines)
foreach (var line in lines)
{
if(!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line))
if (!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line))
{
var splat = line.Split(new[] { '=' }, 2);
dict[splat[0]] = splat[1];

View file

@ -65,7 +65,7 @@ namespace Microsoft.DotNet.Cli.Build
foreach (var relativePath in TestPackageProjects)
{
var fullPath = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages", relativePath.Replace('/', Path.DirectorySeparatorChar));
c.Info("Packing: {fullPath}");
c.Info($"Packing: {fullPath}");
dotnet.Pack("--output", Dirs.TestPackages)
.WorkingDirectory(fullPath)
.Execute()
@ -95,7 +95,7 @@ namespace Microsoft.DotNet.Cli.Build
var dotnet = DotNetCli.Stage2;
foreach (var testProject in TestProjects)
{
c.Info("Building tests: {project}");
c.Info($"Building tests: {testProject}");
dotnet.Build()
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "test", testProject))
.Execute()
@ -155,17 +155,17 @@ namespace Microsoft.DotNet.Cli.Build
var consumers = Path.Combine(c.BuildContext.BuildDirectory, "test", "PackagedCommands", "Consumers");
// Compile the consumer apps
foreach(var dir in Directory.EnumerateDirectories(consumers))
foreach (var dir in Directory.EnumerateDirectories(consumers))
{
dotnet.Build().WorkingDirectory(dir).Execute().EnsureSuccessful();
}
// Test the apps
foreach(var dir in Directory.EnumerateDirectories(consumers))
foreach (var dir in Directory.EnumerateDirectories(consumers))
{
var result = dotnet.Exec("hello").WorkingDirectory(dir).CaptureStdOut().CaptureStdErr().Execute();
result.EnsureSuccessful();
if(!string.Equals("Hello", result.StdOut.Trim(), StringComparison.Ordinal))
if (!string.Equals("Hello", result.StdOut.Trim(), StringComparison.Ordinal))
{
var testName = Path.GetFileName(dir);
c.Error($"Packaged Commands Test '{testName}' failed");

View file

@ -9,13 +9,18 @@
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537"
},
"frameworks": {
"net451": {},
"net451": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
}
}
},
"dnxcore50": {
"imports": "portable-net45+win8",
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811"
}
}
},
"scripts": {}
}
}

View file

@ -1,23 +1,23 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"keyFile": "../../tools/Key.snk"
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811",
"System.CommandLine": "0.1.0-e160119-1",
"Microsoft.CodeAnalysis.CSharp": "1.2.0-beta1-20160202-02",
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
"Microsoft.DotNet.Files": {"version": "1.0.0-*", "target": "project"}
"Microsoft.DotNet.Files": {
"version": "1.0.0-*",
"target": "project"
}
},
"frameworks": {
"dnxcore50": {
"imports": "portable-net45+win8"
}
},
"scripts": {
}
"scripts": {}
}

View file

@ -7,25 +7,20 @@
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811",
"System.Linq.Expressions": "4.0.11-rc2-23811",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
"Microsoft.DotNet.Cli.Utils": {
"type": "build",
"version": "1.0.0-*"
},
"Microsoft.DotNet.ProjectModel": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": {
"dnxcore50": {
"imports": "portable-net45+win8"
}
},
"scripts": {
}
"scripts": {}
}

View file

@ -6,7 +6,6 @@
"description": "Types to model a .NET Project",
"dependencies": {
"System.Reflection.Metadata": "1.2.0-rc3-23811",
"NuGet.Packaging": "3.4.0-beta-583",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
"Microsoft.Extensions.JsonParser.Sources": {
@ -25,7 +24,15 @@
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.IO": ""
"System.Runtime": {
"type": "build"
},
"System.Collections": {
"type": "build"
},
"System.IO": {
"type": "build"
}
}
},
"dnxcore50": {
@ -39,7 +46,5 @@
"System.Xml.XDocument": "4.0.11-rc2-23811"
}
}
},
"scripts": {
}
}

View file

@ -3,11 +3,9 @@
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NETStandard.Library" : "1.0.0-rc2-23811"
"NETStandard.Library": "1.0.0-rc2-23811"
},
"frameworks": {
"dnxcore50": {
"imports": "portable-net45+win8"

View file

@ -14,7 +14,7 @@
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16537"
},
"frameworks": {
"net451": { },
"net451": {},
"dotnet5.4": {
"imports": "portable-net451+win8",
"dependencies": {
@ -37,6 +37,5 @@
}
}
},
"scripts": {
}
"scripts": {}
}

View file

@ -15,7 +15,7 @@
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16040"
},
"frameworks": {
"net451": { },
"net451": {},
"dnxcore50": {
"imports": "portable-net45+win8",
"dependencies": {
@ -25,5 +25,5 @@
}
}
},
"scripts": { }
"scripts": {}
}