Merge rel/1.0.0 into master.

This commit is contained in:
Eric Erhardt 2017-02-01 14:32:59 -06:00
commit 9f0bb778a1
168 changed files with 4217 additions and 1184 deletions

View file

@ -3,7 +3,7 @@
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetBuild : DotNetTool
public class DotNetBuild : DotNetMSBuildTool
{
protected override string Command
{
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {GetOutputPath()} {GetMaxCpuCount()}"; }
get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetRuntime()} {GetOutputPath()}"; }
}
public string BuildBasePath { get; set; }
@ -26,9 +26,7 @@ namespace Microsoft.DotNet.Cli.Build
public string ProjectPath { get; set; }
public string OutputPath { get; set; }
public string MaxCpuCount { get; set; }
private string GetOutputPath()
{
if (!string.IsNullOrEmpty(OutputPath))
@ -78,15 +76,5 @@ namespace Microsoft.DotNet.Cli.Build
return null;
}
private string GetMaxCpuCount()
{
if (!string.IsNullOrEmpty(MaxCpuCount))
{
return $"/maxcpucount:{MaxCpuCount}";
}
return null;
}
}
}

View file

@ -0,0 +1,30 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetMSBuild : DotNetMSBuildTool
{
protected override string Command
{
get { return "msbuild"; }
}
protected override string Args
{
get { return $"{base.Args} {GetArguments()}"; }
}
public string Arguments { get; set; }
private string GetArguments()
{
if (!string.IsNullOrEmpty(Arguments))
{
return $"{Arguments}";
}
return null;
}
}
}

View file

@ -0,0 +1,32 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.Cli.Build.Framework;
namespace Microsoft.DotNet.Cli.Build
{
public abstract class DotNetMSBuildTool : DotNetTool
{
public int MaxCpuCount {get; set;} = 0;
protected override string Args
{
get
{
return $"{GetMaxCpuCountArg()}";
}
}
private string GetMaxCpuCountArg()
{
if (MaxCpuCount > 0)
{
return $"/m:{MaxCpuCount}";
}
return null;
}
}
}

View file

@ -3,7 +3,7 @@
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetPack : DotNetTool
public class DotNetPack : DotNetMSBuildTool
{
protected override string Command
{
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetProjectPath()} {GetConfiguration()} {GetNoBuild()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {MsbuildArgs}"; }
get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetNoBuild()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {MsbuildArgs}"; }
}
public string Configuration { get; set; }

View file

@ -3,7 +3,7 @@
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetPublish : DotNetTool
public class DotNetPublish : DotNetMSBuildTool
{
protected override string Command
{
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetNativeSubdirectory()} {GetBuildBasePath()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {GetMSBuildArgs()}"; }
get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetFramework()} {GetNativeSubdirectory()} {GetBuildBasePath()} {GetOutput()} {GetVersionSuffix()} {GetRuntime()} {GetMSBuildArgs()}"; }
}
public string BuildBasePath { get; set; }

View file

@ -3,7 +3,7 @@
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetRestore : DotNetTool
public class DotNetRestore : DotNetMSBuildTool
{
protected override string Command
{
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetProjectPath()} {GetConfigFile()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {GetAdditionalParameters()}"; }
get { return $"{base.Args} {GetProjectPath()} {GetConfigFile()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {GetAdditionalParameters()}"; }
}
public string ConfigFile { get; set; }

View file

@ -3,7 +3,7 @@
namespace Microsoft.DotNet.Cli.Build
{
public class DotNetTest : DotNetTool
public class DotNetTest : DotNetMSBuildTool
{
protected override string Command
{
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetProjectPath()} {GetConfiguration()} {GetLogger()} {GetNoBuild()}"; }
get { return $"{base.Args} {GetProjectPath()} {GetConfiguration()} {GetLogger()} {GetNoBuild()}"; }
}
public string Configuration { get; set; }

View file

@ -1,5 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@ -18,6 +19,24 @@ namespace Microsoft.DotNet.Cli.Build
protected abstract string Args { get; }
protected override ProcessStartInfo GetProcessStartInfo(
string pathToTool,
string commandLineCommands,
string responseFileSwitch)
{
var psi = base.GetProcessStartInfo(
pathToTool,
commandLineCommands,
responseFileSwitch);
foreach (var environmentVariableName in new EnvironmentFilter().GetEnvironmentVariableNamesToRemove())
{
psi.Environment.Remove(environmentVariableName);
}
return psi;
}
public string WorkingDirectory { get; set; }
protected override string ToolName

View file

@ -0,0 +1,57 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.DotNet.Cli.Build
{
public class EnvironmentFilter
{
private const string _MSBuildEnvironmentVariablePrefix = "MSBuild";
private const string _DotNetEnvironmentVariablePrefix = "DOTNET";
private const string _NugetEnvironmentVariablePrefix = "NUGET";
private IEnumerable<string> _prefixesOfEnvironmentVariablesToRemove = new string []
{
_MSBuildEnvironmentVariablePrefix,
_DotNetEnvironmentVariablePrefix,
_NugetEnvironmentVariablePrefix
};
private IEnumerable<string> _environmentVariablesToRemove = new string []
{
"CscToolExe"
};
private IEnumerable<string> _environmentVariablesToKeep = new string []
{
"DOTNET_CLI_TELEMETRY_SESSIONID",
"DOTNET_RUNTIME_ID",
"DOTNET_SKIP_FIRST_TIME_EXPERIENCE",
"NUGET_PACKAGES"
};
public IEnumerable<string> GetEnvironmentVariableNamesToRemove()
{
var allEnvironmentVariableNames = (IEnumerable<string>)Environment
.GetEnvironmentVariables()
.Keys
.Cast<string>();
var environmentVariablesToRemoveByPrefix = allEnvironmentVariableNames
.Where(e => _prefixesOfEnvironmentVariablesToRemove.Any(p => e.StartsWith(p)));
var environmentVariablesToRemoveByName = allEnvironmentVariableNames
.Where(e => _environmentVariablesToRemove.Contains(e));
var environmentVariablesToRemove = environmentVariablesToRemoveByName
.Concat(environmentVariablesToRemoveByPrefix)
.Distinct()
.Except(_environmentVariablesToKeep);
return environmentVariablesToRemove;
}
}
}

View file

@ -3,10 +3,10 @@
<PropertyGroup>
<Description>Build scripts for dotnet-cli</Description>
<VersionPrefix>1.0.0</VersionPrefix>
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>netcoreapp1.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>bin\$(Configuration)</OutputPath>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);portable-net45+win8+wp8+wpa81</PackageTargetFallback>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);portable-net45+win8+wp8+wpa81</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\shared-build-targets-utils\shared-build-targets-utils.csproj" />
@ -17,7 +17,7 @@
<Version>1.6.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR">
<Version>1.0.4</Version>
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Build">
<Version>$(CLI_MSBuild_Version)</Version>